Ruby  2.1.10p492(2016-04-01revision54464)
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[] = {
27 };
28 const char ruby_version[] = RUBY_VERSION;
34 const char ruby_engine[] = "ruby";
36 
38 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
79 {
80  PRINT(description);
81  fflush(stdout);
82 }
83 
87 void
89 {
90  PRINT(copyright);
91  exit(EXIT_SUCCESS);
92 }
void Init_version(void)
Defines platform-depended Ruby-level constants.
Definition: version.c:39
const char ruby_copyright[]
Definition: version.c:33
#define RUBY_API_VERSION_TEENY
Definition: version.h:35
#define RUBY_RELEASE_DATE
Definition: tcltklib.c:19
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
Definition: version.c:78
void rb_define_global_const(const char *, VALUE)
Definition: variable.c:2239
#define RUBY_API_VERSION_MAJOR
Definition: version.h:33
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout and exits this process successfully...
Definition: version.c:88
#define RUBY_VERSION
Definition: tcltklib.c:16
const int ruby_patchlevel
Definition: version.c:31
const char ruby_version[]
Definition: version.c:28
#define RUBY_PATCHLEVEL
Definition: version.h:3
const char ruby_release_date[]
Definition: version.c:29
#define EXIT_SUCCESS
Definition: version.c:17
const int ruby_api_version[]
Definition: version.c:23
#define Qnil
Definition: enum.c:67
const char ruby_platform[]
Definition: version.c:30
#define INT2FIX(i)
VALUE ruby_engine_name
Definition: version.c:35
#define RUBY_COPYRIGHT
Definition: version.h:48
#define RUBY_PLATFORM
Definition: defines.h:299
#define PRINT(type)
Definition: version.c:20
const char ruby_engine[]
Definition: version.c:34
#define MKSTR(type)
Definition: version.c:21
#define RUBY_REVISION
Definition: loadpath.c:16
const char ruby_description[]
Definition: version.c:32
#define RUBY_API_VERSION_MINOR
Definition: version.h:34
unsigned long VALUE
Definition: ripper.y:88
static void version(void)
Definition: nkf.c:898
#define RUBY_DESCRIPTION
Definition: version.h:42