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

ruby-changes:38752

From: nobu <ko1@a...>
Date: Thu, 11 Jun 2015 17:07:59 +0900 (JST)
Subject: [ruby-changes:38752] nobu:r50833 (trunk): fake.rb.in: scan version.c

nobu	2015-06-11 17:07:49 +0900 (Thu, 11 Jun 2015)

  New Revision: 50833

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

  Log:
    fake.rb.in: scan version.c
    
    * template/fake.rb.in: scan MKSTR and MKINT from version.c and
      then extract the value for them from version.i.
    
    * version.c (Init_version): use MKINT as the marker.

  Modified files:
    trunk/template/fake.rb.in
    trunk/version.c
Index: version.c
===================================================================
--- version.c	(revision 50832)
+++ version.c	(revision 50833)
@@ -19,6 +19,7 @@ https://github.com/ruby/ruby/blob/trunk/version.c#L19
 
 #define PRINT(type) puts(ruby_##type)
 #define MKSTR(type) rb_obj_freeze(rb_usascii_str_new_static(ruby_##type, sizeof(ruby_##type)-1))
+#define MKINT(name) INT2FIX(ruby_##name)
 
 const int ruby_api_version[] = {
     RUBY_API_VERSION_MAJOR,
@@ -38,6 +39,8 @@ VALUE ruby_engine_name = Qnil; https://github.com/ruby/ruby/blob/trunk/version.c#L39
 void
 Init_version(void)
 {
+    enum {ruby_patchlevel = RUBY_PATCHLEVEL};
+    enum {ruby_revision = RUBY_REVISION};
     VALUE version;
     /*
      * The running version of ruby
@@ -55,11 +58,11 @@ Init_version(void) https://github.com/ruby/ruby/blob/trunk/version.c#L58
      * The patchlevel for this ruby.  If this is a development build of ruby
      * the patchlevel will be -1
      */
-    rb_define_global_const("RUBY_PATCHLEVEL", INT2FIX(RUBY_PATCHLEVEL));
+    rb_define_global_const("RUBY_PATCHLEVEL", MKINT(patchlevel));
     /*
      * The SVN revision for this ruby.
      */
-    rb_define_global_const("RUBY_REVISION", INT2FIX(RUBY_REVISION));
+    rb_define_global_const("RUBY_REVISION", MKINT(revision));
     /*
      * The full ruby version string, like <tt>ruby -v</tt> prints'
      */
Index: template/fake.rb.in
===================================================================
--- template/fake.rb.in	(revision 50832)
+++ template/fake.rb.in	(revision 50833)
@@ -8,8 +8,10 @@ end https://github.com/ruby/ruby/blob/trunk/template/fake.rb.in#L8
 if arg['i']
   src = File.read(arg['i'])
   arg['versions'] = version = {}
-  src.scan(/rb_define_global_const\("(RUBY_\w+)",\s*(?:.*rb_\w*str_new\w*\s*\(\s*(\w+)|[\(\s]*\(\s*VALUE\s*\)\s*\((.+)\)\s*\)\s*<<\s?)/) do |n, s, i|
-    version[n] = i ? i.gsub(/\s+/, '').to_i : src[/\b#{s}\[\]\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*);/m, 1].gsub(/\A"|"\s*\z|" *"/, '').gsub(/\\(.)/, '\1')
+  File.read(File.join(arg['srcdir'], 'version.c')).
+    scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|STR)\(([^()]*)\)/m) do |n, v|
+    version[n] =
+        eval(src[/\bruby_#{v}(?:\[\])?\s*=\s*((?:"(?:\\.|[^\"\\])*"\s*)*(?=;)|[^{};]+)/m, 1].gsub(/#/, '\\#'))
   end
 end
 %>baseruby="<%=arg['BASERUBY']%>"

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

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