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

[perl #94564] [PATCH] use a flag to signal a stacking filetests instead of peeking at the next op.

Thread Previous
From:
Gerard Goossen
Date:
July 11, 2011 12:29
Subject:
[perl #94564] [PATCH] use a flag to signal a stacking filetests instead of peeking at the next op.
Message ID:
rt-3.6.HEAD-30268-1310412578-1931.94564-75-0@perl.org
# New Ticket Created by  Gerard Goossen 
# Please include the string:  [perl #94564]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org:443/rt3/Ticket/Display.html?id=94564 >



This is a bug report for perl from gerard@ggoossen.net,
generated with the help of perlbug 1.39 running under perl 5.15.0.

>From 53d0fba815aba18f4fcf5c6be80eebaa9eb981e0 Mon Sep 17 00:00:00 2001
From: Gerard Goossen <gerard@ggoossen.net>
Date: Mon, 17 Jan 2011 22:12:53 +0100
Subject: [PATCH] use a flag to signal a stacking filetests instead of peeking
 at the next op.

Preparation for the codegeneration changes where the next op isn't accessible.
---
 op.c     |    4 +++-
 op.h     |    3 ++-
 pp_sys.c |    6 +-----
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/op.c b/op.c
index fba667f..47ca0b2 100644
--- a/op.c
+++ b/op.c
@@ -7342,8 +7342,10 @@ Perl_ck_ftst(pTHX_ OP *o)
 	if ((PL_hints & HINT_FILETEST_ACCESS) && OP_IS_FILETEST_ACCESS(o->op_type))
 	    o->op_private |= OPpFT_ACCESS;
 	if (PL_check[kidtype] == Perl_ck_ftst
-		&& kidtype != OP_STAT && kidtype != OP_LSTAT)
+	        && kidtype != OP_STAT && kidtype != OP_LSTAT) {
 	    o->op_private |= OPpFT_STACKED;
+	    kid->op_private |= OPpFT_STACKING;
+	}
     }
     else {
 #ifdef PERL_MAD
diff --git a/op.h b/op.h
index e184468..cbcac7d 100644
--- a/op.h
+++ b/op.h
@@ -284,7 +284,8 @@ Deprecated.  Use C<GIMME_V> instead.
 
 /* Private for OP_FTXXX */
 #define OPpFT_ACCESS		2	/* use filetest 'access' */
-#define OPpFT_STACKED		4	/* stacked filetest, as in "-f -x $f" */
+#define OPpFT_STACKED		4	/* stacked filetest, as "-f" in "-f -x $f" */
+#define OPpFT_STACKING		8	/* stacking filetest, as "-x" in "-f -x $f" */
 
 /* Private for OP_(MAP|GREP)(WHILE|START) */
 #define OPpGREP_LEX		2	/* iterate over lexical $_ */
diff --git a/pp_sys.c b/pp_sys.c
index 6ef266f..3325453 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2914,11 +2914,7 @@ S_try_amagic_ftest(pTHX_ char chr) {
 
 	SPAGAIN;
 
-	next = PL_op->op_next;
-	if (next->op_type >= OP_FTRREAD &&
-	    next->op_type <= OP_FTBINARY &&
-	    next->op_private & OPpFT_STACKED
-	) {
+	if (PL_op->op_private & OPpFT_STACKING) {
 	    if (SvTRUE(tmpsv))
 		/* leave the object alone */
 		return TRUE;
-- 
1.7.5.4

---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.15.0:

Configured by gerard at Mon Jul 11 20:29:16 CEST 2011.

Summary of my perl5 (revision 5 version 15 subversion 0) configuration:
  Commit id: 53d0fba815aba18f4fcf5c6be80eebaa9eb981e0
  Platform:
    osname=linux, osvers=2.6.39-2-686-pae, archname=i686-linux-thread-multi
    uname='linux zeus 2.6.39-2-686-pae #1 smp wed jun 8 11:33:14 utc 2011 i686 gnulinux '
    config_args='-des -DDEBUGGING -Dusethreads -Dusedevel -Doptimize=-O3 -g3 -Dprefix=/home/gerard/perl/inst/madperl'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O3 -g3',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.6.1', 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, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /usr/lib/i386-linux-gnu /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.13'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O3 -g3 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    

---
@INC for perl 5.15.0:
    lib
    /home/gerard/perl/inst/madperl/lib/site_perl/5.15.0/i686-linux-thread-multi
    /home/gerard/perl/inst/madperl/lib/site_perl/5.15.0
    /home/gerard/perl/inst/madperl/lib/5.15.0/i686-linux-thread-multi
    /home/gerard/perl/inst/madperl/lib/5.15.0
    /home/gerard/perl/inst/madperl/lib/site_perl
    .

---
Environment for perl 5.15.0:
    HOME=/home/gerard
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/gerard/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
    PERL_BADLANG (unset)
    SHELL=/bin/bash


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