Skip Menu |
Report information
Id: 18165
Status: resolved
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: mjd [at] plover.com
Cc:
AdminCc:

Operating System: Linux
PatchStatus: (no value)
Severity: medium
Type: core
Perl Version: 5.6.1
Fixed In: (no value)



Date: 30 Oct 2002 17:27:06 -0000
From: mjd [...] plover.com
To: perlbug [...] perl.org
Subject: "0" fails as right-hand argument to ..
Cc: root [...] plover.com
Download (untitled) / with headers
text/plain 2.7k
This is a bug report for perl from mjd@plover.com, generated with the help of perlbug 1.33 running under perl v5.6.1. ----------------------------------------------------------------- [Please enter your report here] perl -e 'print "-4" .. "0"' This prints nothing. The problem persists in 5.7.3. [Please do not change anything below this line] ----------------------------------------------------------------- --- Flags: category=core severity=medium --- Site configuration information for perl v5.6.1: Configured by root at Sat Dec 29 11:54:59 EST 2001. Summary of my perl5 (revision 5.0 version 6 subversion 1) configuration: Platform: osname=linux, osvers=2.4.2-2, archname=i586-linux uname='linux plover.com 2.4.2-2 #1 sun apr 8 19:37:14 edt 2001 i586 unknown ' config_args='-des' hint=recommended, useposix=true, d_sigaction=define usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef useperlio=undef d_sfio=undef uselargefiles=define usesocks=undef use64bitint=undef use64bitall=undef uselongdouble=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fno-strict-aliasing' ccversion='', gccversion='2.96 20000731 (Red Hat Linux 7.1 2.96-81)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 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 -lcrypt -lutil perllibs=-lnsl -ldl -lm -lc -lcrypt -lutil libc=/lib/libc-2.2.2.so, 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 v5.6.1: /usr/local/lib/perl5/5.6.1/i586-linux /usr/local/lib/perl5/5.6.1 /usr/local/lib/perl5/site_perl/5.6.1/i586-linux /usr/local/lib/perl5/site_perl/5.6.1 /usr/local/lib/perl5/site_perl/5.6.0/i586-linux /usr/local/lib/perl5/site_perl/5.6.0 /usr/local/lib/perl5/site_perl . --- Environment for perl v5.6.1: HOME=/home/mjd LANG=C LANGUAGE (unset) LD_LIBRARY_PATH=/lib:/usr/lib:/usr/X11R6/lib LOGDIR (unset) PATH=/home/mjd/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin:/usr/games:/sbin:/usr/sbin:/usr/local/bin/X11R6:/usr/local/bin/mh:/data/mysql/bin:/usr/local/bin/pbm:/usr/local/bin/ezmlm:/home/mjd/TPI/bin:/usr/local/teTeX/bin:/usr/local/mysql/bin PERL_BADLANG (unset) SHELL=/bin/bash
Date: Thu, 31 Oct 2002 02:29:04 +0530
From: Abhijit Menon-Sen <ams [...] wiw.org>
To: perl5-porters [...] perl.org
Subject: Re: [perl #18165] "0" fails as right-hand argument to ..
RT-Send-Cc:
Download (untitled) / with headers
text/plain 2.1k
At 2002-10-30 17:27:53 -0000, perlbug@perl.org wrote: Show quoted text
> > perl -e 'print "-4" .. "0"'
This is a very old bug, introduced by: | Change 4730 by gsar@auger on 1999/12/28 19:55:56 | | range operator does magical string increment iff both operands | are non-numbers, from Tom Phoenix <rootbeer@redcat.com>; fixed | the "foreach (RANGE)" case as well (Ha ha, Andreas. :-) The appended patch fixes it. -- ams Change 18073 by ams@lustre on 2002/10/30 19:47:12 Subject: [perl #18165] "0" fails as right-hand argument to .. From: Mark-Jason Dominus (via RT) <perlbug@perl.org> Date: 30 Oct 2002 17:27:53 -0000 Message-Id: <rt-18165-40816.6.86096008382222@bugs6.perl.org> (Fixed by making an exception for .."0" in pp_flop.) Affected files ... ...... //depot/perl/pp_ctl.c#325 edit ...... //depot/perl/t/op/range.t#9 edit Differences ... ==== //depot/perl/pp_ctl.c#325 (text) ==== Index: perl/pp_ctl.c --- perl/pp_ctl.c#324~18048~ Tue Oct 22 22:34:26 2002 +++ perl/pp_ctl.c Thu Oct 31 01:17:12 2002 @@ -943,10 +943,15 @@ if (SvGMAGICAL(right)) mg_get(right); + /* This code tries to decide if "$left .. $right" should use the + magical string increment, or if the range is numeric (we make + an exception for .."0" [#18165]). AMS 20021031. */ + if (SvNIOKp(left) || !SvPOKp(left) || SvNIOKp(right) || !SvPOKp(right) || (looks_like_number(left) && *SvPVX(left) != '0' && - looks_like_number(right) && *SvPVX(right) != '0')) + looks_like_number(right) && (*SvPVX(right) != '0' || + SvCUR(right) == 1))) { if (SvNV(left) < IV_MIN || SvNV(right) > IV_MAX) DIE(aTHX_ "Range iterator outside integer range"); ==== //depot/perl/t/op/range.t#9 (xtext) ==== Index: perl/t/op/range.t --- perl/t/op/range.t#8~4730~ Wed Dec 29 01:25:56 1999 +++ perl/t/op/range.t Thu Oct 31 01:17:12 2002 @@ -1,6 +1,6 @@ #!./perl -print "1..15\n"; +print "1..16\n"; print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n"; @@ -73,3 +73,7 @@ print "not "; } print "ok 15\n"; + +# [#18165] Should allow "-4".."0", broken by #4730. (AMS 20021031) +print "not " unless 5 == (() = "-4".."0"); +print "ok 16\n";
To: Abhijit Menon-Sen <ams [...] wiw.org>
Cc: perl5-porters [...] perl.org
Subject: Re: [perl #18165] "0" fails as right-hand argument to ..
From: Slaven Rezic <slaven.rezic [...] berlin.de>
Date: 31 Oct 2002 00:13:51 +0100
RT-Send-Cc:
Download (untitled) / with headers
text/plain 2.5k
Abhijit Menon-Sen <ams@wiw.org> writes: Show quoted text
> At 2002-10-30 17:27:53 -0000, perlbug@perl.org wrote:
> > > > perl -e 'print "-4" .. "0"'
> > This is a very old bug, introduced by: > > | Change 4730 by gsar@auger on 1999/12/28 19:55:56 > | > | range operator does magical string increment iff both operands > | are non-numbers, from Tom Phoenix <rootbeer@redcat.com>; fixed > | the "foreach (RANGE)" case as well > > (Ha ha, Andreas. :-) > > The appended patch fixes it. >
Please see also [perl #18114] and the patch there, which also handles the "-4\n" .. "0\n" case. Regards, Slaven Show quoted text
> -- ams > > Change 18073 by ams@lustre on 2002/10/30 19:47:12 > > Subject: [perl #18165] "0" fails as right-hand argument to .. > From: Mark-Jason Dominus (via RT) <perlbug@perl.org> > Date: 30 Oct 2002 17:27:53 -0000 > Message-Id: <rt-18165-40816.6.86096008382222@bugs6.perl.org> > > (Fixed by making an exception for .."0" in pp_flop.) > > Affected files ... > > ... //depot/perl/pp_ctl.c#325 edit > ... //depot/perl/t/op/range.t#9 edit > > Differences ... > > ==== //depot/perl/pp_ctl.c#325 (text) ==== > Index: perl/pp_ctl.c > --- perl/pp_ctl.c#324~18048~ Tue Oct 22 22:34:26 2002 > +++ perl/pp_ctl.c Thu Oct 31 01:17:12 2002 > @@ -943,10 +943,15 @@ > if (SvGMAGICAL(right)) > mg_get(right); > > + /* This code tries to decide if "$left .. $right" should use the > + magical string increment, or if the range is numeric (we make > + an exception for .."0" [#18165]). AMS 20021031. */ > + > if (SvNIOKp(left) || !SvPOKp(left) || > SvNIOKp(right) || !SvPOKp(right) || > (looks_like_number(left) && *SvPVX(left) != '0' && > - looks_like_number(right) && *SvPVX(right) != '0')) > + looks_like_number(right) && (*SvPVX(right) != '0' || > + SvCUR(right) == 1))) > { > if (SvNV(left) < IV_MIN || SvNV(right) > IV_MAX) > DIE(aTHX_ "Range iterator outside integer range"); > > ==== //depot/perl/t/op/range.t#9 (xtext) ==== > Index: perl/t/op/range.t > --- perl/t/op/range.t#8~4730~ Wed Dec 29 01:25:56 1999 > +++ perl/t/op/range.t Thu Oct 31 01:17:12 2002 > @@ -1,6 +1,6 @@ > #!./perl > > -print "1..15\n"; > +print "1..16\n"; > > print join(':',1..5) eq '1:2:3:4:5' ? "ok 1\n" : "not ok 1\n"; > > @@ -73,3 +73,7 @@ > print "not "; > } > print "ok 15\n"; > + > +# [#18165] Should allow "-4".."0", broken by #4730. (AMS 20021031) > +print "not " unless 5 == (() = "-4".."0"); > +print "ok 16\n"; >
-- Slaven Rezic - slaven.rezic@berlin.de tknotes - A knotes clone, written in Perl/Tk. http://ptktools.sourceforge.net/#tknotes
Date: Thu, 31 Oct 2002 05:12:46 +0530
From: Abhijit Menon-Sen <ams [...] wiw.org>
To: perl5-porters [...] perl.org
Subject: Re: [perl #18165] "0" fails as right-hand argument to ..
RT-Send-Cc:
Download (untitled) / with headers
text/plain 297b
At 2002-10-31 00:13:51 +0100, slaven.rezic@berlin.de wrote: Show quoted text
> > Please see also [perl #18114] and the patch there, which also handles > the "-4\n" .. "0\n" case.
Thanks, I've applied that patch with Yves Orton's tests and my comments, as #18074. -- ams, clearly not reading p5p with both eyes.
To: Abhijit Menon-Sen <ams [...] wiw.org>
Cc: perl5-porters [...] perl.org
Subject: Re: [perl #18165] "0" fails as right-hand argument to ..
From: Slaven Rezic <slaven.rezic [...] berlin.de>
Date: 30 Nov 2002 00:07:05 +0100
RT-Send-Cc:
Download (untitled) / with headers
text/plain 1.5k
Abhijit Menon-Sen <ams@wiw.org> writes: Show quoted text
> At 2002-10-31 00:13:51 +0100, slaven.rezic@berlin.de wrote:
> > > > Please see also [perl #18114] and the patch there, which also handles > > the "-4\n" .. "0\n" case.
> > Thanks, I've applied that patch with Yves Orton's tests and my comments, > as #18074. >
Here's a similar patch for the for ("-4" .. "0") { ... } case: --- bleedperl/pp_ctl.c Mon Nov 25 04:42:18 2002 +++ bleedperl3/pp_ctl.c Fri Nov 29 23:50:32 2002 @@ -1690,11 +1690,11 @@ PP(pp_enteriter) cx->blk_loop.iterary = (AV*)SvREFCNT_inc(POPs); if (SvTYPE(cx->blk_loop.iterary) != SVt_PVAV) { dPOPss; + /* See comment in pp_flop() */ if (SvNIOKp(sv) || !SvPOKp(sv) || SvNIOKp(cx->blk_loop.iterary) || !SvPOKp(cx->blk_loop.iterary) || (looks_like_number(sv) && *SvPVX(sv) != '0' && - looks_like_number((SV*)cx->blk_loop.iterary) && - *SvPVX(cx->blk_loop.iterary) != '0')) + looks_like_number((SV*)cx->blk_loop.iterary))) { if (SvNV(sv) < IV_MIN || SvNV((SV*)cx->blk_loop.iterary) >= IV_MAX) --- bleedperl/t/cmd/for.t Thu May 10 15:28:03 2001 +++ bleedperl3/t/cmd/for.t Fri Nov 29 23:43:39 2002 @@ -1,6 +1,6 @@ #!./perl -print "1..11\n"; +print "1..12\n"; for ($i = 0; $i <= 10; $i++) { $x[$i] = $i; @@ -66,3 +66,8 @@ foreach $b (bar()) { } print $a == 7 ? "ok" : "not ok", " 11\n"; +$loop_count = 0; +for ("-3" .. "0") { + $loop_count++; +} +print $loop_count == 4 ? "ok" : "not ok", " 12\n"; -- Slaven Rezic - slaven.rezic@berlin.de Tk-AppMaster: a perl/Tk module launcher designed for handhelds http://tk-appmaster.sf.net
Date: Mon, 9 Dec 2002 00:17:47 +0100
From: Rafael Garcia-Suarez <rgarciasuarez [...] free.fr>
To: slaven.rezic [...] berlin.de
Cc: perl5-porters [...] perl.org
Subject: Re: [perl #18165] "0" fails as right-hand argument to ..
RT-Send-Cc:
Download (untitled) / with headers
text/plain 560b
Slaven Rezic wrote: Show quoted text
> Abhijit Menon-Sen <ams@wiw.org> writes: >
> > At 2002-10-31 00:13:51 +0100, slaven.rezic@berlin.de wrote:
> > > > > > Please see also [perl #18114] and the patch there, which also handles > > > the "-4\n" .. "0\n" case.
> > > > Thanks, I've applied that patch with Yves Orton's tests and my comments, > > as #18074. > >
> > Here's a similar patch for the > > for ("-4" .. "0") { ... } > > case: > > --- bleedperl/pp_ctl.c Mon Nov 25 04:42:18 2002 > +++ bleedperl3/pp_ctl.c Fri Nov 29 23:50:32 2002
Thanks, applied as #18264.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org