Ruby 2.1.5p273(2014-11-13revision48405)

- 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 "ruby/ruby.h"
13 #include "version.h"
14 #include <stdio.h>
15
16 #ifndef EXIT_SUCCESS
17 #define EXIT_SUCCESS 0
18 #endif
19
20 #define PRINT(type) puts(ruby_##type)
21 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new(ruby_##type, sizeof(ruby_##type)-1))
22
23 const int ruby_api_version[] = {
24 RUBY_API_VERSION_MAJOR,
25 RUBY_API_VERSION_MINOR,
26 RUBY_API_VERSION_TEENY,
27 };
28 const char ruby_version[] = RUBY_VERSION;
29 const char ruby_release_date[] = RUBY_RELEASE_DATE;
30 const char ruby_platform[] = RUBY_PLATFORM;
31 const int ruby_patchlevel = RUBY_PATCHLEVEL;
32 const char ruby_description[] = RUBY_DESCRIPTION;
33 const char ruby_copyright[] = RUBY_COPYRIGHT;
34 const char ruby_engine[] = "ruby";
35 VALUE ruby_engine_name = Qnil;
36
38 void
39 Init_version(void)
40 {
41 /*
42 * The running version of ruby
43 */
44 rb_define_global_const("RUBY_VERSION", MKSTR(version));
45 /*
46 * The date this ruby was released
47 */
48 rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
49 /*
50 * The platform for this ruby
51 */
52 rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
53 /*
54 * The patchlevel for this ruby. If this is a development build of ruby
55 * the patchlevel will be -1
56 */
57 rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
58 /*
59 * The SVN revision for this ruby.
60 */
61 rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
62 /*
63 * The full ruby version string, like <tt>ruby -v</tt> prints'
64 */
65 rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
66 /*
67 * The copyright string for ruby
68 */
69 rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
70 /*
71 * The engine or interpreter this ruby uses.
72 */
73 rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
74 }
75
77 void
78 ruby_show_version(void)
79 {
80 PRINT(description);
81 fflush(stdout);
82 }
83
87 void
88 ruby_show_copyright(void)
89 {
90 PRINT(copyright);
91 exit(EXIT_SUCCESS);
92 }
rb_define_global_const
void rb_define_global_const(const char *, VALUE)
Definition: variable.c:2236
Init_version
void Init_version(void)
Defines platform-depended Ruby-level constants.
Definition: version.c:39
ruby_copyright
const char ruby_copyright[]
Definition: version.c:33
RUBY_API_VERSION_TEENY
#define RUBY_API_VERSION_TEENY
Definition: version.h:35
RUBY_RELEASE_DATE
#define RUBY_RELEASE_DATE
Definition: tcltklib.c:19
ruby.h
ruby_show_version
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
Definition: version.c:78
RUBY_API_VERSION_MAJOR
#define RUBY_API_VERSION_MAJOR
Definition: version.h:33
ruby_show_copyright
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout and exits this process successfully...
Definition: version.c:88
RUBY_VERSION
#define RUBY_VERSION
Definition: tcltklib.c:16
ruby_patchlevel
const int ruby_patchlevel
Definition: version.c:31
ruby_version
const char ruby_version[]
Definition: version.c:28
RUBY_PATCHLEVEL
#define RUBY_PATCHLEVEL
Definition: version.h:3
ruby_release_date
const char ruby_release_date[]
Definition: version.c:29
EXIT_SUCCESS
#define EXIT_SUCCESS
Definition: version.c:17
ruby_api_version
const int ruby_api_version[]
Definition: version.c:23
ruby_platform
const char ruby_platform[]
Definition: version.c:30
ruby_engine_name
VALUE ruby_engine_name
Definition: version.c:35
Qnil
#define Qnil
Definition: ruby.h:427
RUBY_COPYRIGHT
#define RUBY_COPYRIGHT
Definition: version.h:48
VALUE
unsigned long VALUE
Definition: ruby.h:88
version.h
RUBY_PLATFORM
#define RUBY_PLATFORM
Definition: defines.h:299
INT2FIX
#define INT2FIX(i)
Definition: ruby.h:231
PRINT
#define PRINT(type)
Definition: version.c:20
ruby_engine
const char ruby_engine[]
Definition: version.c:34
MKSTR
#define MKSTR(type)
Definition: version.c:21
RUBY_REVISION
#define RUBY_REVISION
Definition: loadpath.c:16
RUBY_API_VERSION_MINOR
#define RUBY_API_VERSION_MINOR
Definition: version.h:34
version
static void version(void)
Definition: nkf.c:898
ruby_description
const char ruby_description[]
Definition: version.c:32
RUBY_DESCRIPTION
#define RUBY_DESCRIPTION
Definition: version.h:42