e$B$J$+$@$G$9!#e(B
At Wed, 14 Nov 2007 16:20:12 +0900,
Yukihiro M. wrote in [ruby-dev:32288]:
|e$B!!e(B[ruby-dev:31743] e$B$GCfED$5$s$,Ds0F$7$F$$$k$b$N$K!$$J$K$,$7$+$NL>A0e(B
|e$B$GFM$C9~$`$N$,0lHV$$$$$h$&$J5$$O$7$F$$$^$9!%e(B
e$B8D?ME*$K$O$"$"$$$&8DJL%%V%8%’%/%H$NF3F~$O$"$^$j9%$_$G$J$$$Ne(B
e$B$G!"e(BRUBY_LONG_VERSIONe$BE$JJ8;zNs$r<h$j9~$`$3$H$GBE6($G$-$^$;e(B
e$B$s$+!)e(B
e$B8DJL%*%V%8%’%/%H$H$$$&$N$Oe(BRuby modulee$B$G$9$+e(B?
e$B$?$V$s!"$5$5$@$5$se(B
e$B$N$$$C$F$$$k$N$Oe(BRuby::VersionNumbere$B$N$3$H$G$O$J$$$N$G$O$J$$$+$He(B
e$B;W$&$N$G$9$,!#e(B
e$B$H$j$"$($:$3$s$J$N$O$I$&$G$7$g$&$+!#e(B
Index: include/ruby/defines.h
— include/ruby/defines.h (revision 13945)
+++ include/ruby/defines.h (working copy)
@@ -65,4 +65,9 @@ void xrealloc2(void,size_t,size_t);
void xfree(void*);
+#define STRINGIZE(expr) STRINGIZE0(expr)
+#ifndef STRINGIZE0
+#define STRINGIZE0(expr) #expr
+#endif
+
#if SIZEOF_LONG_LONG > 0
define LONG_LONG long long
Index: version.c
— version.c (revision 13945)
+++ version.c (working copy)
@@ -15,4 +15,7 @@
#include <stdio.h>
+#define PRINT(type) puts(RUBY_##type)
+#define MKSTR(type) rb_str_new(RUBY_##type, sizeof(RUBY_##type)-1)
+
const char ruby_version[] = RUBY_VERSION;
const char ruby_release_date[] = RUBY_RELEASE_DATE;
@@ -23,12 +26,21 @@ void
Init_version(void)
{
- const char *varname;
+#define RUBY_CONST(name, val) ( \
- varname = “RUBY_” #name, \
- rb_define_const(mRuby, varname + 5, val), \
- rb_define_global_const(varname, val))
-
- VALUE mRuby = rb_define_module(“Ruby”);
VALUE v = rb_obj_freeze(rb_str_new2(ruby_version));
VALUE d = rb_obj_freeze(rb_str_new2(ruby_release_date));
VALUE p = rb_obj_freeze(rb_str_new2(ruby_platform));
- rb_define_global_const(“RUBY_VERSION”, v);
- rb_define_global_const(“RUBY_RELEASE_DATE”, d);
- rb_define_global_const(“RUBY_PLATFORM”, p);
- rb_define_global_const(“RUBY_PATCHLEVEL”,
INT2FIX(RUBY_PATCHLEVEL));
- RUBY_CONST(VERSION, v);
- RUBY_CONST(RELEASE_DATE, d);
- RUBY_CONST(PLATFORM, p);
- RUBY_CONST(PATCHLEVEL, INT2FIX(RUBY_PATCHLEVEL));
- RUBY_CONST(DESCRIPTION, MKSTR(DESCRIPTION));
- RUBY_CONST(COPYRIGHT, MKSTR(COPYRIGHT));
}
@@ -36,5 +48,5 @@ void
ruby_show_version(void)
{
- printf(“ruby %s (%s patchlevel %d) [%s]\n”, RUBY_VERSION,
RUBY_RELEASE_DATE, RUBY_PATCHLEVEL, RUBY_PLATFORM);
- PRINT(VERSION);
fflush(stdout);
}
@@ -43,5 +55,5 @@ void
ruby_show_copyright(void)
{
- printf(“ruby - Copyright © 1993-%d Yukihiro M.\n”,
RUBY_RELEASE_YEAR);
- PRINT(COPYRIGHT);
exit(0);
}
Index: version.h
===================================================================
— version.h (revision 13945)
+++ version.h (working copy)
@@ -1,2 +1,4 @@
+#ifndef RUBY_VERSION
-
#define RUBY_VERSION “1.9.0”
#define RUBY_RELEASE_DATE “2007-11-16”
@@ -18,2 +20,24 @@ RUBY_EXTERN const char ruby_platform[];
RUBY_EXTERN const int ruby_patchlevel;
#endif
+
+#define RUBY_AUTHOR “Yukihiro M.”
+#define RUBY_BIRTH_YEAR 1993
+#define RUBY_BIRTH_MONTH 2
+#define RUBY_BIRTH_DAY 24
+
+#define RUBY_RELEASE_STR “patchlevel”
+#define RUBY_RELEASE_NUM RUBY_PATCHLEVEL
+
+# define RUBY_DESCRIPTION \
- "ruby "RUBY_VERSION \
- " (“RUBY_RELEASE_DATE” " \
- RUBY_RELEASE_STR" " \
- STRINGIZE(RUBY_RELEASE_NUM)") " \
- “[“RUBY_PLATFORM”]”
+# define RUBY_COPYRIGHT \
- "ruby - Copyright © " \
- STRINGIZE(RUBY_BIRTH_YEAR)"-" \
- STRINGIZE(RUBY_RELEASE_YEAR)" " \
- RUBY_AUTHOR
-
+#endif