This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Consolidate the code for returning false values from filetest operators.
authorNicholas Clark <nick@ccl4.org>
Fri, 27 Jul 2012 12:19:27 +0000 (14:19 +0200)
committerNicholas Clark <nick@ccl4.org>
Sat, 28 Jul 2012 07:56:58 +0000 (09:56 +0200)
Move the code that implements the non-stacking return processing from the
macro FT_RETURN_FALSE() into the static function S_ft_stacking_return_false().
Rename the function to S_ft_return_false() as it now handles all false cases.

pp_sys.c

index 891a76d..e7163ac 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -2909,7 +2909,7 @@ PP(pp_stat)
 */
 
 static OP *
-S_ft_stacking_return_false(pTHX_ SV *ret) {
+S_ft_return_false(pTHX_ SV *ret) {
     OP *next = NORMAL;
     dSP;
 
@@ -2917,21 +2917,16 @@ S_ft_stacking_return_false(pTHX_ SV *ret) {
     else                          SETs(ret);
     PUTBACK;
 
-    while (OP_IS_FILETEST(next->op_type)
-       && next->op_private & OPpFT_STACKED)
-       next = next->op_next;
+    if (PL_op->op_private & OPpFT_STACKING) {
+        while (OP_IS_FILETEST(next->op_type)
+               && next->op_private & OPpFT_STACKED)
+            next = next->op_next;
+    }
     return next;
 }
 
 #define FT_RETURN_FALSE(X)                          \
-    STMT_START {                                     \
-        dSP;                                           \
-       if (PL_op->op_private & OPpFT_STACKING)        \
-           return S_ft_stacking_return_false(aTHX_ X); \
-       PL_op->op_flags & OPf_REF ? XPUSHs(X) : SETs(X); \
-        PUTBACK;                                          \
-        return NORMAL;                                     \
-    } STMT_END
+    return S_ft_return_false(aTHX_ X)
 #define FT_RETURN_TRUE(X)                                               \
     STMT_START {                                                        \
         dSP;                                                            \