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

ruby-changes:5174

From: nobu <ko1@a...>
Date: Wed, 28 May 2008 17:51:16 +0900 (JST)
Subject: [ruby-changes:5174] Ruby:r16669 (trunk): * win32/mkexports.rb (Exports#objdump, Exports#each_line): extracted.

nobu	2008-05-28 17:50:41 +0900 (Wed, 28 May 2008)

  New Revision: 16669

  Modified files:
    trunk/ChangeLog
    trunk/win32/mkexports.rb

  Log:
    * win32/mkexports.rb (Exports#objdump, Exports#each_line): extracted.


  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/win32/mkexports.rb?r1=16669&r2=16668&diff_format=u
  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16669&r2=16668&diff_format=u

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 16668)
+++ ChangeLog	(revision 16669)
@@ -1,3 +1,7 @@
+Wed May 28 17:50:32 2008  Nobuyoshi Nakada  <nobu@r...>
+
+	* win32/mkexports.rb (Exports#objdump, Exports#each_line): extracted.
+
 Wed May 28 17:41:43 2008  Nobuyoshi Nakada  <nobu@r...>
 
 	* Makefile.in (MKPREP): appended $(RBCONFIG).
Index: win32/mkexports.rb
===================================================================
--- win32/mkexports.rb	(revision 16668)
+++ win32/mkexports.rb	(revision 16669)
@@ -27,7 +27,7 @@
 
   def self.output(output = $output, &block)
     if output
-      open(output, 'w', &block)
+      open(output, 'wb', &block)
     else
       yield STDOUT
     end
@@ -74,38 +74,50 @@
   def each_export(objs)
   end
 
+  def objdump(objs, &block)
+    if objs.empty?
+      $stdin.each_line(&block)
+    else
+      each_line(objs, &block)
+    end
+  end
+
   def symbols()
     @syms.sort.collect {|k, v| v ? v == true ? "#{k} DATA" : "#{k}=#{v}" : k}
   end
 end
 
 class Exports::Mswin < Exports
+  def each_line(objs, &block)
+    IO.popen(%w"dumpbin -symbols -exports" + objs) do |f|
+      f.each(&block)
+    end
+  end
+
   def each_export(objs)
     noprefix = ($arch ||= nil and /^(sh|i\d86)/ !~ $arch)
     objs = objs.collect {|s| s.tr('/', '\\')}
     filetype = nil
-    IO.popen(%w"dumpbin -symbols -exports" + objs) do |f|
-      f.each do |l|
-        if (filetype = l[/^File Type: (.+)/, 1])..(/^\f/ =~ l)
-          case filetype
-          when /OBJECT/, /LIBRARY/
-            next if /^[[:xdigit:]]+ 0+ UNDEF / =~ l
-            next unless /External/ =~ l
-            next unless l.sub!(/.*?\s(\(\)\s+)?External\s+\|\s+/, '')
-            is_data = !$1
-            if noprefix or /^[@_]/ =~ l
-              next if /(?!^)@.*@/ =~ l || /@[[:xdigit:]]{16}$/ =~ l
-              l.sub!(/^[@_]/, '') if /@\d+$/ !~ l
-            elsif !l.sub!(/^(\S+) \([^@?\`\']*\)$/, '\1')
-              next
-            end
-          when /DLL/
-            next unless l.sub!(/^\s*\d+\s+[[:xdigit:]]+\s+[[:xdigit:]]+\s+/, '')
-          else
+    objdump(objs) do |l|
+      if (filetype = l[/^File Type: (.+)/, 1])..(/^\f/ =~ l)
+        case filetype
+        when /OBJECT/, /LIBRARY/
+          next if /^[[:xdigit:]]+ 0+ UNDEF / =~ l
+          next unless /External/ =~ l
+          next unless l.sub!(/.*?\s(\(\)\s+)?External\s+\|\s+/, '')
+          is_data = !$1
+          if noprefix or /^[@_]/ =~ l
+            next if /(?!^)@.*@/ =~ l || /@[[:xdigit:]]{16}$/ =~ l
+            l.sub!(/^[@_]/, '') if /@\d+$/ !~ l
+          elsif !l.sub!(/^(\S+) \([^@?\`\']*\)$/, '\1')
             next
           end
-          yield l.strip, is_data
+        when /DLL/
+          next unless l.sub!(/^\s*\d+\s+[[:xdigit:]]+\s+[[:xdigit:]]+\s+/, '')
+        else
+          next
         end
+        yield l.strip, is_data
       end
     end
     yield "strcasecmp", "msvcrt.stricmp"
@@ -118,9 +130,13 @@
     @@nm ||= RbConfig::CONFIG["NM"]
   end
 
+  def each_line(objs, &block)
+    IO.foreach("|#{self.class.nm} --extern --defined #{objs.join(' ')}", &block)
+  end
+
   def each_export(objs)
-    IO.popen([self.class.nm, "--extern", "--defined", *objs]) do |f|
-      f.each {|l| yield $1 if / [[:upper:]] _(.*)$/ =~ l}
+    objdump(objs) do |l|
+      yield $1 if / [[:upper:]] _(.*)$/ =~ l
     end
     yield "strcasecmp", "_stricmp"
     yield "strncasecmp", "_strnicmp"

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

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