[前][次][番号順一覧][スレッド一覧]

ruby-changes:10803

From: nobu <ko1@a...>
Date: Tue, 17 Feb 2009 17:02:55 +0900 (JST)
Subject: [ruby-changes:10803] Ruby:r22371 (ruby_1_8): * version.c, version.h: NO_STRING_LITERAL_CONCATENATION support.

nobu	2009-02-17 17:02:47 +0900 (Tue, 17 Feb 2009)

  New Revision: 22371

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22371

  Log:
    * version.c, version.h: NO_STRING_LITERAL_CONCATENATION support.

  Modified files:
    branches/ruby_1_8/ChangeLog
    branches/ruby_1_8/version.c
    branches/ruby_1_8/version.h

Index: ruby_1_8/ChangeLog
===================================================================
--- ruby_1_8/ChangeLog	(revision 22370)
+++ ruby_1_8/ChangeLog	(revision 22371)
@@ -1,3 +1,7 @@
+Tue Feb 17 17:02:45 2009  Nobuyoshi Nakada  <nobu@r...>
+
+	* version.c, version.h: NO_STRING_LITERAL_CONCATENATION support.
+
 Tue Feb 17 17:00:49 2009  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in (MAJOR, MINOR, TEENY): uses RUBY_VERSION_*.
Index: ruby_1_8/version.c
===================================================================
--- ruby_1_8/version.c	(revision 22370)
+++ ruby_1_8/version.c	(revision 22371)
@@ -14,15 +14,31 @@
 #include "version.h"
 #include <stdio.h>
 
-#define PRINT(type) puts(ruby_##type)
-#define MKSTR(type) rb_obj_freeze(rb_str_new(ruby_##type, sizeof(ruby_##type)-1))
+#define PRINT(type) puts(TOKEN_PASTE(ruby_,type))
+#ifndef rb_str_new_cstr
+#define rb_str_new_cstr(str) rb_str_new(str, strlen(str))
+#endif
+#define MKSTR(type) rb_obj_freeze(rb_str_new_cstr(TOKEN_PASTE(ruby_,type)))
 
 const char ruby_version[] = RUBY_VERSION;
 const char ruby_release_date[] = RUBY_RELEASE_DATE;
 const char ruby_platform[] = RUBY_PLATFORM;
 const int ruby_patchlevel = RUBY_PATCHLEVEL;
+#ifdef RUBY_DESCRIPTION
 const char ruby_description[] = RUBY_DESCRIPTION;
+#else
+char ruby_description[
+    sizeof("ruby  () []") +
+    sizeof(RUBY_VERSION)-1 + sizeof(RUBY_PATCHLEVEL_STR)-1 +
+    sizeof(RUBY_RELEASE_DATE)-1 + sizeof(RUBY_REVISION_STR)-1 +
+    sizeof(RUBY_PLATFORM)-1];
+#endif
+#ifdef RUBY_COPYRIGHT
 const char ruby_copyright[] = RUBY_COPYRIGHT;
+#else
+char ruby_copyright[
+    sizeof("ruby - Copyright (C) - ") + 20 + sizeof(RUBY_AUTHOR)-1];
+#endif
 
 void
 Init_version()
@@ -31,6 +47,20 @@
     VALUE d = MKSTR(release_date);
     VALUE p = MKSTR(platform);
 
+#ifndef RUBY_DESCRIPTION
+    snprintf(ruby_description, sizeof(ruby_description),
+	     "ruby %s%s (%s%s) [%s]",
+	     RUBY_VERSION, RUBY_PATCHLEVEL_STR,
+	     RUBY_RELEASE_DATE, RUBY_REVISION_STR,
+	     RUBY_PLATFORM);
+#endif
+#ifndef RUBY_COPYRIGHT
+    snprintf(ruby_copyright, sizeof(ruby_copyright),
+	     "ruby - Copyright (C) %d-%d %s",
+	     RUBY_BIRTH_YEAR, RUBY_RELEASE_YEAR,
+	     RUBY_AUTHOR);
+#endif
+	     
     rb_define_global_const("RUBY_VERSION", v);
     rb_define_global_const("RUBY_RELEASE_DATE", d);
     rb_define_global_const("RUBY_PLATFORM", p);
Index: ruby_1_8/version.h
===================================================================
--- ruby_1_8/version.h	(revision 22370)
+++ ruby_1_8/version.h	(revision 22371)
@@ -16,9 +16,11 @@
 RUBY_EXTERN const char ruby_release_date[];
 RUBY_EXTERN const char ruby_platform[];
 RUBY_EXTERN const int ruby_patchlevel;
+#ifndef NO_STRING_LITERAL_CONCATENATION
 RUBY_EXTERN const char ruby_description[];
 RUBY_EXTERN const char ruby_copyright[];
 #endif
+#endif
 
 #define RUBY_AUTHOR "Yukihiro Matsumoto"
 #define RUBY_BIRTH_YEAR 1993
@@ -32,24 +34,29 @@
 #define RUBY_REVISION 0
 #endif
 
-#if RUBY_VERSION_TEENY > 0 && RUBY_PATCHLEVEL < 5000
-#define RUBY_RELEASE_STR "patchlevel"
-#define RUBY_RELEASE_NUM RUBY_PATCHLEVEL
+#if RUBY_PATCHLEVEL == -1
+#define RUBY_PATCHLEVEL_STR "dev"
 #else
-#ifdef RUBY_BRANCH_NAME
-#define RUBY_RELEASE_STR RUBY_BRANCH_NAME
+#define RUBY_PATCHLEVEL_STR "p"STRINGIZE(RUBY_PATCHLEVEL)
+#endif
+
+#if RUBY_REVISION
+# ifdef RUBY_BRANCH_NAME
+#  define RUBY_REVISION_STR " "RUBY_BRANCH_NAME" "STRINGIZE(RUBY_REVISION)
+# else
+#  define RUBY_REVISION_STR " revision "STRINGIZE(RUBY_REVISION)
+# endif
 #else
-#define RUBY_RELEASE_STR "revision"
+# define RUBY_REVISION_STR ""
 #endif
-#define RUBY_RELEASE_NUM RUBY_REVISION
-#endif
 
+#ifndef NO_STRING_LITERAL_CONCATENATION
 #ifndef RUBY_DESCRIPTION
 # define RUBY_DESCRIPTION	    \
     "ruby "RUBY_VERSION		    \
-    " ("RUBY_RELEASE_DATE" "	    \
-    RUBY_RELEASE_STR" "		    \
-    STRINGIZE(RUBY_RELEASE_NUM)") " \
+    RUBY_PATCHLEVEL_STR             \
+    " ("RUBY_RELEASE_DATE	    \
+    RUBY_REVISION_STR") "	    \
     "["RUBY_PLATFORM"]"
 #endif
 #ifndef RUBY_COPYRIGHT
@@ -59,3 +66,4 @@
     STRINGIZE(RUBY_RELEASE_YEAR)" " \
     RUBY_AUTHOR
 #endif
+#endif

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]