From: nobu.nakada@... Date: 2001-06-06T22:25:50+09:00 Subject: [ruby-dev:13485] Re: ext/extmk.rb.in なかだです。 At Wed, 6 Jun 2001 08:00:33 +0900, Nobuyoshi-Nakada wrote: > これをちゃんと解決するには、自分でコマンドラインを解析してパ > イプラインを作るとか、大事になりそうなのでとりあえず egrep_cpp > の方を変えてみました。 $DEBUG のときと、ログの出力がヘンでした。 Index: ext/extmk.rb.in =================================================================== RCS file: /cvs/ruby/src/ruby/ext/extmk.rb.in,v retrieving revision 1.47 diff -u -2 -p -r1.47 extmk.rb.in --- ext/extmk.rb.in 2001/06/05 04:54:52 1.47 +++ ext/extmk.rb.in 2001/06/06 10:17:18 @@ -90,4 +90,16 @@ def xsystem command end +def xopen command, &block + if $DEBUG + puts command+" |" + return open("|"+command, "r", &block) + end + $stderr.reopen($log) + $log.puts command+" |" + r = open("|"+command, "r", &block) + $stderr.reopen($orgerr) + return r +end + def try_link0(src, opt="") cfile = open("conftest.c", "w") @@ -132,6 +144,15 @@ def egrep_cpp(pat, src, opt="") cfile.print src cfile.close + if Regexp === pat + src = pat.source + else + pat = Regexp.new(src = pat) + end begin - xsystem(format(CPP+"|egrep #{pat}", $CFLAGS, $CPPFLAGS, opt)) + xopen(format(CPP, $CFLAGS, $CPPFLAGS, opt)) do |f| + ($DEBUG ? $stdout : $log).puts " egrep #{src}" + f.grep(pat) {return true} + end + false ensure rm_f "conftest*" Index: ext/etc/extconf.rb =================================================================== RCS file: /cvs/ruby/src/ruby/ext/etc/extconf.rb,v retrieving revision 1.3 diff -u -2 -p -r1.3 extconf.rb --- ext/etc/extconf.rb 2001/06/05 04:42:46 1.3 +++ ext/etc/extconf.rb 2001/06/06 09:49:06 @@ -12,10 +12,10 @@ b = have_func("getpwent") c = have_func("getgrent") if a or b or c - etc_grep_header("pw_gecos") + etc_grep_header("pw_gecos") unless /mingw/ === RUBY_PLATFORM etc_grep_header("pw_change") etc_grep_header("pw_quota") etc_grep_header("pw_age") etc_grep_header("pw_class") - etc_grep_header("pw_comment") unless /cygwin/ === RUBY_PLATFORM + etc_grep_header("pw_comment") unless /cygwin|mingw/ === RUBY_PLATFORM etc_grep_header("pw_expire") create_makefile("etc") Index: lib/mkmf.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/mkmf.rb,v retrieving revision 1.54 diff -u -2 -p -r1.54 mkmf.rb --- lib/mkmf.rb 2001/06/05 04:54:52 1.54 +++ lib/mkmf.rb 2001/06/06 10:16:28 @@ -71,4 +71,16 @@ def xsystem command end +def xopen command, &block + if $DEBUG + puts command+" |" + return open("|"+command, "r", &block) + end + $stderr.reopen($log) + $log.puts command+" |" + r = open("|"+command, "r", &block) + $stderr.reopen($orgerr) + return r +end + def try_link0(src, opt="") cfile = open("conftest.c", "w") @@ -113,6 +125,15 @@ def egrep_cpp(pat, src, opt="") cfile.print src cfile.close + if Regexp === pat + src = pat.source + else + pat = Regexp.new(src = pat) + end begin - xsystem(format(CPP+"|egrep #{pat}", $CPPFLAGS, $CFLAGS, opt)) + xopen(format(CPP, $CFLAGS, $CPPFLAGS, opt)) do |f| + ($DEBUG ? $stdout : $log).puts " egrep #{src}" + f.grep(pat) {return true} + end + false ensure rm_f "conftest*" -- --- 僕の前にBugはない。 --- 僕の後ろにBugはできる。 中田 伸悦