Move magic logic into tryAMAGICftest macro.
Ben Morrow [Sun, 18 Jan 2009 08:35:23 +0000 (08:35 +0000)]
pp.h
pp_sys.c

diff --git a/pp.h b/pp.h
index 118c027..5c25b55 100644 (file)
--- a/pp.h
+++ b/pp.h
@@ -471,6 +471,22 @@ Does not use C<TARG>.  See also C<XPUSHu>, C<mPUSHu> and C<PUSHu>.
 #define tryAMAGICunDEREF_var(meth_enum) \
        tryAMAGICunW_var(meth_enum,setAGAIN,0,(void)0)
 
+#define tryAMAGICftest(chr)                        \
+    STMT_START {                                   \
+       if (SvAMAGIC(TOPs)) {                       \
+           SV * const tmpsv = amagic_call(TOPs,    \
+               newSVpvn_flags(&chr, 1, SVs_TEMP),  \
+               ftest_amg, 0);                      \
+                                                   \
+           if (tmpsv) {                            \
+               SPAGAIN;                            \
+               SETs(tmpsv);                        \
+               RETURN;                             \
+           }                                       \
+       }                                           \
+    } STMT_END
+
+
 #define opASSIGN (PL_op->op_flags & OPf_STACKED)
 #define SETsv(sv)      STMT_START {                                    \
                if (opASSIGN || (SvFLAGS(TARG) & SVs_PADMY))            \
index ba3bd1b..1945b13 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3048,17 +3048,7 @@ PP(pp_ftrread)
        break;
     }
 
-    if (SvAMAGIC(TOPs)) {
-       SV * const tmpsv = amagic_call(TOPs, 
-           newSVpvn_flags(&opchar, 1, SVs_TEMP), 
-           ftest_amg, 0);
-       
-       if (tmpsv) {
-           SPAGAIN;
-           SETs(tmpsv);
-           RETURN;
-       }
-    }
+    tryAMAGICftest(opchar);
 
     if (use_access) {
 #if defined(HAS_ACCESS) || defined (PERL_EFF_ACCESS)