Ruby  2.0.0p648(2015-12-16revision53162)
version.c
Go to the documentation of this file.
1 /**********************************************************************
2 
3  version.c -
4 
5  $Author: nobu $
6  created at: Thu Sep 30 20:08:01 JST 1993
7 
8  Copyright (C) 1993-2007 Yukihiro Matsumoto
9 
10 **********************************************************************/
11 
12 #include "verconf.h"
13 #include "ruby/ruby.h"
14 #include "version.h"
15 #include <stdio.h>
16 
17 #define PRINT(type) puts(ruby_##type)
18 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1))
19 
20 #ifndef RUBY_ARCH
21 #define RUBY_ARCH RUBY_PLATFORM
22 #endif
23 #ifndef RUBY_SITEARCH
24 #define RUBY_SITEARCH RUBY_ARCH
25 #endif
26 #ifdef RUBY_PLATFORM_CPU
27 #define RUBY_THINARCH RUBY_PLATFORM_CPU"-"RUBY_PLATFORM_OS
28 #endif
29 #ifndef RUBY_LIB_PREFIX
30 #ifndef RUBY_EXEC_PREFIX
31 #error RUBY_EXEC_PREFIX must be defined
32 #endif
33 #define RUBY_LIB_PREFIX RUBY_EXEC_PREFIX"/lib/ruby"
34 #endif
35 #ifndef RUBY_SITE_LIB
36 #define RUBY_SITE_LIB RUBY_LIB_PREFIX"/site_ruby"
37 #endif
38 #ifndef RUBY_VENDOR_LIB
39 #define RUBY_VENDOR_LIB RUBY_LIB_PREFIX"/vendor_ruby"
40 #endif
41 
42 #ifdef RUBY_LIB_VERSION_BLANK
43 #define RUBY_LIB RUBY_LIB_PREFIX
44 #define RUBY_SITE_LIB2 RUBY_SITE_LIB
45 #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB
46 #else
47 #define RUBY_LIB RUBY_LIB_PREFIX "/"RUBY_LIB_VERSION
48 #define RUBY_SITE_LIB2 RUBY_SITE_LIB "/"RUBY_LIB_VERSION
49 #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB "/"RUBY_LIB_VERSION
50 #endif
51 #ifndef RUBY_ARCH_LIB_FOR
52 #define RUBY_ARCH_LIB_FOR(arch) RUBY_LIB "/"arch
53 #endif
54 #ifndef RUBY_SITE_ARCH_LIB_FOR
55 #define RUBY_SITE_ARCH_LIB_FOR(arch) RUBY_SITE_LIB2 "/"arch
56 #endif
57 #ifndef RUBY_VENDOR_ARCH_LIB_FOR
58 #define RUBY_VENDOR_ARCH_LIB_FOR(arch) RUBY_VENDOR_LIB2 "/"arch
59 #endif
60 
61 const int ruby_api_version[] = {
65 };
66 const char ruby_version[] = RUBY_VERSION;
72 const char ruby_engine[] = "ruby";
74 
76 #ifndef NO_INITIAL_LOAD_PATH
77 #ifdef RUBY_SEARCH_PATH
78  RUBY_SEARCH_PATH "\0"
79 #endif
80 #ifndef NO_RUBY_SITE_LIB
81  RUBY_SITE_LIB2 "\0"
82 #ifdef RUBY_THINARCH
83  RUBY_SITE_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
84 #endif
86 #ifndef RUBY_LIB_VERSION_BLANK
87  RUBY_SITE_LIB "\0"
88 #endif
89 #endif
90 
91 #ifndef NO_RUBY_VENDOR_LIB
92  RUBY_VENDOR_LIB2 "\0"
93 #ifdef RUBY_THINARCH
94  RUBY_VENDOR_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
95 #endif
97 #ifndef RUBY_LIB_VERSION_BLANK
98  RUBY_VENDOR_LIB "\0"
99 #endif
100 #endif
101 
102 #ifdef RUBYGEMS_DIR
103  RUBYGEMS_DIR "\0"
104 #endif
105 
106  RUBY_LIB "\0"
107 #ifdef RUBY_THINARCH
108  RUBY_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
109 #endif
111 #endif
112  "";
113 
115 void
117 {
118  /*
119  * The running version of ruby
120  */
121  rb_define_global_const("RUBY_VERSION", MKSTR(version));
122  /*
123  * The date this ruby was released
124  */
125  rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
126  /*
127  * The platform for this ruby
128  */
129  rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
130  /*
131  * The patchlevel for this ruby. If this is a development build of ruby
132  * the patchlevel will be -1
133  */
134  rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
135  /*
136  * The SVN revision for this ruby.
137  */
138  rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
139  /*
140  * The full ruby version string, like <tt>ruby -v</tt> prints'
141  */
142  rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
143  /*
144  * The copyright string for ruby
145  */
146  rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
147  /*
148  * The engine or interpreter this ruby uses.
149  */
150  rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
151 }
152 
154 void
156 {
157  PRINT(description);
158  fflush(stdout);
159 }
160 
164 void
166 {
167  PRINT(copyright);
168  exit(0);
169 }
void rb_define_global_const(const char *, VALUE)
Definition: variable.c:2218
#define RUBY_VENDOR_LIB2
Definition: version.c:49
void Init_version(void)
Defines platform-depended Ruby-level constants.
Definition: version.c:116
const char ruby_copyright[]
Definition: version.c:71
#define RUBY_API_VERSION_TEENY
Definition: version.h:35
#define RUBY_RELEASE_DATE
Definition: tcltklib.c:19
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
Definition: version.c:155
#define RUBY_API_VERSION_MAJOR
Definition: version.h:33
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout and exits this process successfully...
Definition: version.c:165
#define RUBY_VERSION
Definition: tcltklib.c:16
const int ruby_patchlevel
Definition: version.c:69
const char ruby_version[]
Definition: version.c:66
#define RUBY_PATCHLEVEL
Definition: version.h:3
#define RUBY_SITE_LIB
Definition: verconf.h:9
#define RUBY_SITEARCH
Definition: version.c:24
const char ruby_release_date[]
Definition: version.c:67
#define RUBY_SITE_ARCH_LIB_FOR(arch)
Definition: verconf.h:10
const int ruby_api_version[]
Definition: version.c:61
const char ruby_platform[]
Definition: version.c:68
VALUE ruby_engine_name
Definition: version.c:73
#define RUBY_ARCH
Definition: version.c:21
#define Qnil
Definition: ruby.h:435
#define RUBY_COPYRIGHT
Definition: version.h:48
unsigned long VALUE
Definition: ruby.h:104
#define RUBY_PLATFORM
Definition: defines.h:237
#define RUBY_ARCH_LIB_FOR(arch)
Definition: verconf.h:8
#define RUBY_REVISION
Definition: revision.h:1
#define INT2FIX(i)
Definition: ruby.h:241
#define RUBY_SITE_LIB2
Definition: version.c:48
#define PRINT(type)
Definition: version.c:17
#define RUBY_VENDOR_LIB
Definition: verconf.h:11
const char ruby_engine[]
Definition: version.c:72
#define MKSTR(type)
Definition: version.c:18
#define RUBYGEMS_DIR
Definition: verconf.h:3
const char ruby_initial_load_paths[]
Definition: version.c:75
#define RUBY_LIB
Definition: version.c:47
#define RUBY_API_VERSION_MINOR
Definition: version.h:34
#define RUBY_VENDOR_ARCH_LIB_FOR(arch)
Definition: verconf.h:12
static void version(void)
Definition: nkf.c:898
const char ruby_description[]
Definition: version.c:70
#define RUBY_DESCRIPTION
Definition: version.h:42