Skip to content

Commit

Permalink
pp_backtick: remove RC_STACK wrapper and use the new APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Jan 2, 2024
1 parent 50fa090 commit d8c5e10
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions pp_sys.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,11 +278,11 @@ S_emulate_eaccess(pTHX_ const char* path, Mode_t mode)
# define PERL_EFF_ACCESS(p,f) (S_emulate_eaccess(aTHX_ (p), (f)))
#endif

PP_wrapped(pp_backtick, 1, 0)
PP(pp_backtick)
{
dSP; dTARGET;
dTARGET;
PerlIO *fp;
const char * const tmps = POPpconstx;
const char * const tmps = SvPV_nolen(*PL_stack_sp);
const U8 gimme = GIMME_V;
const char *mode = "r";

Expand All @@ -292,6 +292,7 @@ PP_wrapped(pp_backtick, 1, 0)
else if (PL_op->op_private & OPpOPEN_IN_CRLF)
mode = "rt";
fp = PerlProc_popen(tmps, mode);
rpp_popfree_1();
if (fp) {
const char * const type = Perl_PerlIO_context_layers(aTHX_ NULL);
if (type && *type)
Expand All @@ -310,7 +311,7 @@ PP_wrapped(pp_backtick, 1, 0)
while (sv_gets(TARG, fp, SvCUR(TARG)) != NULL)
NOOP;
LEAVE_with_name("backtick");
XPUSHs(TARG);
rpp_push_1(TARG);
SvTAINTED_on(TARG);
}
else {
Expand All @@ -320,7 +321,8 @@ PP_wrapped(pp_backtick, 1, 0)
SvREFCNT_dec(sv);
break;
}
mXPUSHs(sv);
rpp_extend(1);
rpp_push_1_norc(sv);
if (SvLEN(sv) - SvCUR(sv) > 20) {
SvPV_shrink_to_cur(sv);
}
Expand All @@ -333,10 +335,10 @@ PP_wrapped(pp_backtick, 1, 0)
else {
STATUS_NATIVE_CHILD_SET(-1);
if (gimme == G_SCALAR)
RETPUSHUNDEF;
rpp_push_1(&PL_sv_undef);
}

RETURN;
return NORMAL;
}


Expand Down

0 comments on commit d8c5e10

Please sign in to comment.