Ruby  1.9.3p547(2014-05-14revision45962)
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 #define RUBY_ARCHLIB RUBY_LIB "/"RUBY_ARCH
51 #define RUBY_SITE_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_SITEARCH
52 #define RUBY_VENDOR_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_SITEARCH
53 #ifdef RUBY_THINARCH
54 #define RUBY_THIN_ARCHLIB RUBY_LIB "/"RUBY_THINARCH
55 #define RUBY_SITE_THIN_ARCHLIB RUBY_SITE_LIB2 "/"RUBY_THINARCH
56 #define RUBY_VENDOR_THIN_ARCHLIB RUBY_VENDOR_LIB2 "/"RUBY_THINARCH
57 #endif
58 
59 const int ruby_api_version[] = {
63 };
64 const char ruby_version[] = RUBY_VERSION;
70 const char ruby_engine[] = "ruby";
72 
74 #ifndef NO_INITIAL_LOAD_PATH
75 #ifdef RUBY_SEARCH_PATH
76  RUBY_SEARCH_PATH "\0"
77 #endif
78 #ifndef NO_RUBY_SITE_LIB
79  RUBY_SITE_LIB2 "\0"
80 #ifdef RUBY_SITE_THIN_ARCHLIB
81  RUBY_SITE_THIN_ARCHLIB "\0"
82 #endif
84 #ifndef DISABLE_VERSIONED_PATHS
85  RUBY_SITE_LIB "\0"
86 #endif
87 #endif
88 
89 #ifndef NO_RUBY_VENDOR_LIB
90  RUBY_VENDOR_LIB2 "\0"
91 #ifdef RUBY_VENDOR_THIN_ARCHLIB
92  RUBY_VENDOR_THIN_ARCHLIB "\0"
93 #endif
95 #ifndef DISABLE_VERSIONED_PATHS
96  RUBY_VENDOR_LIB "\0"
97 #endif
98 #endif
99 
100 #ifdef RUBYGEMS_DIR
101  RUBYGEMS_DIR "\0"
102 #endif
103 
104  RUBY_LIB "\0"
105 #ifdef RUBY_THIN_ARCHLIB
106  RUBY_THIN_ARCHLIB "\0"
107 #endif
108  RUBY_ARCHLIB "\0"
109 #endif
110  "";
111 
112 void
114 {
115  /*
116  * The running version of ruby
117  */
118  rb_define_global_const("RUBY_VERSION", MKSTR(version));
119  /*
120  * The date this ruby was released
121  */
122  rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
123  /*
124  * The platform for this ruby
125  */
126  rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
127  /*
128  * The patchlevel for this ruby. If this is a development build of ruby
129  * the patchlevel will be -1
130  */
131  rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
132  /*
133  * The SVN revision for this ruby.
134  */
135  rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
136  /*
137  * The full ruby version string, like <tt>ruby -v</tt> prints'
138  */
139  rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
140  /*
141  * The copyright string for ruby
142  */
143  rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
144  /*
145  * The engine or interpreter this ruby uses.
146  */
147  rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
148 }
149 
150 void
152 {
153  PRINT(description);
154  fflush(stdout);
155 }
156 
157 void
159 {
160  PRINT(copyright);
161  exit(0);
162 }
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:113
const char ruby_copyright[]
Definition: version.c:69
#define RUBY_ARCHLIB
Definition: version.c:50
#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:158
#define RUBY_API_VERSION_MAJOR
Definition: version.h:33
#define RUBY_VERSION
Definition: tcltklib.c:16
const int ruby_patchlevel
Definition: version.c:67
const char ruby_version[]
Definition: version.c:64
#define RUBY_SITE_ARCHLIB
Definition: version.c:51
#define RUBY_PATCHLEVEL
Definition: version.h:2
const char ruby_release_date[]
Definition: version.c:65
#define RUBY_VENDOR_LIB
Definition: version.c:38
const int ruby_api_version[]
Definition: version.c:59
const char ruby_platform[]
Definition: version.c:66
VALUE ruby_engine_name
Definition: version.c:71
void ruby_show_version(void)
Definition: version.c:151
#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:70
#define MKSTR(type)
Definition: version.c:17
const char ruby_initial_load_paths[]
Definition: version.c:73
#define RUBY_LIB
Definition: version.c:46
#define RUBY_API_VERSION_MINOR
Definition: version.h:34
#define RUBY_VENDOR_ARCHLIB
Definition: version.c:52
static void version(void)
Definition: nkf.c:874
const char ruby_description[]
Definition: version.c:68
#define RUBY_DESCRIPTION
Definition: version.h:42