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