Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG in perl553> on regexp with charclasses at the beginning of (){} #2302

Closed
p5pRT opened this issue Aug 3, 2000 · 4 comments
Closed

BUG in perl553> on regexp with charclasses at the beginning of (){} #2302

p5pRT opened this issue Aug 3, 2000 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Aug 3, 2000

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

Searchable as RT3626$

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2000

From root@reality.darkrealms.cx

Created by feedback@suse.de

5.005 and 5.6 seems to be broken when you have a character class at the beginning of (here ){2} <- and a quanitifier of 2 or
more

perl -wle '$fingerprint=" 4 4 444 "; if($fingerprint =~ /^( \d{1,3}){3}\ $/) { print "yes"; } else{ print "no"}'
-> yes

perl -wle '$fingerprint="444 4 4 "; if($fingerprint =~ /^(\d{1,3} ){3}\ $/) { print "yes"; } else {print "no"}'
-> no

BUT.. this works too -> perl -wle '$fingerprint="1.1.1.1"; if($fingerprint =~ /^(\d{1,3}\.){3}\d{1,3}$/) { print "yes"; } else {print "no}'
-> yes

it seems that the qantifier after the {2} must be of digitclass, no spaces or charclasses.

this want work​: (.{4} )
this works​: ( .{4})

Perl Info


Site configuration information for perl 5.00503:

Configured by root at Mon Dec  6 19:24:36 GMT 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.2.13, archname=i586-linux
    uname='linux d235 2.2.13 #1 smp mon nov 8 16:05:52 cet 1999 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2 -pipe', gccversion=egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
    cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl 5.00503:
    /usr/lib/perl5/5.00503/i586-linux
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i586-linux
    /usr/lib/perl5/site_perl/5.005
    .


Environment for perl 5.00503:
    HOME=/root
    LANG=POSIX
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/sbin:/bin:/usr/bin:/sbin:/usr/X11R6/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash


@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2000

From [Unknown Contact. See original ticket]

hi

i sent the report with the id ID(20000803.001)
i sent it as root.. please reply to r3@​darkrealms.org

tnx

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2000

From @vanstyn

In <200008031052.MAA29001@​reality.darkrealms.cx>, root writes​:
: 5.005 and 5.6 seems to be broken when you have a character class at the
:beginning of (here ){2} <- and a quanitifier of 2 or more
[...]
:perl -wle '$fingerprint="444 4 4 "; if($fingerprint =~ /^(\d{1,3} ){3}\ $/) {
: print "yes"; } else {print "no"}'
:-> no

Thanks for the report; this is similar to a problem fixed recently in the
latest bleading-edge perl, but shows that that fix didn't go far enough.
Here's a reference to the previous patch​:
  http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-07/msg00491.html

That patch fixed the starting point to look for the best floating
substring, but the endpoint for that search also needed fixing.

The two patches to regcomp.c should apply cleanly to 5.6.0 and 5.005_03
release versions (around the same place in 5.6.0, and around line 580
in 5.005_03), but I have tested them only in bleadperl.

Hugo

Inline Patch
--- regcomp.c.old	Tue Aug  1 03:32:07 2000
+++ regcomp.c	Thu Aug  3 18:13:50 2000
@@ -904,6 +904,8 @@
 			} else {
 			    /* start offset must point into the last copy */
 			    data->last_start_min += minnext * (mincount - 1);
+			    data->last_start_max += is_inf ? 0 : (maxcount - 1)
+				* (minnext + data->pos_delta);
 			}
 		    }
 		    /* It is counted once already... */
--- t/op/re_tests.old	Wed Aug  2 18:03:41 2000
+++ t/op/re_tests	Thu Aug  3 18:16:05 2000
@@ -756,6 +756,18 @@
 ^(.,){2}c	a,b,c	y	$1	b,
 ^(?:[^,]*,){2}c	a,b,c	y	-	-
 ^([^,]*,){2}c	a,b,c	y	$1	b,
+^([^,]*,){3}d	aaa,b,c,d	y	$1	c,
+^([^,]*,){3,}d	aaa,b,c,d	y	$1	c,
+^([^,]*,){0,3}d	aaa,b,c,d	y	$1	c,
+^([^,]{1,3},){3}d	aaa,b,c,d	y	$1	c,
+^([^,]{1,3},){3,}d	aaa,b,c,d	y	$1	c,
+^([^,]{1,3},){0,3}d	aaa,b,c,d	y	$1	c,
+^([^,]{1,},){3}d	aaa,b,c,d	y	$1	c,
+^([^,]{1,},){3,}d	aaa,b,c,d	y	$1	c,
+^([^,]{1,},){0,3}d	aaa,b,c,d	y	$1	c,
+^([^,]{0,3},){3}d	aaa,b,c,d	y	$1	c,
+^([^,]{0,3},){3,}d	aaa,b,c,d	y	$1	c,
+^([^,]{0,3},){0,3}d	aaa,b,c,d	y	$1	c,
 (?i)		y	-	-
 '(?!\A)x'm	a\nxb\n	y	-	-
 ^(a(b)?)+$	aba	y	-$1-$2-	-a--

@p5pRT
Copy link
Author

p5pRT commented Aug 3, 2000

From @jhi

On Thu, Aug 03, 2000 at 06​:25​:30PM +0100, Hugo wrote​:

In <200008031052.MAA29001@​reality.darkrealms.cx>, root writes​:
: 5.005 and 5.6 seems to be broken when you have a character class at the
:beginning of (here ){2} <- and a quanitifier of 2 or more
[...]
:perl -wle '$fingerprint="444 4 4 "; if($fingerprint =~ /^(\d{1,3} ){3}\ $/) {
: print "yes"; } else {print "no"}'
:-> no

Thanks for the report; this is similar to a problem fixed recently in the
latest bleading-edge perl, but shows that that fix didn't go far enough.
Here's a reference to the previous patch​:
http​://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2000-07/msg00491.html

That patch fixed the starting point to look for the best floating
substring, but the endpoint for that search also needed fixing.

The two patches to regcomp.c should apply cleanly to 5.6.0 and 5.005_03
release versions (around the same place in 5.6.0, and around line 580
in 5.005_03), but I have tested them only in bleadperl.

It's in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant