From 1ad2fb538ba3deddf66914f96dad1cce4e5f29fd Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 10 Jul 2011 00:27:05 -0500 Subject: apparently this didn't exist before 5.14 or so --- smartmatch.xs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) 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) { -- cgit v1.2.3-54-g00ecf