Ruby  2.0.0p353(2013-11-22revision43784)
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 #define RUBY_LIB RUBY_LIB_PREFIX "/"RUBY_LIB_VERSION
43 #define RUBY_SITE_LIB2 RUBY_SITE_LIB "/"RUBY_LIB_VERSION
44 #define RUBY_VENDOR_LIB2 RUBY_VENDOR_LIB "/"RUBY_LIB_VERSION
45 #ifndef RUBY_ARCH_LIB_FOR
46 #define RUBY_ARCH_LIB_FOR(arch) RUBY_LIB "/"arch
47 #endif
48 #ifndef RUBY_SITE_ARCH_LIB_FOR
49 #define RUBY_SITE_ARCH_LIB_FOR(arch) RUBY_SITE_LIB2 "/"arch
50 #endif
51 #ifndef RUBY_VENDOR_ARCH_LIB_FOR
52 #define RUBY_VENDOR_ARCH_LIB_FOR(arch) RUBY_VENDOR_LIB2 "/"arch
53 #endif
54 
55 const int ruby_api_version[] = {
59 };
60 const char ruby_version[] = RUBY_VERSION;
66 const char ruby_engine[] = "ruby";
68 
70 #ifndef NO_INITIAL_LOAD_PATH
71 #ifdef RUBY_SEARCH_PATH
72  RUBY_SEARCH_PATH "\0"
73 #endif
74 #ifndef NO_RUBY_SITE_LIB
75  RUBY_SITE_LIB2 "\0"
76 #ifdef RUBY_THINARCH
77  RUBY_SITE_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
78 #endif
80  RUBY_SITE_LIB "\0"
81 #endif
82 
83 #ifndef NO_RUBY_VENDOR_LIB
84  RUBY_VENDOR_LIB2 "\0"
85 #ifdef RUBY_THINARCH
86  RUBY_VENDOR_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
87 #endif
89  RUBY_VENDOR_LIB "\0"
90 #endif
91 
92  RUBY_LIB "\0"
93 #ifdef RUBY_THINARCH
94  RUBY_ARCH_LIB_FOR(RUBY_THINARCH) "\0"
95 #endif
97 #endif
98  "";
99 
101 void
103 {
104  /*
105  * The running version of ruby
106  */
107  rb_define_global_const("RUBY_VERSION", MKSTR(version));
108  /*
109  * The date this ruby was released
110  */
111  rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
112  /*
113  * The platform for this ruby
114  */
115  rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
116  /*
117  * The patchlevel for this ruby. If this is a development build of ruby
118  * the patchlevel will be -1
119  */
120  rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
121  /*
122  * The SVN revision for this ruby.
123  */
124  rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
125  /*
126  * The full ruby version string, like <tt>ruby -v</tt> prints'
127  */
128  rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
129  /*
130  * The copyright string for ruby
131  */
132  rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
133  /*
134  * The engine or interpreter this ruby uses.
135  */
136  rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
137 }
138 
140 void
142 {
143  PRINT(description);
144  fflush(stdout);
145 }
146 
150 void
152 {
153  PRINT(copyright);
154  exit(0);
155 }
void rb_define_global_const(const char *, VALUE)
Definition: variable.c:2216
#define RUBY_VENDOR_LIB2
Definition: version.c:44
void Init_version(void)
Defines platform-depended Ruby-level constants.
Definition: version.c:102
const char ruby_copyright[]
Definition: version.c:65
#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:141
#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:151
#define RUBY_VERSION
Definition: tcltklib.c:16
const int ruby_patchlevel
Definition: version.c:63
const char ruby_version[]
Definition: version.c:60
#define RUBY_PATCHLEVEL
Definition: version.h:3
#define RUBY_SITE_LIB
Definition: verconf.h:8
#define RUBY_SITEARCH
Definition: version.c:24
const char ruby_release_date[]
Definition: version.c:61
#define RUBY_SITE_ARCH_LIB_FOR(arch)
Definition: verconf.h:9
const int ruby_api_version[]
Definition: version.c:55
const char ruby_platform[]
Definition: version.c:62
VALUE ruby_engine_name
Definition: version.c:67
#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:7
#define RUBY_REVISION
Definition: revision.h:1
#define INT2FIX(i)
Definition: ruby.h:241
#define RUBY_SITE_LIB2
Definition: version.c:43
#define PRINT(type)
Definition: version.c:17
#define RUBY_VENDOR_LIB
Definition: verconf.h:10
const char ruby_engine[]
Definition: version.c:66
#define MKSTR(type)
Definition: version.c:18
const char ruby_initial_load_paths[]
Definition: version.c:69
#define RUBY_LIB
Definition: version.c:42
#define RUBY_API_VERSION_MINOR
Definition: version.h:34
#define RUBY_VENDOR_ARCH_LIB_FOR(arch)
Definition: verconf.h:11
static void version(void)
Definition: nkf.c:898
const char ruby_description[]
Definition: version.c:64
#define RUBY_DESCRIPTION
Definition: version.h:42