Skip to content

Commit

Permalink
builtin::trim: dest is always TARG
Browse files Browse the repository at this point in the history
  • Loading branch information
tonycoz committed Nov 26, 2024
1 parent d700717 commit f5e39e9
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@ XS(XS_builtin_trim)
SV *source = TOPs;
STRLEN len;
const U8 *start;
SV *dest;

SvGETMAGIC(source);

Expand Down Expand Up @@ -273,27 +272,25 @@ XS(XS_builtin_trim)
}
}

dest = TARG;
SvUPGRADE(TARG, SVt_PV);
SvGROW(TARG, len + 1);

SvUPGRADE(dest, SVt_PV);
SvGROW(dest, len + 1);

Copy(start, SvPVX(dest), len, U8);
SvPVX(dest)[len] = '\0';
SvPOK_only_UTF8(dest);
SvCUR_set(dest, len);
Copy(start, SvPVX(TARG), len, U8);
SvPVX(TARG)[len] = '\0';
SvPOK_only_UTF8(TARG);
SvCUR_set(TARG, len);

if (DO_UTF8(source))
SvUTF8_on(dest);
SvUTF8_on(TARG);
else
SvUTF8_off(dest);
SvUTF8_off(TARG);

if (SvTAINTED(source))
SvTAINT(dest);
SvTAINT(TARG);

SvSETMAGIC(dest);
SvSETMAGIC(TARG);

SETs(dest);
SETs(TARG);

XSRETURN(1);
}
Expand Down

0 comments on commit f5e39e9

Please sign in to comment.