aboutsummaryrefslogtreecommitdiffstats
path: root/main/perl-params-classify/Params-Classify-0.013-Fix-5.25-or-5.22-24-with-PERL_OP_PARENT.patch
blob: a3964c8e2bb5555f85ac4cc591fef6638f6b4049 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From 0d301779bd42da52b4f8e13a667499846fc2cc55 Mon Sep 17 00:00:00 2001
From: Reini Urban <rurban@cpanel.net>
Date: Tue, 14 Jun 2016 17:08:24 +0200
Subject: [PATCH] Fix 5.25 or 5.22/24 with PERL_OP_PARENT
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Fixes RT #114490

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 lib/Params/Classify.xs | 36 ++++++++++++++++++++++++++----------
 1 file changed, 26 insertions(+), 10 deletions(-)

diff --git a/lib/Params/Classify.xs b/lib/Params/Classify.xs
index 15a5ad5..f4012fd 100644
--- a/lib/Params/Classify.xs
+++ b/lib/Params/Classify.xs
@@ -123,6 +123,22 @@ static void *THX_ptr_table_fetch(pTHX_ PTR_TBL_t *tbl, void *from)
 # define sv_is_regexp(sv) 0
 #endif /* <5.11.0 */
 
+
+#ifndef OpSIBLING
+# ifdef PERL_OP_PARENT
+#  define OpSIBLING(o)		(0 + (o)->op_moresib ? (o)->op_sibparent : NULL)
+#  define OpMAYBESIB_set(o, sib, parent) \
+       ((o)->op_sibparent = ((o)->op_moresib = cBOOL(sib)) ? (sib) : (parent))
+# else
+#  define OpSIBLING(o)		(0 + (o)->op_sibling)
+#  if PERL_VERSION_GE(5,11,0)
+#    define OpMAYBESIB_set(o, sib, parent) ((o)->op_sibling = (sib))
+#  else
+#    define OpMAYBESIB_set(o, sib, parent) ((o)->op_moresib = cBOOL(sib), (o)->op_sibling = (sib))
+#  endif
+# endif
+#endif
+
 #define sv_is_undef(sv) (!sv_is_glob(sv) && !sv_is_regexp(sv) && !SvOK(sv))
 
 #define sv_is_string(sv) \
@@ -631,8 +647,8 @@ static OP *myck_entersub(pTHX_ OP *op)
 	OP *(*ppfunc)(pTHX);
 	I32 cvflags;
 	pushop = cUNOPx(op)->op_first;
-	if(!pushop->op_sibling) pushop = cUNOPx(pushop)->op_first;
-	for(cvop = pushop; cvop->op_sibling; cvop = cvop->op_sibling) ;
+	if(!OpSIBLING(pushop)) pushop = cUNOPx(pushop)->op_first;
+	for(cvop = pushop; OpSIBLING(cvop); cvop = OpSIBLING(cvop)) ;
 	if(!(cvop->op_type == OP_RV2CV &&
 			!(cvop->op_private & OPpENTERSUB_AMPER) &&
 			(cv = rvop_cv(cUNOPx(cvop)->op_first)) &&
@@ -641,20 +657,20 @@ static OP *myck_entersub(pTHX_ OP *op)
 		return nxck_entersub(aTHX_ op);
 	cvflags = CvXSUBANY(cv).any_i32;
 	op = nxck_entersub(aTHX_ op);   /* for prototype checking */
-	aop = pushop->op_sibling;
-	bop = aop->op_sibling;
+	aop = OpSIBLING(pushop);
+	bop = OpSIBLING(aop);
 	if(bop == cvop) {
 		if(!(cvflags & PC_ALLOW_UNARY)) return op;
 		unary:
-		pushop->op_sibling = bop;
-		aop->op_sibling = NULL;
+		OpMAYBESIB_set(pushop, bop, NULL);
+		OpMAYBESIB_set(aop, NULL, NULL);
 		op_free(op);
 		op = newUNOP(OP_NULL, 0, aop);
 		op->op_type = OP_RAND;
 		op->op_ppaddr = ppfunc;
 		op->op_private = (U8)cvflags;
 		return op;
-	} else if(bop && bop->op_sibling == cvop) {
+	} else if(bop && OpSIBLING(bop) == cvop) {
 		if(!(cvflags & PC_ALLOW_BINARY)) return op;
 		if(ppfunc == THX_pp_check_sclass &&
 				(cvflags & PC_TYPE_MASK) == SCLASS_REF) {
@@ -673,9 +689,9 @@ static OP *myck_entersub(pTHX_ OP *op)
 			cvflags &= ~PC_TYPE_MASK;
 			ppfunc = THX_pp_check_dyn_battr;
 		}
-		pushop->op_sibling = cvop;
-		aop->op_sibling = NULL;
-		bop->op_sibling = NULL;
+		OpMAYBESIB_set(pushop, cvop, NULL);
+		OpMAYBESIB_set(aop, NULL, NULL);
+		OpMAYBESIB_set(bop, NULL, NULL);
 		op_free(op);
 		op = newBINOP(OP_NULL, 0, aop, bop);
 		op->op_type = OP_RAND;
-- 
2.9.4