File: force_list_keeping_pushmark.c.inc

package info (click to toggle)
libxs-parse-keyword-perl 0.48-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 572 kB
  • sloc: ansic: 2,037; perl: 1,013; sh: 6; makefile: 3
file content (25 lines) | stat: -rw-r--r-- 729 bytes parent folder | download | duplicates (4)
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
/* vi: set ft=c : */

#include "op_sibling_splice.c.inc"

/* force_list_keeping_pushmark nulls out the OP_LIST itself but preserves
 * the OP_PUSHMARK inside it. This is essential or else op_contextualize()
 * will null out both of them and we lose the mark
 */
/* copypasta from core's op.c */
#define force_list_keeping_pushmark(o)  S_force_list_keeping_pushmark(aTHX_ o)
static OP *S_force_list_keeping_pushmark(pTHX_ OP *o)
{
  if(!o || o->op_type != OP_LIST) {
    OP *rest = NULL;
    if(o) {
      rest = OpSIBLING(o);
      OpLASTSIB_set(o, NULL);
    }
    o = newLISTOP(OP_LIST, 0, o, NULL);
    if(rest)
      op_sibling_splice(o, cLISTOPo->op_last, 0, rest);
  }
  op_null(o);
  return op_contextualize(o, G_LIST);
}