develooper Front page | perl.perl5.porters | Postings from July 2003

[perl #23180] "target is too short" optimization does not reset pos()

From:
perlbug-followup
Date:
July 31, 2003 06:15
Subject:
[perl #23180] "target is too short" optimization does not reset pos()
Message ID:
rt-23180-61998.3.76897933408102@rt.perl.org
# New Ticket Created by  david.bouman@xbn.nl 
# Please include the string:  [perl #23180]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt2/Ticket/Display.html?id=23180 >



This is a bug report for perl from david.bouman@xbn.nl,
generated with the help of perlbug 1.26 running under perl 5.00503.


-----------------------------------------------------------------
[Please enter your report here]

Please consider this short example:

#!/usr/bin/perl -l

for ("f") {
  m/./g  or print "1st match failed"; print pos || "<undef>";
  m/../g or print "2nd match failed"; print pos || "<undef>";
}

This outputs:

1
2nd match failed
1

Since the second match failed, pos() should be undefined after
that.

Changing the second match to "m/./g" will show pos has been reset

This behaviour is present in all versions of perl I've access
to up to and including 5.8.0

I should mention that it was Steve Grazzini <grazz@pobox.com> who
really identified where the problem probably was and who provided
the above example. The only credit I will take is stumbling upon
pos() behaving badly and reporting an case to comp.lang.perl.misc

[Please do not change anything below this line]
-----------------------------------------------------------------

---
Site configuration information for perl 5.00503:

Configured by beheer at Tue Jul  6 14:27:38 MET DST 1999.

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=solaris, osvers=2.7, archname=sun4-solaris
    uname='sunos white 5.7 generic_106541-04 sun4u sparc sunw,ultra-250 '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='gcc', optimize='-O2', gccversion=2.8.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-fPIC', lddlflags='-G -L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl 5.00503:
    /opt/perl5/lib/5.00503
    /opt/perl5/lib/site_perl/5.005
    /opt/perl5/lib/site_perl/5.005
    .

---
Environment for perl 5.00503:
    HOME=/home/david
    LANG=C
    LANGUAGE (unset)
    LC_CTYPE=iso_8859_1
    LD_LIBRARY_PATH=/home/david/usr/lib
    LOGDIR (unset)
    PATH=/usr/bin:/usr/ccs/bin:/usr/local/bin:/usr/openwin/bin:/opt/netpbm/bin:/usr/sbin:/sbin:/home/david/usr/bin:/volume/tex/teTeX/bin:/usr/lib/lp/postscript:/opt/perl5/bin:/opt/openssh/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/bash




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