MEMBER_TO_FPTR(Perl_pp_log),
MEMBER_TO_FPTR(Perl_pp_sqrt),
MEMBER_TO_FPTR(Perl_pp_int),
- MEMBER_TO_FPTR(Perl_pp_hex),
+ MEMBER_TO_FPTR(Perl_pp_oct), /* Perl_pp_hex */
MEMBER_TO_FPTR(Perl_pp_oct),
MEMBER_TO_FPTR(Perl_pp_abs),
MEMBER_TO_FPTR(Perl_pp_length),
Perl_pp_sle => [qw(slt sgt sge)],
Perl_pp_print => ['say'],
Perl_pp_index => ['rindex'],
+ Perl_pp_oct => ['hex'],
);
while (my ($func, $names) = splice @raw_alias, 0, 2) {
RETURN;
}
-
-PP(pp_hex)
-{
- dVAR; dSP; dTARGET;
- const char *tmps;
- I32 flags = PERL_SCAN_ALLOW_UNDERSCORES;
- STRLEN len;
- NV result_nv;
- UV result_uv;
- SV* const sv = POPs;
-
- tmps = (SvPV_const(sv, len));
- if (DO_UTF8(sv)) {
- /* If Unicode, try to downgrade
- * If not possible, croak. */
- SV* const tsv = sv_2mortal(newSVsv(sv));
-
- SvUTF8_on(tsv);
- sv_utf8_downgrade(tsv, FALSE);
- tmps = SvPV_const(tsv, len);
- }
- result_uv = grok_hex (tmps, &len, &flags, &result_nv);
- if (flags & PERL_SCAN_GREATER_THAN_UV_MAX) {
- XPUSHn(result_nv);
- }
- else {
- XPUSHu(result_uv);
- }
- RETURN;
-}
-
PP(pp_oct)
{
dVAR; dSP; dTARGET;
sv_utf8_downgrade(tsv, FALSE);
tmps = SvPV_const(tsv, len);
}
+ if (PL_op->op_type == OP_HEX)
+ goto hex;
+
while (*tmps && len && isSPACE(*tmps))
tmps++, len--;
if (*tmps == '0')
tmps++, len--;
- if (*tmps == 'x')
+ if (*tmps == 'x') {
+ hex:
result_uv = grok_hex (tmps, &len, &flags, &result_nv);
+ }
else if (*tmps == 'b')
result_uv = grok_bin (tmps, &len, &flags, &result_nv);
else