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