Debian Codegraph @

hax/op_sibling_splice.c.inc

raw
1 /* vi: set ft=c : */
2
3 #ifndef op_sibling_splice
4 # define op_sibling_splice(parent, start, del_count, insert) S_op_sibling_splice(aTHX_ parent, start, del_count, insert)
5 static OP *S_op_sibling_splice(pTHX_ OP *parent, OP *start, int del_count, OP *insert)
6 {
7 OP *deleted = NULL;
8
9 if(!insert && !del_count)
10 return NULL;
11
12 OP **prevp;
13 if(start)
14 prevp = &(start->op_sibling);
15 else
16 prevp = &(cLISTOPx(parent)->op_first);
17
18 OP *after = *prevp;
19
20 if(del_count) {
21 croak("Back-compat op_sibling_splice with del_count != 0 not yet implemented");
22 /* THIS IS AS YET UNTESTED
23 deleted = *prevp;
24 OP *o = deleted;
25 while(del_count > 1)
26 o = o->op_sibling, del_count--;
27 after = o->op_sibling;
28 o->op_sibling = NULL;
29 */
30 }
31
32 if(insert) {
33 *prevp = insert;
34 OP *o = insert;
35 while(o->op_sibling)
36 o = o->op_sibling;
37 o->op_sibling = after;
38 }
39 else
40 *prevp = after;
41
42 return deleted;
43 }
44 #endif