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

ruby-changes:36409

From: nobu <ko1@a...>
Date: Wed, 19 Nov 2014 10:08:06 +0900 (JST)
Subject: [ruby-changes:36409] nobu:r48490 (trunk): prelude.c.tmpl: strip prefix

nobu	2014-11-19 10:08:00 +0900 (Wed, 19 Nov 2014)

  New Revision: 48490

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

  Log:
    prelude.c.tmpl: strip prefix
    
    * template/prelude.c.tmpl (Prelude#translate): strip VPATH prefix
      from prelude names, so that srcdir diffrences do not make the
      generated code diffrent.

  Modified files:
    trunk/ChangeLog
    trunk/template/prelude.c.tmpl
    trunk/tool/vpath.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48489)
+++ ChangeLog	(revision 48490)
@@ -1,3 +1,9 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Nov 19 10:07:57 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* template/prelude.c.tmpl (Prelude#translate): strip VPATH prefix
+	  from prelude names, so that srcdir diffrences do not make the
+	  generated code diffrent.
+
 Wed Nov 19 07:45:11 2014  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (rb_w32_write): should set the error of
Index: tool/vpath.rb
===================================================================
--- tool/vpath.rb	(revision 48489)
+++ tool/vpath.rb	(revision 48490)
@@ -79,4 +79,9 @@ class VPath https://github.com/ruby/ruby/blob/trunk/tool/vpath.rb#L79
     end
     @list
   end
+
+  def strip(path)
+    prefix = list.map {|dir| Regexp.quote(dir)}
+    path.sub(/\A#{prefix.join('|')}(?:\/|\z)/, '')
+  end
 end
Index: template/prelude.c.tmpl
===================================================================
--- template/prelude.c.tmpl	(revision 48489)
+++ template/prelude.c.tmpl	(revision 48490)
@@ -41,7 +41,7 @@ class Prelude https://github.com/ruby/ruby/blob/trunk/template/prelude.c.tmpl#L41
     idx = @preludes[filename]
     return idx if idx
     lines = []
-    result = [@preludes.size, filename, lines, sub]
+    result = [@preludes.size, @vpath.strip(filename), lines, sub]
     @vpath.foreach(filename) do |line|
       @preludes[filename] ||= result
       line.sub!(/(?:^|\s+)\#(?:$|\s.*)/, '')

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

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