Re: mkmf.rb

From: Charles Mills <cmills@...>
Date: 2004-05-25 00:47:08 UTC
List: ruby-core #2939
On May 20, 2004, at 12:42 AM, nobu.nokada@softhome.net wrote:

> 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?

### Using irb I get this:
irb(main):002:0> /^-D([^=]+)(=(.*))?/ =~ "-DA=2"
=> 0
irb(main):003:0> $1
=> "A"
irb(main):004:0> $2
=> "=2"
irb(main):005:0> $3
=> "2"
irb(main):006:0> "#$1 #{$3 || 1}\n"
=> "A 2\n"
irb(main):007:0> "#$1 #{$2 || 1}\n"
=> "A =2\n"
###
So in the C header that is created by create_header() the line
     hfile.print "#define #$1 #{$2 || 1}\n"
will produce
#define A =2
when it should be
#define A 2
right?  That is why I thought it should be changed to
     hfile.print "#define #$1 #{$3 || 1}\n"
I could be missing something though, it wouldn't be a first.
-Charlie


In This Thread

Prev Next