Ruby  2.5.0dev(2017-10-22revision60238)
version.c
Go to the documentation of this file.
1 /**********************************************************************
2 
3  version.c -
4 
5  $Author$
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_static(ruby_##type, sizeof(ruby_##type)-1))
22 #define MKINT(name) INT2FIX(ruby_##name)
23 
24 const int ruby_api_version[] = {
28 };
29 const char ruby_version[] = RUBY_VERSION;
35 const char ruby_engine[] = "ruby";
36 
38 void
40 {
42  enum {ruby_revision = RUBY_REVISION};
43  VALUE version;
44  VALUE ruby_engine_name;
45  /*
46  * The running version of ruby
47  */
48  rb_define_global_const("RUBY_VERSION", (version = MKSTR(version)));
49  /*
50  * The date this ruby was released
51  */
52  rb_define_global_const("RUBY_RELEASE_DATE", MKSTR(release_date));
53  /*
54  * The platform for this ruby
55  */
56  rb_define_global_const("RUBY_PLATFORM", MKSTR(platform));
57  /*
58  * The patchlevel for this ruby. If this is a development build of ruby
59  * the patchlevel will be -1
60  */
61  rb_define_global_const("RUBY_PATCHLEVEL", MKINT(patchlevel));
62  /*
63  * The SVN revision for this ruby.
64  */
65  rb_define_global_const("RUBY_REVISION", MKINT(revision));
66  /*
67  * The full ruby version string, like <tt>ruby -v</tt> prints'
68  */
69  rb_define_global_const("RUBY_DESCRIPTION", MKSTR(description));
70  /*
71  * The copyright string for ruby
72  */
73  rb_define_global_const("RUBY_COPYRIGHT", MKSTR(copyright));
74  /*
75  * The engine or interpreter this ruby uses.
76  */
77  rb_define_global_const("RUBY_ENGINE", ruby_engine_name = MKSTR(engine));
78  ruby_set_script_name(ruby_engine_name);
79  /*
80  * The version of the engine or interpreter this ruby uses.
81  */
82  rb_define_global_const("RUBY_ENGINE_VERSION", (1 ? version : MKSTR(version)));
83 }
84 
86 void
88 {
89  PRINT(description);
90 #ifdef RUBY_LAST_COMMIT_TITLE
91  fputs("last_commit=" RUBY_LAST_COMMIT_TITLE, stdout);
92 #endif
93 #ifdef HAVE_MALLOC_CONF
94  if (malloc_conf) printf("malloc_conf=%s\n", malloc_conf);
95 #endif
96  fflush(stdout);
97 }
98 
100 void
102 {
103  PRINT(copyright);
104  fflush(stdout);
105 }
void rb_define_global_const(const char *, VALUE)
Definition: variable.c:2702
void Init_version(void)
Defines platform-depended Ruby-level constants.
Definition: version.c:39
const char ruby_copyright[]
Definition: version.c:34
#define RUBY_API_VERSION_TEENY
Definition: version.h:35
void ruby_show_version(void)
Prints the version information of the CRuby interpreter to stdout.
Definition: version.c:87
#define RUBY_API_VERSION_MAJOR
Definition: version.h:33
void ruby_show_copyright(void)
Prints the copyright notice of the CRuby interpreter to stdout.
Definition: version.c:101
const int ruby_patchlevel
Definition: version.c:32
const char ruby_version[]
Definition: version.c:29
#define RUBY_PATCHLEVEL
Definition: version.h:3
const char ruby_release_date[]
Definition: version.c:30
#define RUBY_VERSION
Definition: version.h:1
const int ruby_api_version[]
Definition: version.c:24
const char ruby_platform[]
Definition: version.c:31
void ruby_set_script_name(VALUE name)
Sets the current script name to this value.
Definition: ruby.c:2132
#define RUBY_RELEASE_DATE
Definition: version.h:2
#define RUBY_COPYRIGHT
Definition: version.h:69
unsigned long VALUE
Definition: ruby.h:85
#define RUBY_PLATFORM
Definition: defines.h:325
#define PRINT(type)
Definition: version.c:20
#define MKINT(name)
Definition: version.c:22
const char ruby_engine[]
Definition: version.c:35
#define MKSTR(type)
Definition: version.c:21
#define RUBY_REVISION
Definition: loadpath.c:16
#define RUBY_API_VERSION_MINOR
Definition: version.h:34
#define RUBY_DESCRIPTION
Definition: version.h:63
const char ruby_description[]
Definition: version.c:33