develooper Front page | perl.perl5.porters | Postings from March 2007

Re: [PATCH] Tweaks so that miniperl.exe doesnt croak while building perl.exe

Thread Previous | Thread Next
From:
demerphq
Date:
March 8, 2007 08:22
Subject:
Re: [PATCH] Tweaks so that miniperl.exe doesnt croak while building perl.exe
Message ID:
9b18b3110703080822u43ad5517w1b25b88ef6263614@mail.gmail.com
On 3/8/07, Craig Berry <craig.a.berry@gmail.com> wrote:
> On 3/7/07, demerphq <demerphq@gmail.com> wrote:
> > The change required to lib/ExtUtils/Liblist/Kid.pm fixes a bug in it
> > that was detected by the require_tie_mod() failures, but was not
> > actually related to it. The cause was that m-[\w$\-]- matches the same
> > as /[\w$-]/ and not /[\w$\-]/ as I guess the author expected.
>
> -      if (($locspec,$type) = $lib =~ m-^([\w$\-]+)(/\w+)?- and
> $locspec =~ /perl/i) {
> +      if (($locspec,$type) = $lib =~ m!^([\w$\-]+)(/\w+)?! and
> $locspec =~ /perl/i) {
>
>
> The code you changed in  _vms_ext() has been as it was for many years
> (like 9, 10, maybe more) and has never caused any trouble I'm aware
> of, though I agree it does not seem to do what it was intended to.
> After your change it now always generates the following warning:
>
> Use of uninitialized value $\ in regexp compilation at
> ../../../../lib/ExtUtils/Liblist/Kid.pm line 392.
>
> easily reproducible like so since $\ is undef by default:
>
> $ perl -we "print $1 if 'foo$bar-baz' =~ m!([\w$\-]+)!;"
> Use of uninitialized value $\ in regexp compilation at -e line 1.
> foo
>
> Replacing "-" with "!" as the match delimiter changed the
> interpretation of C<$\-> so that the backslash no longer escapes the
> minus sign but now sidles up to the dollar sign to function as the
> special variable C<$\>.  Whereas before we were inadvertently getting
> the special variable C<$-> interpolated, we are now inadvertently
> getting the special variable C<$\> interpolated.  The default value of
> C<$-> is zero, so there was no uninitialized value warning the old
> way, but C<$\> defaults to undef and causes the warning.  You can
> confirm all this by running one-liners under -Dr and seeing what regex
> you're really getting.

Yes I know. This is the reason it was changed. An unrelated bug made
accessing $- under miniperl a fatal error. (Long story properly fixed
by 30517 and 30518). Accordingly I tried to divine what was intended
here, and decided that maybe there was a reason to use $\ on VMS. I
should have called your attention to the change as it /was/
speculative. Sorry it slipped my mind.

> I'm pretty sure the original intention for the character class was to
> match word characters, dollar signs and minus signs, not word
> characters, a special variable, and minus signs.  The clue is that
> dollar signs appear quite frequently in system-supplied library names
> on VMS, and that is what this bit of code is working with.

Right. In hindsight this should have been obvious. Sigh.

> I think all we need is to escape the dollar sign and use a match
> delimiter that doesn't appear in the regex:
>
> $ perl  -we "print qq/$1,$2\n/ if 'foo$bar-baz/share' =~ m|^([\w\$-]+)(/\w+)?|;"
> foo$bar-baz,/share

Like '!'

:-)

> I will test this in Kid.pm and see what else breaks as a result of
> fixing it :-(.

Sorry about that. :-(

Cheers,
Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About