Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.94k stars 554 forks source link

Regex: (((??{1 + $^N}))) behaves differently in 5.10.0 than in blead #9387

Closed p5pRT closed 15 years ago

p5pRT commented 16 years ago

Migrated from rt.perl.org#56194 (status was 'resolved')

Searchable as RT56194$

p5pRT commented 16 years ago

From p5p@perl.wizbit.be

While testing [perl #27603] to see if the warning is gone I noticed this​:

perl-5.10.0 -wle 'if (123 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' match

perl-blead -wle 'if (123 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' no match

And​:

perl-5.10.0 -wle 'if (122 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' no match

perl-blead -wle 'if (122 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' match

Is this change of behaviour intended?

Kind regards\,

Bram

p5pRT commented 16 years ago

From p5p@spam.wizbit.be

On Sat Jun 21 11​:03​:51 2008\, p5p@​perl.wizbit.be wrote​:

While testing [perl #27603] to see if the warning is gone I noticed this​:

perl-5.10.0 -wle 'if (123 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' match

perl-blead -wle 'if (123 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' no match

And​:

perl-5.10.0 -wle 'if (122 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' no match

perl-blead -wle 'if (122 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' match

Is this change of behaviour intended?

If I revert patch 32857 then it behaves in the same way as 5.10.0.

http​://public.activestate.com/cgi-bin/perlbrowse/p/32857

Kind regards\,

Bram

p5pRT commented 16 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 15 years ago

From p5p@spam.wizbit.be

On Sat Jun 21 11​:03​:51 2008\, p5p@​perl.wizbit.be wrote​:

While testing [perl #27603] to see if the warning is gone I noticed this​:

perl-5.10.0 -wle 'if (123 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' match

perl-blead -wle 'if (123 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' no match

And​:

perl-5.10.0 -wle 'if (122 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' no match

perl-blead -wle 'if (122 =~ /^(\d)(((??{1 + $^N})))+$/) { print
"match"; } else { print "no match"; }' match

PL_reglastparen and PL_reglastcloseparen contains a pointer are set to & rex->lastparen and & rex->lastcloseparen. In case END rex is modifie but PL_reglastparen and PL_reglastcloseparen is not. Some part of the codes access PL_reglastparen while other parts use rex-

lastparen.

The attached patch corrects this and adds 3 assertions.

I'm currently unable to proof (with a test case) that the code in case EVAL_ab is really nessesary... Logically speaking it is nessesary but I do not know if it can cause test failures.

Also in the patch are missing regressions between 5.8 -> 5.10 and 5.10 -

5.11. (and a test script that contains these regressions)

The script outputs the following failures​: (stripped to show only the not ok)

$ perl-5.8.9 rt-56194.pl (same for perl-5.8.8) not ok 23 - ctl_n 8 # Failed test 'ctl_n 8' # at rt-56194.pl line 62. # got​: 'undef undef undef' # expected​: 'bla blubb undef' not ok 24 - plus 8 # Failed test 'plus 8' # at rt-56194.pl line 63. # got​: 'undef undef undef' # expected​: 'a b undef' not ok 73 - match 9 # Failed test 'match 9' # at rt-56194.pl line 192. not ok 74 - ctl_n 9 # Failed test 'ctl_n 9' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 abc' not ok 75 - plus 9 # Failed test 'plus 9' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 abc' not ok 76 - str 9 # Failed test 'str 9' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = abc\, $2 = undef\, $3 = undef\, $4 = undef\, $5 = undef'

$ perl-5.10.0 rt-56194.pl not ok 2 - ctl_n 1 # Failed test 'ctl_n 1' # at rt-56194.pl line 62. # got​: 'bla undef bla' # expected​: 'bla blubb bla' not ok 3 - plus 1 # Failed test 'plus 1' # at rt-56194.pl line 63. # got​: 'a undef a' # expected​: 'a b a' not ok 5 - ctl_n 2 # Failed test 'ctl_n 2' # at rt-56194.pl line 62. # got​: 'bla undef \\\\' # expected​: 'bla blubb \\\\' not ok 6 - plus 2 # Failed test 'plus 2' # at rt-56194.pl line 63. # got​: 'a undef a' # expected​: 'a b a' not ok 8 - ctl_n 3 # Failed test 'ctl_n 3' # at rt-56194.pl line 62. # got​: 'bla undef bla' # expected​: 'bla blubb bla' not ok 9 - plus 3 # Failed test 'plus 3' # at rt-56194.pl line 63. # got​: 'a undef a' # expected​: 'a b a' not ok 11 - ctl_n 4 # Failed test 'ctl_n 4' # at rt-56194.pl line 62. # got​: 'bla undef bla' # expected​: 'bla blubb bla' not ok 12 - plus 4 # Failed test 'plus 4' # at rt-56194.pl line 63. # got​: 'a undef a' # expected​: 'a b a' not ok 17 - ctl_n 6 # Failed test 'ctl_n 6' # at rt-56194.pl line 62. # got​: 'bla undef bla' # expected​: 'bla blubb bla' not ok 18 - plus 6 # Failed test 'plus 6' # at rt-56194.pl line 63. # got​: 'a undef a' # expected​: 'a b a' not ok 20 - ctl_n 7 # Failed test 'ctl_n 7' # at rt-56194.pl line 62. # got​: 'bla undef bla' # expected​: 'bla blubb bla' not ok 21 - plus 7 # Failed test 'plus 7' # at rt-56194.pl line 63. # got​: 'a undef a' # expected​: 'a b a' not ok 23 - ctl_n 8 # Failed test 'ctl_n 8' # at rt-56194.pl line 62. # got​: 'undef undef undef' # expected​: 'bla blubb undef' not ok 24 - plus 8 # Failed test 'plus 8' # at rt-56194.pl line 63. # got​: 'undef undef undef' # expected​: 'a b undef' not ok 26 - ctl_n 9 # Failed test 'ctl_n 9' # at rt-56194.pl line 62. # got​: 'bla undef bla' # expected​: 'bla blubb bla' not ok 27 - plus 9 # Failed test 'plus 9' # at rt-56194.pl line 63. # got​: 'a undef a' # expected​: 'a b a' not ok 29 - ctl_n 10 # Failed test 'ctl_n 10' # at rt-56194.pl line 62. # got​: 'undef undef \\\\' # expected​: 'bla blubb \\\\' not ok 30 - plus 10 # Failed test 'plus 10' # at rt-56194.pl line 63. # got​: 'undef undef \\\\' # expected​: 'a b \\\\' not ok 32 - ctl_n 11 # Failed test 'ctl_n 11' # at rt-56194.pl line 62. # got​: 'undef undef \\\\' # expected​: 'bla blubb \\\\' not ok 33 - plus 11 # Failed test 'plus 11' # at rt-56194.pl line 63. # got​: 'undef undef \\\\' # expected​: 'a b \\\\' not ok 35 - ctl_n 12 # Failed test 'ctl_n 12' # at rt-56194.pl line 62. # got​: 'undef undef \\\\' # expected​: 'bla blubb \\\\' not ok 36 - plus 12 # Failed test 'plus 12' # at rt-56194.pl line 63. # got​: 'undef undef \\\\' # expected​: 'a b \\\\' not ok 38 - ctl_n 13 # Failed test 'ctl_n 13' # at rt-56194.pl line 62. # got​: 'undef undef undef' # expected​: 'bla blubb undef' not ok 39 - plus 13 # Failed test 'plus 13' # at rt-56194.pl line 63. # got​: 'undef undef undef' # expected​: 'a b undef' not ok 73 - match 9 # Failed test 'match 9' # at rt-56194.pl line 192. not ok 74 - ctl_n 9 # Failed test 'ctl_n 9' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 abc' not ok 75 - plus 9 # Failed test 'plus 9' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 abc' not ok 76 - str 9 # Failed test 'str 9' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = abc\, $2 = undef\, $3 = undef\, $4 = undef\, $5 = undef' not ok 77 - match 10 # Failed test 'match 10' # at rt-56194.pl line 192. not ok 78 - ctl_n 10 # Failed test 'ctl_n 10' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 abc' not ok 79 - plus 10 # Failed test 'plus 10' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 b' not ok 80 - str 10 # Failed test 'str 10' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = abc\, $2 = b\, $3 = undef\, $4 = undef\, $5 = undef' not ok 93 # Failed test at rt-56194.pl line 217. not ok 94 # Failed test at rt-56194.pl line 224. # got​: '' # expected​: '1 2 undef' not ok 95 # Failed test at rt-56194.pl line 225. # got​: '' # expected​: '1 2 undef' not ok 96 # Failed test at rt-56194.pl line 226. # got​: '' # expected​: '$1 = undef\, $2 = undef\, $3 = undef\, $4 = undef\, $5 = undef\, $^R = undef'

$ perl-maint-5.10 rt-56194.pl not ok 17 - ctl_n 6 # Failed test 'ctl_n 6' # at rt-56194.pl line 62. # got​: 'undef blubb bla' # expected​: 'bla blubb bla' not ok 18 - plus 6 # Failed test 'plus 6' # at rt-56194.pl line 63. # got​: 'undef b a' # expected​: 'a b a' not ok 20 - ctl_n 7 # Failed test 'ctl_n 7' # at rt-56194.pl line 62. # got​: 'undef blubb bla' # expected​: 'bla blubb bla' not ok 21 - plus 7 # Failed test 'plus 7' # at rt-56194.pl line 63. # got​: 'undef b a' # expected​: 'a b a' not ok 26 - ctl_n 9 # Failed test 'ctl_n 9' # at rt-56194.pl line 62. # got​: 'undef blubb bla' # expected​: 'bla blubb bla' not ok 27 - plus 9 # Failed test 'plus 9' # at rt-56194.pl line 63. # got​: 'undef b a' # expected​: 'a b a' not ok 29 - ctl_n 10 # Failed test 'ctl_n 10' # at rt-56194.pl line 62. # got​: 'bla blubb undef' # expected​: 'bla blubb \\\\' not ok 30 - plus 10 # Failed test 'plus 10' # at rt-56194.pl line 63. # got​: 'a b undef' # expected​: 'a b \\\\' not ok 32 - ctl_n 11 # Failed test 'ctl_n 11' # at rt-56194.pl line 62. # got​: 'bla blubb undef' # expected​: 'bla blubb \\\\' not ok 33 - plus 11 # Failed test 'plus 11' # at rt-56194.pl line 63. # got​: 'a b undef' # expected​: 'a b \\\\' not ok 35 - ctl_n 12 # Failed test 'ctl_n 12' # at rt-56194.pl line 62. # got​: 'bla blubb undef' # expected​: 'bla blubb \\\\' not ok 36 - plus 12 # Failed test 'plus 12' # at rt-56194.pl line 63. # got​: 'a b undef' # expected​: 'a b \\\\' not ok 40 # Failed test at rt-56194.pl line 77. not ok 41 - match 1 # Failed test 'match 1' # at rt-56194.pl line 192. not ok 42 - ctl_n 1 # Failed test 'ctl_n 1' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 43 - plus 1 # Failed test 'plus 1' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 44 - str 1 # Failed test 'str 1' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 45 - match 2 # Failed test 'match 2' # at rt-56194.pl line 192. not ok 46 - ctl_n 2 # Failed test 'ctl_n 2' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 47 - plus 2 # Failed test 'plus 2' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 48 - str 2 # Failed test 'str 2' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 49 - match 3 # Failed test 'match 3' # at rt-56194.pl line 192. not ok 50 - ctl_n 3 # Failed test 'ctl_n 3' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 51 - plus 3 # Failed test 'plus 3' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 52 - str 3 # Failed test 'str 3' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 53 - match 4 # Failed test 'match 4' # at rt-56194.pl line 192. not ok 54 - ctl_n 4 # Failed test 'ctl_n 4' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 55 - plus 4 # Failed test 'plus 4' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 56 - str 4 # Failed test 'str 4' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 57 - match 5 # Failed test 'match 5' # at rt-56194.pl line 192. not ok 58 - ctl_n 5 # Failed test 'ctl_n 5' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 59 - plus 5 # Failed test 'plus 5' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 60 - str 5 # Failed test 'str 5' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 61 - match 6 # Failed test 'match 6' # at rt-56194.pl line 192. not ok 62 - ctl_n 6 # Failed test 'ctl_n 6' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 abc' not ok 63 - plus 6 # Failed test 'plus 6' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 b' not ok 64 - str 6 # Failed test 'str 6' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 123\, $2 = 1\, $3 = 3\, $4 = abc\, $5 = b' not ok 65 - match 7 # Failed test 'match 7' # at rt-56194.pl line 192. not ok 66 - ctl_n 7 # Failed test 'ctl_n 7' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 123abc3' not ok 67 - plus 7 # Failed test 'plus 7' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 b' not ok 68 - str 7 # Failed test 'str 7' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 123abc3\, $2 = 1\, $3 = 3\, $4 = abc\, $5 = b' not ok 69 - match 8 # Failed test 'match 8' # at rt-56194.pl line 192. not ok 70 - ctl_n 8 # Failed test 'ctl_n 8' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 123abc3' not ok 71 - plus 8 # Failed test 'plus 8' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 b' not ok 72 - str 8 # Failed test 'str 8' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 123abc3\, $2 = 1\, $3 = 3\, $4 = abc\, $5 = b' not ok 73 - match 9 # Failed test 'match 9' # at rt-56194.pl line 192. not ok 74 - ctl_n 9 # Failed test 'ctl_n 9' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 abc' not ok 75 - plus 9 # Failed test 'plus 9' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 abc' not ok 76 - str 9 # Failed test 'str 9' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = abc\, $2 = undef\, $3 = undef\, $4 = undef\, $5 = undef' not ok 77 - match 10 # Failed test 'match 10' # at rt-56194.pl line 192. not ok 78 - ctl_n 10 # Failed test 'ctl_n 10' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 abc' not ok 79 - plus 10 # Failed test 'plus 10' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 b' not ok 80 - str 10 # Failed test 'str 10' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = abc\, $2 = b\, $3 = undef\, $4 = undef\, $5 = undef' not ok 81 - match 11 # Failed test 'match 11' # at rt-56194.pl line 192. not ok 82 - ctl_n 11 # Failed test 'ctl_n 11' # at rt-56194.pl line 198. # got​: '' # expected​: '1234 123 12 1 2 3 1234' not ok 83 - plus 11 # Failed test 'plus 11' # at rt-56194.pl line 199. # got​: '' # expected​: '1234 123 12 1 2 3 4' not ok 84 - str 11 # Failed test 'str 11' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1234\, $2 = 1\, $3 = 2\, $4 = 3\, $5 = 4' not ok 85 - match 12 # Failed test 'match 12' # at rt-56194.pl line 192. not ok 86 - ctl_n 12 # Failed test 'ctl_n 12' # at rt-56194.pl line 198. # got​: '' # expected​: '1234556 123455 12345 1234 123 12 1 2 3 4 4 5 56' not ok 87 - plus 12 # Failed test 'plus 12' # at rt-56194.pl line 199. # got​: '' # expected​: '1234556 123455 12345 1234 123 12 1 2 3 4 4 5 5' not ok 88 - str 12 # Failed test 'str 12' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 2\, $3 = 3\, $4 = 4\, $5 = 56' not ok 89 - match 13 # Failed test 'match 13' # at rt-56194.pl line 192. not ok 90 - ctl_n 13 # Failed test 'ctl_n 13' # at rt-56194.pl line 198. # got​: '' # expected​: '12345562 1234556 123455 12345 1234 123 12 1 2 3 4 4 5 62' not ok 91 - plus 13 # Failed test 'plus 13' # at rt-56194.pl line 199. # got​: '' # expected​: '12345562 1234556 123455 12345 1234 123 12 1 2 3 4 4 5 2' not ok 92 - str 13 # Failed test 'str 13' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 2\, $3 = 3\, $4 = 4\, $5 = 5' not ok 93 # Failed test at rt-56194.pl line 217. not ok 94 # Failed test at rt-56194.pl line 224. # got​: '' # expected​: '1 2 undef' not ok 95 # Failed test at rt-56194.pl line 225. # got​: '' # expected​: '1 2 undef' not ok 96 # Failed test at rt-56194.pl line 226. # got​: '' # expected​: '$1 = undef\, $2 = undef\, $3 = undef\, $4 = undef\, $5 = undef\, $^R = undef'

$ perl-blead rt-56194.pl not ok 17 - ctl_n 6 # Failed test 'ctl_n 6' # at rt-56194.pl line 62. # got​: 'undef blubb bla' # expected​: 'bla blubb bla' not ok 18 - plus 6 # Failed test 'plus 6' # at rt-56194.pl line 63. # got​: 'undef b a' # expected​: 'a b a' not ok 20 - ctl_n 7 # Failed test 'ctl_n 7' # at rt-56194.pl line 62. # got​: 'undef blubb bla' # expected​: 'bla blubb bla' not ok 21 - plus 7 # Failed test 'plus 7' # at rt-56194.pl line 63. # got​: 'undef b a' # expected​: 'a b a' not ok 26 - ctl_n 9 # Failed test 'ctl_n 9' # at rt-56194.pl line 62. # got​: 'undef blubb bla' # expected​: 'bla blubb bla' not ok 27 - plus 9 # Failed test 'plus 9' # at rt-56194.pl line 63. # got​: 'undef b a' # expected​: 'a b a' not ok 29 - ctl_n 10 # Failed test 'ctl_n 10' # at rt-56194.pl line 62. # got​: 'bla blubb undef' # expected​: 'bla blubb \\\\' not ok 30 - plus 10 # Failed test 'plus 10' # at rt-56194.pl line 63. # got​: 'a b undef' # expected​: 'a b \\\\' not ok 32 - ctl_n 11 # Failed test 'ctl_n 11' # at rt-56194.pl line 62. # got​: 'bla blubb undef' # expected​: 'bla blubb \\\\' not ok 33 - plus 11 # Failed test 'plus 11' # at rt-56194.pl line 63. # got​: 'a b undef' # expected​: 'a b \\\\' not ok 35 - ctl_n 12 # Failed test 'ctl_n 12' # at rt-56194.pl line 62. # got​: 'bla blubb undef' # expected​: 'bla blubb \\\\' not ok 36 - plus 12 # Failed test 'plus 12' # at rt-56194.pl line 63. # got​: 'a b undef' # expected​: 'a b \\\\' not ok 40 # Failed test at rt-56194.pl line 77. not ok 41 - match 1 # Failed test 'match 1' # at rt-56194.pl line 192. not ok 42 - ctl_n 1 # Failed test 'ctl_n 1' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 43 - plus 1 # Failed test 'plus 1' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 44 - str 1 # Failed test 'str 1' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 45 - match 2 # Failed test 'match 2' # at rt-56194.pl line 192. not ok 46 - ctl_n 2 # Failed test 'ctl_n 2' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 47 - plus 2 # Failed test 'plus 2' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 48 - str 2 # Failed test 'str 2' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 49 - match 3 # Failed test 'match 3' # at rt-56194.pl line 192. not ok 50 - ctl_n 3 # Failed test 'ctl_n 3' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 51 - plus 3 # Failed test 'plus 3' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 52 - str 3 # Failed test 'str 3' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 53 - match 4 # Failed test 'match 4' # at rt-56194.pl line 192. not ok 54 - ctl_n 4 # Failed test 'ctl_n 4' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 55 - plus 4 # Failed test 'plus 4' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 56 - str 4 # Failed test 'str 4' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 57 - match 5 # Failed test 'match 5' # at rt-56194.pl line 192. not ok 58 - ctl_n 5 # Failed test 'ctl_n 5' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 3' not ok 59 - plus 5 # Failed test 'plus 5' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 3' not ok 60 - str 5 # Failed test 'str 5' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 3\, $3 = undef\, $4 = undef\, $5 = undef' not ok 61 - match 6 # Failed test 'match 6' # at rt-56194.pl line 192. not ok 62 - ctl_n 6 # Failed test 'ctl_n 6' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 abc' not ok 63 - plus 6 # Failed test 'plus 6' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 b' not ok 64 - str 6 # Failed test 'str 6' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 123\, $2 = 1\, $3 = 3\, $4 = abc\, $5 = b' not ok 65 - match 7 # Failed test 'match 7' # at rt-56194.pl line 192. not ok 66 - ctl_n 7 # Failed test 'ctl_n 7' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 3 123abc3' not ok 67 - plus 7 # Failed test 'plus 7' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 3 b' not ok 68 - str 7 # Failed test 'str 7' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 123abc3\, $2 = 1\, $3 = 3\, $4 = abc\, $5 = b' not ok 69 - match 8 # Failed test 'match 8' # at rt-56194.pl line 192. not ok 70 - ctl_n 8 # Failed test 'ctl_n 8' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 123abc3' not ok 71 - plus 8 # Failed test 'plus 8' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 b' not ok 72 - str 8 # Failed test 'str 8' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 123abc3\, $2 = 1\, $3 = 3\, $4 = abc\, $5 = b' not ok 73 - match 9 # Failed test 'match 9' # at rt-56194.pl line 192. not ok 74 - ctl_n 9 # Failed test 'ctl_n 9' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 abc' not ok 75 - plus 9 # Failed test 'plus 9' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 abc' not ok 76 - str 9 # Failed test 'str 9' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = abc\, $2 = undef\, $3 = undef\, $4 = undef\, $5 = undef' not ok 77 - match 10 # Failed test 'match 10' # at rt-56194.pl line 192. not ok 78 - ctl_n 10 # Failed test 'ctl_n 10' # at rt-56194.pl line 198. # got​: '' # expected​: '1 2 abc' not ok 79 - plus 10 # Failed test 'plus 10' # at rt-56194.pl line 199. # got​: '' # expected​: '1 2 b' not ok 80 - str 10 # Failed test 'str 10' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = abc\, $2 = b\, $3 = undef\, $4 = undef\, $5 = undef' not ok 81 - match 11 # Failed test 'match 11' # at rt-56194.pl line 192. not ok 82 - ctl_n 11 # Failed test 'ctl_n 11' # at rt-56194.pl line 198. # got​: '' # expected​: '1234 123 12 1 2 3 1234' not ok 83 - plus 11 # Failed test 'plus 11' # at rt-56194.pl line 199. # got​: '' # expected​: '1234 123 12 1 2 3 4' not ok 84 - str 11 # Failed test 'str 11' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1234\, $2 = 1\, $3 = 2\, $4 = 3\, $5 = 4' not ok 85 - match 12 # Failed test 'match 12' # at rt-56194.pl line 192. not ok 86 - ctl_n 12 # Failed test 'ctl_n 12' # at rt-56194.pl line 198. # got​: '' # expected​: '1234556 123455 12345 1234 123 12 1 2 3 4 4 5 56' not ok 87 - plus 12 # Failed test 'plus 12' # at rt-56194.pl line 199. # got​: '' # expected​: '1234556 123455 12345 1234 123 12 1 2 3 4 4 5 5' not ok 88 - str 12 # Failed test 'str 12' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 2\, $3 = 3\, $4 = 4\, $5 = 56' not ok 89 - match 13 # Failed test 'match 13' # at rt-56194.pl line 192. not ok 90 - ctl_n 13 # Failed test 'ctl_n 13' # at rt-56194.pl line 198. # got​: '' # expected​: '12345562 1234556 123455 12345 1234 123 12 1 2 3 4 4 5 62' not ok 91 - plus 13 # Failed test 'plus 13' # at rt-56194.pl line 199. # got​: '' # expected​: '12345562 1234556 123455 12345 1234 123 12 1 2 3 4 4 5 2' not ok 92 - str 13 # Failed test 'str 13' # at rt-56194.pl line 200. # got​: '' # expected​: '$1 = 1\, $2 = 2\, $3 = 3\, $4 = 4\, $5 = 5' not ok 93 # Failed test at rt-56194.pl line 217. not ok 94 # Failed test at rt-56194.pl line 224. # got​: '' # expected​: '1 2 undef' not ok 95 # Failed test at rt-56194.pl line 225. # got​: '' # expected​: '1 2 undef' not ok 96 # Failed test at rt-56194.pl line 226. # got​: '' # expected​: '$1 = undef\, $2 = undef\, $3 = undef\, $4 = undef\, $5 = undef\, $^R = undef'

$ patched-blead rt-56194.pl => all OK

The test script might contain some redundant tests but I feel it is better to include a regression test too much then one too little...

Kind regards\,

Bram

p5pRT commented 15 years ago

From p5p@spam.wizbit.be

rt-56194.patch ```diff diff -Naur old/regexec.c new/regexec.c --- old/regexec.c 2009-03-11 22:20:02.000000000 +0100 +++ new/regexec.c 2009-03-11 22:20:06.000000000 +0100 @@ -2841,6 +2841,11 @@ state_num = OP(scan); reenter_switch: + + assert(PL_reglastparen == &rex->lastparen); + assert(PL_reglastcloseparen == &rex->lastcloseparen); + assert(PL_regoffs == rex->offs); + switch (state_num) { case BOL: if (locinput == PL_bostr) @@ -3889,9 +3894,12 @@ regcpblow(ST.cp); cur_eval = ST.prev_eval; cur_curlyx = ST.prev_curlyx; - + + /* rex was changed so update the pointer in PL_reglastparen and PL_reglastcloseparen */ PL_reglastparen = &rex->lastparen; PL_reglastcloseparen = &rex->lastcloseparen; + /* also update PL_regoffs */ + PL_regoffs = rex->offs; /* XXXX This is too dramatic a measure... */ PL_reg_maxiter = 0; @@ -3907,6 +3915,7 @@ SETREX(rex_sv,ST.prev_rex); rex = (struct regexp *)SvANY(rex_sv); rexi = RXi_GET(rex); + /* rex was changed so update the pointer in PL_reglastparen and PL_reglastcloseparen */ PL_reglastparen = &rex->lastparen; PL_reglastcloseparen = &rex->lastcloseparen; @@ -4909,6 +4918,11 @@ cur_curlyx = cur_eval->u.eval.prev_curlyx; ReREFCNT_inc(rex_sv); st->u.eval.cp = regcppush(0); /* Save *all* the positions. */ + + /* rex was changed so update the pointer in PL_reglastparen and PL_reglastcloseparen */ + PL_reglastparen = &rex->lastparen; + PL_reglastcloseparen = &rex->lastcloseparen; + REGCP_SET(st->u.eval.lastcp); PL_reginput = locinput; diff -Naur old/t/op/pat.t new/t/op/pat.t --- old/t/op/pat.t 2009-03-11 22:20:25.000000000 +0100 +++ new/t/op/pat.t 2009-03-11 22:22:36.000000000 +0100 @@ -13,7 +13,7 @@ $| = 1; -my $EXPECTED_TESTS = 3965; # Update this when adding/deleting tests. +my $EXPECTED_TESTS = 4061; # Update this when adding/deleting tests. BEGIN { chdir 't' if -d 't'; @@ -4123,6 +4123,222 @@ ok $1 eq "A1"; ok $2 eq "B"; } + + + { + use re 'eval'; + local $Message = 'Test if $^N and $+ work in (?{{})'; + our @ctl_n = (); + our @plus = (); + our $nested_tags; + $nested_tags = qr{ + < + ((\w)+) + (?{ + push @ctl_n, (defined $^N ? $^N : "undef"); + push @plus, (defined $+ ? $+ : "undef"); + }) + > + (??{$nested_tags})* + + }x; + + + my $c = 0; + for my $test ( + [ 1, qr#^$nested_tags$#, "bla blubb bla", "a b a" ], + [ 1, qr#^($nested_tags)$#, "bla blubb ", "a b a" ], + [ 1, qr#^(|)$nested_tags$#, "bla blubb bla", "a b a" ], + [ 1, qr#^(?:|)$nested_tags$#, "bla blubb bla", "a b a" ], + [ 1, qr#^<(bl|bla)>$nested_tags<(/\1)>$#, "blubb /bla", "b /bla" ], + [ 1, qr#(??{"(|)"})$nested_tags$#, "bla blubb bla", "a b a" ], + [ 1, qr#^(??{"(bla|)"})$nested_tags$#, "bla blubb bla", "a b a" ], + [ 1, qr#^(??{"(|)"})(??{$nested_tags})$#, "bla blubb undef", "a b undef" ], + [ 1, qr#^(??{"(?:|)"})$nested_tags$#, "bla blubb bla", "a b a" ], + [ 1, qr#^((??{"(?:bla|)"}))((??{$nested_tags}))$#, "bla blubb ", "a b " ], + [ 1, qr#^((??{"(?!)?"}))((??{$nested_tags}))$#, "bla blubb ", "a b " ], + [ 1, qr#^((??{"(?:|<(/?bla)>)"}))((??{$nested_tags}))\1$#, "bla blubb ", "a b " ], + [ 0, qr#^((??{"(?!)"}))?((??{$nested_tags}))(?!)$#, "bla blubb undef", "a b undef" ], + + ) { + $c++; + @ctl_n = (); + @plus = (); + my $match = (("" =~ $test->[1]) ? 1 : 0); + push @ctl_n, (defined $^N ? $^N : "undef"); + push @plus, (defined $+ ? $+ : "undef"); + ok($test->[0] == $match, "match $c"); + if ($test->[0] != $match) { + # unset @ctl_n and @plus + @ctl_n = @plus = (); + } + iseq("@ctl_n", $test->[2], "ctl_n $c"); + iseq("@plus", $test->[3], "plus $c"); + } + } + + { + use re 'eval'; + local $BugId = '56194'; + + our $f; + local $f; + $f = sub { + defined $_[0] ? $_[0] : "undef"; + }; + + ok("123" =~ m/^(\d)(((??{1 + $^N})))+$/); + + our @ctl_n; + our @plus; + + my $re = qr#(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1}))*(?{$^N})#; + my $re2 = qr#(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1}))*(?{$^N})(|a(b)c|def)(??{"$^R"})#; + my $re3 = qr#(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1})){2}(?{$^N})(|a(b)c|def)(??{"$^R"})#; + our $re5; + local $re5 = qr#(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1})){2}(?{$^N})#; + my $re6 = qr#(??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1})#; + my $re7 = qr#(??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1})#; + my $re8 = qr/(\d+)/; + my $c = 0; + for my $test ( + [ + "1233", + qr#^(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1}))+(??{$^N})$#, + "1 2 3 3", + "1 2 3 3", + "\$1 = 1, \$2 = 3, \$3 = undef, \$4 = undef, \$5 = undef", + ], + [ + "1233", + qr#^(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1}))+(abc|def|)?(??{$+})$#, + "1 2 3 3", + "1 2 3 3", + "\$1 = 1, \$2 = 3, \$3 = undef, \$4 = undef, \$5 = undef", + ], + [ + "1233", + qr#^(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1}))+(|abc|def)?(??{$+})$#, + "1 2 3 3", + "1 2 3 3", + "\$1 = 1, \$2 = 3, \$3 = undef, \$4 = undef, \$5 = undef", + ], + [ + "1233", + qr#^(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1}))+(abc|def|)?(??{$^N})$#, + "1 2 3 3", + "1 2 3 3", + "\$1 = 1, \$2 = 3, \$3 = undef, \$4 = undef, \$5 = undef", + ], + [ + "1233", + qr#^(1)((??{ push @ctl_n, $f->($^N); push @plus, $f->($+); $^N + 1}))+(|abc|def)?(??{$^N})$#, + "1 2 3 3", + "1 2 3 3", + "\$1 = 1, \$2 = 3, \$3 = undef, \$4 = undef, \$5 = undef", + ], + [ + "123abc3", + qr#^($re)(|a(b)c|def)(??{$^R})$#, + "1 2 3 abc", + "1 2 3 b", + "\$1 = 123, \$2 = 1, \$3 = 3, \$4 = abc, \$5 = b", + ], + [ + "123abc3", + qr#^($re2)$#, + "1 2 3 123abc3", + "1 2 3 b", + "\$1 = 123abc3, \$2 = 1, \$3 = 3, \$4 = abc, \$5 = b", + ], + [ + "123abc3", + qr#^($re3)$#, + "1 2 123abc3", + "1 2 b", + "\$1 = 123abc3, \$2 = 1, \$3 = 3, \$4 = abc, \$5 = b", + ], + [ + "123abc3", + qr#^(??{$re5})(|abc|def)(??{"$^R"})$#, + "1 2 abc", + "1 2 abc", + "\$1 = abc, \$2 = undef, \$3 = undef, \$4 = undef, \$5 = undef", + ], + [ + "123abc3", + qr#^(??{$re5})(|a(b)c|def)(??{"$^R"})$#, + "1 2 abc", + "1 2 b", + "\$1 = abc, \$2 = b, \$3 = undef, \$4 = undef, \$5 = undef", + ], + [ + "1234", + qr#^((\d+)((??{push @ctl_n, $f->($^N); push @plus, $f->($+);$^N + 1}))((??{push @ctl_n, $f->($^N); push @plus, $f->($+);$^N + 1}))((??{push @ctl_n, $f->($^N); push @plus, $f->($+);$^N + 1})))$#, + "1234 123 12 1 2 3 1234", + "1234 123 12 1 2 3 4", + "\$1 = 1234, \$2 = 1, \$3 = 2, \$4 = 3, \$5 = 4", + ], + [ + "1234556", + qr#^(\d+)($re6)($re6)($re6)$re6(($re6)$re6)$#, + "1234556 123455 12345 1234 123 12 1 2 3 4 4 5 56", + "1234556 123455 12345 1234 123 12 1 2 3 4 4 5 5", + "\$1 = 1, \$2 = 2, \$3 = 3, \$4 = 4, \$5 = 56", + ], + [ + "12345562", + qr#^((??{$re8}))($re7)($re7)($re7)$re7($re7)($re7(\2))$#, + "12345562 1234556 123455 12345 1234 123 12 1 2 3 4 4 5 62", + "12345562 1234556 123455 12345 1234 123 12 1 2 3 4 4 5 2", + "\$1 = 1, \$2 = 2, \$3 = 3, \$4 = 4, \$5 = 5", + ], + ) { + $c++; + @ctl_n = (); + @plus = (); + undef $^R; + my $match = $test->[0] =~ $test->[1]; + my $str = join(", ", '$1 = '.$f->($1), '$2 = '.$f->($2), '$3 = '.$f->($3), '$4 = '.$f->($4),'$5 = '.$f->($5)); + push @ctl_n, $f->($^N); + push @plus, $f->($+); + ok($match, "match $c"); + if (not $match) { + # unset $str, @ctl_n and @plus + $str = ""; + @ctl_n = @plus = (); + } + iseq("@ctl_n", $test->[2], "ctl_n $c"); + iseq("@plus", $test->[3], "plus $c"); + iseq($str, $test->[4], "str $c"); + } + SKIP: { + if ($] le '5.010') { + skip "test segfaults on perl < 5.10", 4; + } + + @ctl_n = (); + @plus = (); + + our $re4; + local $re4 = qr#(1)((??{push @ctl_n, $f->($^N); push @plus, $f->($+);$^N + 1})){2}(?{$^N})(|abc|def)(??{"$^R"})#; + undef $^R; + my $match = "123abc3" =~ m/^(??{$re4})$/; + my $str = join(", ", '$1 = '.$f->($1), '$2 = '.$f->($2), '$3 = '.$f->($3), '$4 = '.$f->($4),'$5 = '.$f->($5),'$^R = '.$f->($^R)); + push @ctl_n, $f->($^N); + push @plus, $f->($+); + ok($match); + if (not $match) { + # unset $str + @ctl_n = (); + @plus = (); + $str = ""; + } + iseq("@ctl_n", "1 2 undef"); + iseq("@plus", "1 2 undef"); + iseq($str, "\$1 = undef, \$2 = undef, \$3 = undef, \$4 = undef, \$5 = undef, \$^R = undef"); + } + } # # This should be the last test. # ```
p5pRT commented 15 years ago

From p5p@spam.wizbit.be

rt-56194.pl

p5pRT commented 15 years ago

From @demerphq

2009/3/11 Bram via RT \perlbug\-followup@&#8203;perl\.org​:

On Sat Jun 21 11​:03​:51 2008\, p5p@​perl.wizbit.be wrote​:

While testing [perl #27603] to see if the warning is gone I noticed this​:

perl-5.10.0 -wle 'if (123 =~ /^(\d)(((??{1 + $^N})))+$/) { print "match"; } else { print "no match"; }' match

perl-blead -wle 'if (123 =~ /^(\d)(((??{1 + $^N})))+$/) { print "match"; } else { print "no match"; }' no match

And​:

perl-5.10.0 -wle 'if (122 =~ /^(\d)(((??{1 + $^N})))+$/) { print "match"; } else { print "no match"; }' no match

perl-blead -wle 'if (122 =~ /^(\d)(((??{1 + $^N})))+$/) { print "match"; } else { print "no match"; }' match

PL_reglastparen and PL_reglastcloseparen contains a pointer are set to & rex->lastparen and & rex->lastcloseparen. In case END rex is modifie but PL_reglastparen and PL_reglastcloseparen is not. Some part of the codes access PL_reglastparen while other parts use rex-

lastparen.

The attached patch corrects this and adds 3 assertions.

I'm currently unable to proof (with a test case) that the code in case EVAL_ab is really nessesary... Logically speaking it is nessesary but I do not know if it can cause test failures.

Also in the patch are missing regressions between 5.8 -> 5.10 and 5.10 -

5.11. (and a test script that contains these regressions)

The script outputs the following failures​: (stripped to show only the not ok) [snip]

$ patched-blead rt-56194.pl => all OK

The test script might contain some redundant tests but I feel it is better to include a regression test too much then one too little...

Applied to blead as commit 34a81e2b89e80eb8560606e2b29037d4da625156.

Thanks.

Could I ask tho that you provide a follow up with a patch that documents the tests a little bit?

Its a bit confusing. I think i understand it\, at least enough to apply it\, but id like to see some comments added anyway just to be sure before you forget. :-)

Yves

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

p5pRT commented 15 years ago

From @tsee

According to Bram\, this issue has been resolved.

p5pRT commented 15 years ago

@tsee - Status changed from 'open' to 'resolved'

p5pRT commented 15 years ago

From p5p@perl.wizbit.be

Citeren demerphq \demerphq@&#8203;gmail\.com​:

[snip]

Applied to blead as commit 34a81e2b89e80eb8560606e2b29037d4da625156.

Thanks.

Could I ask tho that you provide a follow up with a patch that documents the tests a little bit?

Its a bit confusing. I think i understand it\, at least enough to apply it\, but id like to see some comments added anyway just to be sure before you forget. :-)

Patch that adds some basic documentation about the test structure attached.

Best regards\,

Bram

p5pRT commented 15 years ago

From p5p@perl.wizbit.be

patch_56194_2

p5pRT commented 15 years ago

From @rgs

2009/5/30 Bram \p5p@&#8203;perl\.wizbit\.be​:

Citeren demerphq \demerphq@&#8203;gmail\.com​:

[snip]

Applied to blead as commit 34a81e2b89e80eb8560606e2b29037d4da625156.

Thanks.

Could I ask tho that you provide a follow up with a patch that documents the tests a little bit?

Its a bit confusing. I think i understand it\, at least enough to apply it\, but id like to see some comments added anyway just to be sure before you forget. :-)

Patch that adds some basic documentation about the test structure attached.

Thanks\, applied as b73790d3c9fb2026c569344bfe353223af9bdbea