Ruby
2.0.0p195(2013-05-14revision40734)
Main Page
Modules
Data Structures
Files
File List
Globals
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
[] = {
56
RUBY_API_VERSION_MAJOR
,
57
RUBY_API_VERSION_MINOR
,
58
RUBY_API_VERSION_TEENY
,
59
};
60
const
char
ruby_version
[] =
RUBY_VERSION
;
61
const
char
ruby_release_date
[] =
RUBY_RELEASE_DATE
;
62
const
char
ruby_platform
[] =
RUBY_PLATFORM
;
63
const
int
ruby_patchlevel
=
RUBY_PATCHLEVEL
;
64
const
char
ruby_description
[] =
RUBY_DESCRIPTION
;
65
const
char
ruby_copyright
[] =
RUBY_COPYRIGHT
;
66
const
char
ruby_engine
[] =
"ruby"
;
67
VALUE
ruby_engine_name
=
Qnil
;
68
69
const
char
ruby_initial_load_paths
[] =
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
79
RUBY_SITE_ARCH_LIB_FOR
(
RUBY_SITEARCH
)
"\0"
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
88
RUBY_VENDOR_ARCH_LIB_FOR
(
RUBY_SITEARCH
)
"\0"
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
96
RUBY_ARCH_LIB_FOR
(
RUBY_ARCH
)
"\0"
97
#endif
98
""
;
99
101
void
102
Init_version
(
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
141
ruby_show_version
(
void
)
142
{
143
PRINT
(description);
144
fflush(stdout);
145
}
146
150
void
151
ruby_show_copyright
(
void
)
152
{
153
PRINT
(copyright);
154
exit(0);
155
}
156
Generated by
1.8.3.1