From dd9163d468fc2997f2ef69f05d620f2649d23cbd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 31 Jul 2025 16:45:09 +0900 Subject: Win: Strip CRs from `cpp` and `nm` output The combination of mingw tools and cygin/msys2 ruby leaves CRs. --- template/fake.rb.in | 1 + win32/mkexports.rb | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/template/fake.rb.in b/template/fake.rb.in index 5e52d95594..e7a72ac2e5 100644 --- a/template/fake.rb.in +++ b/template/fake.rb.in @@ -9,6 +9,7 @@ while /\A(\w+)=(.*)/ =~ ARGV[0] end if inc = arg['i'] src = inc == '-' ? STDIN.read : File.read(inc) + src.tr!("\r", " ") src.gsub!(/^#.*\n/, '') else src = "" diff --git a/win32/mkexports.rb b/win32/mkexports.rb index 389b49def8..97939cdd09 100755 --- a/win32/mkexports.rb +++ b/win32/mkexports.rb @@ -146,7 +146,9 @@ class Exports::Cygwin < Exports end def each_line(objs, &block) - IO.foreach("|#{self.class.nm} --extern-only --defined-only #{objs.join(' ')}", &block) + IO.popen(%W[#{self.class.nm} --extern-only --defined-only] + objs) do |f| + f.each(&block) + end end def each_export(objs) @@ -155,7 +157,7 @@ class Exports::Cygwin < Exports re = /\s(?:(T)|[[:upper:]])\s#{symprefix}((?!#{PrivateNames}).*)$/ objdump(objs) do |l| next if /@.*@/ =~ l - yield $2, !$1 if re =~ l + yield $2.strip, !$1 if re =~ l end end end -- cgit v1.2.3