REx bug??? /\x99/ compiles....

I

Ilya Zakharevich

One can easily check that /\99/ is equivalent to /\000(?:99)/. A
warning is emitted, but the interpretation is, IMO, OBVIOUSLY not one
intended by the user.

So the question is: is there any justification for it warning instead
of failing? And: is not it DESIRABLE to change this to a fatal error?

Thanks,
Ilya

P.S. Note that the failure mode is very different from /\gg/, which
is guessed to mean /gg/...
 
D

Dr.Ruud

Ilya Zakharevich schreef:
One can easily check that /\99/ is equivalent to /\000(?:99)/.

Nice catch. It's a pity that Deparse doesn't show it:

$ perl -MO=Deparse,x=7 -Mwarnings -e '/\89/'
Illegal octal digit '8' ignored at -e line 1.
Illegal octal digit '8' ignored at -e line 1.
use warnings;
/\89/;
-e syntax OK



With plenty of capture groups, \99 gets a different meaning:

$ perl -le '$r="(.)"x100; $_=")"x102; s/$r\99/:/; print'
:)
 
A

Anno Siegel

Ilya Zakharevich said:
One can easily check that /\99/ is equivalent to /\000(?:99)/. A
warning is emitted, but the interpretation is, IMO, OBVIOUSLY not one
intended by the user.

The warning "Illegal octal digit '9' ignored at..." is also incorrect.
The digit "9" is *not* ignored but taken as an indication that the
sequence of octal digits ends here and "9" is just another character
to match.

Another question is why the warning appears twice. The second "9"
is not the reason (it is just text), as can be seen from

perl -wle '"\00789" =~ /\789/ and print "match"'
Illegal octal digit '8' ignored at -e line 1.
Illegal octal digit '8' ignored at -e line 1.
match

That's pretty messy.
So the question is: is there any justification for it warning instead
of failing? And: is not it DESIRABLE to change this to a fatal error?

Apart from the standard objection that it may break old code it don't
see a reason why it shouldn't fail.

Anno
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was NOT [per weedlist] sent to
Dr.Ruud
With plenty of capture groups, \99 gets a different meaning:
$ perl -le '$r="(.)"x100; $_=")"x102; s/$r\99/:/; print'
:)

Hmm... And how would one enter octals if one has 377 groups? Well,
one could enter \566 instead of \166:
perl -Mre=debug -wle "/\566/"
Freeing REx: `","'
Compiling REx `\566'
size 3 Got 28 bytes for offset annotations.
first at 1
1: EXACT <v>(3)
3: END(0)
anchored `v' at 0 (checking anchored isall) minlen 1
Offsets: [3]
1[3] 0[0] 5[0]
Use of uninitialized value in pattern match (m//) at -e line 1.
Freeing REx: `"\\566"'

but this is hardly a beautiful solution...

Yours,
Ilya
 
I

Ilya Zakharevich

[A complimentary Cc of this posting was sent to
Anno Siegel
Another question is why the warning appears twice.

This is easy. There are two "practically identical" passes over a REx
during compile; one to gather "global" information, another to
actually emit the tree; done by the same code (with one bit of state
changed). It would take too much effort to separate stuff where a
warning makes sense during one pass only from those which would be
triggered on both.

Hope this helps,
Ilya
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,181
Messages
2,570,970
Members
47,537
Latest member
BellCorone

Latest Threads

Top