From 180b7b9bf7b919003df56bf402fc3934dc71f196 Mon Sep 17 00:00:00 2001 From: Ben Morrow Date: Sun, 18 Jan 2009 08:35:23 +0000 Subject: [PATCH] Move magic logic into tryAMAGICftest macro. --- pp.h | 16 ++++++++++++++++ pp_sys.c | 12 +----------- 2 files changed, 17 insertions(+), 11 deletions(-) diff --git a/pp.h b/pp.h index 118c027..5c25b55 100644 --- a/pp.h +++ b/pp.h @@ -471,6 +471,22 @@ Does not use C. See also C, C and C. #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)) \ diff --git a/pp_sys.c b/pp_sys.c index ba3bd1b..1945b13 100644 --- 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) -- 1.8.3.1