This is in preparation for making the test more complicated.
STRLEN cur1 = SvCUR(sv);
const char *pv2 = pv;
STRLEN cur2 = pvlen;
- if (PL_encoding) {
+ if (IN_ENCODING) {
SV* svrecode = NULL;
if (SvUTF8(sv)) {
svrecode = newSVpvn(pv2, cur2);
# endif
#endif /* !NO_LOCALE && HAS_SETLOCALE */
+/* Are we under the encoding pragma? */
+#define IN_ENCODING UNLIKELY(PL_encoding)
+
#include <setjmp.h>
#ifdef I_SYS_PARAM
Perl_croak_no_modify();
}
- if (PL_encoding) {
+ if (IN_ENCODING) {
if (!SvUTF8(sv)) {
/* XXX, here sv is utf8-ized as a side-effect!
If encoding.pm is used properly, almost string-generating
}
rsptr = temp_buffer;
}
- else if (PL_encoding) {
+ else if (IN_ENCODING) {
/* RS is 8 bit, encoding.pm is used.
* Do not recode PL_rs as a side-effect. */
svrecode = newSVpvn(rsptr, rslen);
little_utf8 = DO_UTF8(little);
if (big_utf8 ^ little_utf8) {
/* One needs to be upgraded. */
- if (little_utf8 && !PL_encoding) {
+ if (little_utf8 && !IN_ENCODING) {
/* Well, maybe instead we might be able to downgrade the small
string? */
char * const pv = (char*)bytes_from_utf8((U8 *)little_p, &llen,
temp = little_utf8
? newSVpvn(big_p, biglen) : newSVpvn(little_p, llen);
- if (PL_encoding) {
+ if (IN_ENCODING) {
sv_recode_to_utf8(temp, PL_encoding);
} else {
sv_utf8_upgrade(temp);
STRLEN len;
const U8 *s = (U8*)SvPV_const(argsv, len);
- if (PL_encoding && SvPOK(argsv) && !DO_UTF8(argsv)) {
+ if (IN_ENCODING && SvPOK(argsv) && !DO_UTF8(argsv)) {
SV * const tmpsv = sv_2mortal(newSVsv(argsv));
s = (U8*)sv_recode_to_utf8(tmpsv, PL_encoding);
len = UTF8SKIP(s); /* Should be well-formed; so this is its length */
*tmps = '\0';
(void)SvPOK_only(TARG);
- if (PL_encoding && !IN_BYTES) {
+ if (IN_ENCODING && !IN_BYTES) {
sv_recode_to_utf8(TARG, PL_encoding);
tmps = SvPVX(TARG);
if (SvCUR(TARG) == 0
if (DO_UTF8(TARG) && !doutf8) {
nsv = sv_newmortal();
SvSetSV(nsv, dstr);
- if (PL_encoding)
+ if (IN_ENCODING)
sv_recode_to_utf8(nsv, PL_encoding);
else
sv_utf8_upgrade(nsv);
first = FALSE;
}
else {
- if (PL_encoding) {
+ if (IN_ENCODING) {
if (!nsv) nsv = sv_newmortal();
sv_copypv(nsv, repl);
if (!DO_UTF8(nsv)) sv_recode_to_utf8(nsv, PL_encoding);
bytes from a byte file handle into a UTF8 buffer, but it won't harm us
unduly.
(should be 2 * length + offset + 1, or possibly something longer if
- PL_encoding is true) */
+ IN_ENCODING Is true) */
buffer = SvGROW(bufsv, (STRLEN)(length+offset+1));
if (offset > 0 && offset > (SSize_t)orig_size) { /* Zero any newly allocated space */
Zero(buffer+orig_size, offset-orig_size, char);
vFAIL(error_msg);
}
ender = result;
- if (PL_encoding && ender < 0x100) {
+ if (IN_ENCODING && ender < 0x100) {
goto recode_encoding;
}
if (ender > 0xff) {
}
ender = result;
- if (PL_encoding && ender < 0x100) {
+ if (IN_ENCODING && ender < 0x100) {
goto recode_encoding;
}
if (ender > 0xff) {
form_short_octal_warning(p, numlen));
}
}
- if (PL_encoding && ender < 0x100)
+ if (IN_ENCODING && ender < 0x100)
goto recode_encoding;
break;
recode_encoding:
vFAIL(error_msg);
}
}
- if (PL_encoding && value < 0x100) {
+ if (IN_ENCODING && value < 0x100) {
goto recode_encoding;
}
break;
vFAIL(error_msg);
}
}
- if (PL_encoding && value < 0x100)
+ if (IN_ENCODING && value < 0x100)
goto recode_encoding;
break;
case 'c':
(void)ReREFCNT_inc(RExC_rx_sv);
}
}
- if (PL_encoding && value < 0x100)
+ if (IN_ENCODING && value < 0x100)
goto recode_encoding;
break;
}
S_sv_uncow(aTHX_ sv, 0);
}
- if (PL_encoding && !(flags & SV_UTF8_NO_ENCODING)) {
+ if (IN_ENCODING && !(flags & SV_UTF8_NO_ENCODING)) {
sv_recode_to_utf8(sv, PL_encoding);
if (extra) SvGROW(sv, SvCUR(sv) + extra);
return SvCUR(sv);
if (cur1 && cur2 && SvUTF8(sv1) != SvUTF8(sv2) && !IN_BYTES) {
/* Differing utf8ness.
* Do not UTF8size the comparands as a side-effect. */
- if (PL_encoding) {
+ if (IN_ENCODING) {
if (SvUTF8(sv1)) {
svrecode = newSVpvn(pv2, cur2);
sv_recode_to_utf8(svrecode, PL_encoding);
/* Differing utf8ness.
* Do not UTF8size the comparands as a side-effect. */
if (SvUTF8(sv1)) {
- if (PL_encoding) {
+ if (IN_ENCODING) {
svrecode = newSVpvn(pv2, cur2);
sv_recode_to_utf8(svrecode, PL_encoding);
pv2 = SvPV_const(svrecode, cur2);
}
}
else {
- if (PL_encoding) {
+ if (IN_ENCODING) {
svrecode = newSVpvn(pv1, cur1);
sv_recode_to_utf8(svrecode, PL_encoding);
pv1 = SvPV_const(svrecode, cur1);
" >= %"UVuf, (UV)SvCUR(sv), (UV)SvLEN(sv));
SvPOK_on(sv);
- if (PL_encoding && !has_utf8) {
+ if (IN_ENCODING && !has_utf8) {
sv_recode_to_utf8(sv, PL_encoding);
if (SvUTF8(sv))
has_utf8 = TRUE;
if (!IN_BYTES) {
if (UTF)
PerlIO_apply_layers(aTHX_ PL_rsfp, NULL, ":utf8");
- else if (PL_encoding) {
+ else if (IN_ENCODING) {
SV *name;
dSP;
ENTER;
if (!IN_BYTES) {
if (UTF && is_utf8_string((U8*)SvPVX_const(tmpstr), SvCUR(tmpstr)))
SvUTF8_on(tmpstr);
- else if (PL_encoding)
+ else if (IN_ENCODING)
sv_recode_to_utf8(tmpstr, PL_encoding);
}
PL_lex_stuff = tmpstr;
sv_catpvn(sv, s, termlen);
s += termlen;
for (;;) {
- if (PL_encoding && !UTF && !re_reparse) {
+ if (IN_ENCODING && !UTF && !re_reparse) {
bool cont = TRUE;
while (cont) {
/* at this point, we have successfully read the delimited string */
- if (!PL_encoding || UTF || re_reparse) {
+ if (!IN_ENCODING || UTF || re_reparse) {
if (keep_delims)
sv_catpvn(sv, s, termlen);
s += termlen;
}
- if (has_utf8 || (PL_encoding && !re_reparse))
+ if (has_utf8 || (IN_ENCODING && !re_reparse))
SvUTF8_on(sv);
PL_multi_end = CopLINE(PL_curcop);
if (!IN_BYTES) {
if (UTF && is_utf8_string((U8*)SvPVX_const(stuff), SvCUR(stuff)))
SvUTF8_on(stuff);
- else if (PL_encoding)
+ else if (IN_ENCODING)
sv_recode_to_utf8(stuff, PL_encoding);
}
NEXTVAL_NEXTTOKE.opval = (OP*)newSVOP(OP_CONST, 0, stuff);