summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2011-07-10 00:27:05 -0500
committerJesse Luehrs <doy@tozt.net>2011-07-10 00:27:05 -0500
commit1ad2fb538ba3deddf66914f96dad1cce4e5f29fd (patch)
tree9034df1c88562603fc9fd946dcdf5bfc412d5721
parent283782a3ff689cb78d0a720ff349f2d78812230e (diff)
downloadsmartmatch-1ad2fb538ba3deddf66914f96dad1cce4e5f29fd.tar.gz
smartmatch-1ad2fb538ba3deddf66914f96dad1cce4e5f29fd.zip
apparently this didn't exist before 5.14 or so
-rw-r--r--smartmatch.xs28
1 files changed, 28 insertions, 0 deletions
diff --git a/smartmatch.xs b/smartmatch.xs
index 36d7c51..a639242 100644
--- a/smartmatch.xs
+++ b/smartmatch.xs
@@ -6,6 +6,34 @@
#include "hook_op_check_smartmatch.h"
+#ifndef op_append_elem
+#define op_append_elem(a,b,c) Perl_op_append_elem(aTHX_ a,b,c)
+OP *
+Perl_op_append_elem(pTHX_ I32 type, OP *first, OP *last)
+{
+ if (!first)
+ return last;
+
+ if (!last)
+ return first;
+
+ if (first->op_type != (unsigned)type
+ || (type == OP_LIST && (first->op_flags & OPf_PARENS)))
+ {
+ return newLISTOP(type, 0, first, last);
+ }
+
+ if (first->op_flags & OPf_KIDS)
+ ((LISTOP*)first)->op_last->op_sibling = last;
+ else {
+ first->op_flags |= OPf_KIDS;
+ ((LISTOP*)first)->op_first = last;
+ }
+ ((LISTOP*)first)->op_last = last;
+ return first;
+}
+#endif
+
STATIC OP*
smartmatch_cb(pTHX_ OP *o, void *user_data)
{