develooper Front page | perl.perl5.porters | Postings from April 2006

Re: [perl #24704] Regex replace looses chars

Thread Previous
From:
Nicholas Clark
Date:
April 17, 2006 12:03
Subject:
Re: [perl #24704] Regex replace looses chars
Message ID:
20060417190240.GE32132@plum.flirble.org
On Mon, Apr 17, 2006 at 07:23:26PM +0100, Dave Mitchell wrote:
> On Mon, Apr 17, 2006 at 10:41:27AM -0700, Steve Peters via RT wrote:
> > > [perl-5.8.0@ton.iguana.be - Fri Dec 19 13:16:25 2003]:
> > > 
> > > 
> > > This is a bug report for perl from perl-5.8.0@ton.iguana.be,
> > > generated with the help of perlbug 1.34 running under perl v5.8.0.
> > > 
> > > 
> > > -----------------------------------------------------------------
> > > [Please enter your report here]
> > > 
> > > perl -le '$_="65x"; print; s/65/chr/e; print; print unpack("H*", $_)'
> > > 65x
> > > Ax
> > > 4178
> > > 
> > > This is normal.
> > > 
> > > perl -le '$_="x65x"; s/x//; print; s/65/chr/e; print; print
> > >    unpack("H*", $_)'
> > > 65x
> > > A
> > > 4100
> > > 
> > > Where did the second x go ????
> > > 
> > 
> > It looks like somewhere in Dave's modifications, this bug has been fixed.
> 
> Nothing to do with me! It got fixed somewhere in one of these:

It's this one:

> Change 27270 on 2006/02/22 by rgs@marais 'Turn on match string copying wh'

Change 27270 by rgs@marais on 2006/02/22 20:28:41

        Turn on match string copying when /e flag is set on a substitution.

        Subject: [PATCH] dodge a valgrind error (for maint or blead)
        From: Jarkko Hietaniemi <jhietaniemi@gmail.com>
        Date: Feb 22, 2006 8:16 PM
        Message-ID: <43FCB896.7060106@gmail.com>

Affected files ...

... //depot/perl/pp_hot.c#455 edit

Differences ...

==== //depot/perl/pp_hot.c#455 (text) ====

@@ -1335,7 +1335,7 @@
        }
     }
     if ((!global && rx->nparens)
-           || SvTEMP(TARG) || PL_sawampersand)
+           || SvTEMP(TARG) || PL_sawampersand || (pm->op_pmflags & PMf_EVAL))
        r_flags |= REXEC_COPY_STR;
     if (SvSCREAM(TARG))
        r_flags |= REXEC_SCREAM;
@@ -2101,7 +2101,8 @@
        pm = PL_curpm;
        rx = PM_GETRE(pm);
     }
-    r_flags = (rx->nparens || SvTEMP(TARG) || PL_sawampersand)
+    r_flags = (rx->nparens || SvTEMP(TARG) || PL_sawampersand
+           || (pm->op_pmflags & PMf_EVAL))
               ? REXEC_COPY_STR : 0;
     if (SvSCREAM(TARG))
        r_flags |= REXEC_SCREAM;


I'm not sure why that fixes it. For the example code, valgrind makes no
complaint with or without the change.

Nicholas Clark

Thread Previous


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