U8 * const send = s+len;
PERL_ARGS_ASSERT_DO_TRANS_SIMPLE;
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: entering do_trans_simple:"
+ " input sv:\n",
+ __FILE__, __LINE__));
+ DEBUG_y(sv_dump(sv));
/* First, take care of non-UTF-8 input strings, because they're easy */
if (!SvUTF8(sv)) {
SvUTF8_on(sv);
SvSETMAGIC(sv);
}
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: returning %zu\n",
+ __FILE__, __LINE__, matches));
+ DEBUG_y(sv_dump(sv));
return matches;
}
PERL_ARGS_ASSERT_DO_TRANS_COUNT;
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: entering do_trans_count:"
+ " input sv:\n",
+ __FILE__, __LINE__));
+ DEBUG_y(sv_dump(sv));
+
if (!SvUTF8(sv)) {
while (s < send) {
if (tbl->map[*s++] >= 0)
}
}
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: count returning %zu\n",
+ __FILE__, __LINE__, matches));
return matches;
}
PERL_ARGS_ASSERT_DO_TRANS_COMPLEX;
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: entering do_trans_complex:"
+ " input sv:\n",
+ __FILE__, __LINE__));
+ DEBUG_y(sv_dump(sv));
+
if (!SvUTF8(sv)) {
U8 *d = s;
U8 * const dstart = d;
SvUTF8_on(sv);
}
SvSETMAGIC(sv);
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: returning %zu\n",
+ __FILE__, __LINE__, matches));
+ DEBUG_y(sv_dump(sv));
return matches;
}
PERL_ARGS_ASSERT_DO_TRANS_COUNT_INVMAP;
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d:"
+ "entering do_trans_count_invmap:"
+ " input sv:\n",
+ __FILE__, __LINE__));
+ DEBUG_y(sv_dump(sv));
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "mapping:\n"));
+ DEBUG_y(invmap_dump(from_invlist, (UV *) SvPVX(to_invmap_sv)));
+
s = (U8*)SvPV_nomg(sv, len);
send = s + len;
s += s_len;
}
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: returning %zu\n",
+ __FILE__, __LINE__, matches));
return matches;
}
-
/* Helper function for do_trans().
* Handles cases where an inversion map implementation is to be used and the
* search and replacement charlists are either not identical or flags are
const bool delete_unfound = cBOOL(PL_op->op_private & OPpTRANS_DELETE);
bool inplace = ! cBOOL(PL_op->op_private & OPpTRANS_GROWS);
const UV* from_array = invlist_array(from_invlist);
- UV final_map;
- bool out_is_utf8 = SvUTF8(sv);
+ UV final_map = TR_OOB;
+ bool out_is_utf8 = cBOOL(SvUTF8(sv));
STRLEN s_len;
PERL_ARGS_ASSERT_DO_TRANS_INVMAP;
}
s = (U8*)SvPV_nomg(sv, len);
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: entering do_trans_invmap:"
+ " input sv:\n",
+ __FILE__, __LINE__));
+ DEBUG_y(sv_dump(sv));
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "mapping:\n"));
+ DEBUG_y(invmap_dump(from_invlist, map));
+
send = s + len;
s0 = s;
* this particular input string will grow. However, the compilation
* calculated the maximum expansion possible. Use that to allocale
* based on the worst case scenario. */
- Newx(d, len * max_expansion + 1, U8);
+ Newx(d, (STRLEN) (len * max_expansion + 1 + 1), U8);
d0 = d;
}
if (to == (UV) TR_UNLISTED) { /* Just copy the unreplaced character */
if (UVCHR_IS_INVARIANT(from) || ! out_is_utf8) {
- *d++ = from;
+ *d++ = (U8) from;
}
else if (SvUTF8(sv)) {
Move(s, d, s_len, U8);
matches = 0;
goto restart;
}
- *d++ = to;
+ *d++ = (U8) to;
}
}
s += s_len;
if (! inplace) {
sv_setpvn(sv, (char*)d0, d - d0);
+ Safefree(d0);
}
else {
*d = '\0';
}
SvSETMAGIC(sv);
+ DEBUG_y(PerlIO_printf(Perl_debug_log, "%s: %d: returning %zu\n",
+ __FILE__, __LINE__, matches));
+ DEBUG_y(sv_dump(sv));
return matches;
}
-
/* Execute a tr//. sv is the value to be translated, while PL_op
* should be an OP_TRANS or OP_TRANSR op, whose op_pv field contains a
* translation table or whose op_sv field contains an inversion map.