From: nobu.nokada@... Date: 2004-05-20T16:42:30+09:00 Subject: Re: mkmf.rb Hi, At Thu, 20 May 2004 14:58:58 +0900, Charles Mills wrote in [ruby-core:02911]: > - check_sizeof() crashes my extconf.rb script. > $ echo 'check_sizeof("short")' | ruby -r mkmf - > checking size of short... 2 > /usr/local/lib/ruby/1.8/mkmf.rb:570:in `check_sizeof': undefined local > variable or method `r' for main:Object (NameError) > from -:1 Matz has fixed it this noon. > Other problems with check_sizeof(): > the line: > $defs.push(format("-DSIZEOF_%s", type.upcase)) > should probably be: > $defs.push(format("-DSIZEOF_%s=%i", type.upcase, size)) > or (taken from latest source) > $defs.push(format("-DSIZEOF_%s=%i", type.upcase.tr_s("^A-Z0-9_", "_"), > size)) Exactly, thank you. > This leads to a problem with create_header() > Looks like the regexp on line 619 > /^-D(.*)(?:=(.*))?/ > used to parse $defs should be > /^-D([^=]+)(=(.*))?/ > and line 620 changed to: > hfile.print "#define #$1 #{$3 || 1}\n" > from > hfile.print "#define #$1 #{$2 || 1}\n" I think /^-D([^=]+)(?:=(.*))?/ is enough, isn't it? Index: lib/mkmf.rb =================================================================== RCS file: /cvs/ruby/src/ruby/lib/mkmf.rb,v retrieving revision 1.189 diff -u -2 -p -r1.189 mkmf.rb --- lib/mkmf.rb 20 May 2004 04:34:12 -0000 1.189 +++ lib/mkmf.rb 20 May 2004 07:39:26 -0000 @@ -600,5 +600,5 @@ def check_sizeof(type, header = nil, &b) Logging::message "check_sizeof: %s--------------------\n", m if size = try_constant(expr, header, &b) - $defs.push(format("-DSIZEOF_%s", type.upcase.tr_s("^A-Z0-9_", "_"))) + $defs.push(format("-DSIZEOF_%s=%d", type.upcase.tr_s("^A-Z0-9_", "_"), size)) end message(a = size ? "#{size}\n" : "failed\n") @@ -653,5 +653,5 @@ def create_header(header = "extconf.h") for line in $defs case line - when /^-D(.*)(?:=(.*))?/ + when /^-D([^=]+)(?:=(.*))?/ hfile.print "#define #$1 #{$2 || 1}\n" when /^-U(.*)/ -- Nobu Nakada