"was the last match target UTF8" into its own variable.
p4raw-id: //depot/perl@11717
#define PL_reg_start_tmpl (vTHX->Treg_start_tmpl)
#define PL_reg_starttry (vTHX->Treg_starttry)
#define PL_reg_sv (vTHX->Treg_sv)
+#define PL_reg_sv_utf8 (vTHX->Treg_sv_utf8)
#define PL_reg_whilem_seen (vTHX->Treg_whilem_seen)
#define PL_regbol (vTHX->Tregbol)
#define PL_regcc (vTHX->Tregcc)
#define PL_reg_start_tmpl (aTHXo->interp.Treg_start_tmpl)
#define PL_reg_starttry (aTHXo->interp.Treg_starttry)
#define PL_reg_sv (aTHXo->interp.Treg_sv)
+#define PL_reg_sv_utf8 (aTHXo->interp.Treg_sv_utf8)
#define PL_reg_whilem_seen (aTHXo->interp.Treg_whilem_seen)
#define PL_regbol (aTHXo->interp.Tregbol)
#define PL_regcc (aTHXo->interp.Tregcc)
#define PL_reg_start_tmpl (aTHX->Treg_start_tmpl)
#define PL_reg_starttry (aTHX->Treg_starttry)
#define PL_reg_sv (aTHX->Treg_sv)
+#define PL_reg_sv_utf8 (aTHX->Treg_sv_utf8)
#define PL_reg_whilem_seen (aTHX->Treg_whilem_seen)
#define PL_regbol (aTHX->Tregbol)
#define PL_regcc (aTHX->Tregcc)
#define PL_Treg_start_tmpl PL_reg_start_tmpl
#define PL_Treg_starttry PL_reg_starttry
#define PL_Treg_sv PL_reg_sv
+#define PL_Treg_sv_utf8 PL_reg_sv_utf8
#define PL_Treg_whilem_seen PL_reg_whilem_seen
#define PL_Tregbol PL_regbol
#define PL_Tregcc PL_regcc
else /* @- */
i = s;
- if (i > 0 && DO_UTF8(PL_reg_sv)) {
+ if (i > 0 && PL_reg_sv_utf8) {
char *b = rx->subbeg;
if (b)
i = Perl_utf8_length(aTHX_ (U8*)b, (U8*)(b+i));
{
i = t1 - s1;
getlen:
- if (i > 0 && DO_UTF8(PL_reg_sv)) {
+ if (i > 0 && PL_reg_sv_utf8) {
char *s = rx->subbeg + s1;
char *send = rx->subbeg + t1;
PL_tainted = FALSE;
}
sv_setpvn(sv, s, i);
- if (PL_reg_sv && DO_UTF8(PL_reg_sv) && is_utf8_string((U8*)s, i))
+ if (PL_reg_sv_utf8 && is_utf8_string((U8*)s, i))
SvUTF8_on(sv);
else
SvUTF8_off(sv);
#define PL_reg_starttry (*Perl_Treg_starttry_ptr(aTHXo))
#undef PL_reg_sv
#define PL_reg_sv (*Perl_Treg_sv_ptr(aTHXo))
+#undef PL_reg_sv_utf8
+#define PL_reg_sv_utf8 (*Perl_Treg_sv_utf8_ptr(aTHXo))
#undef PL_reg_whilem_seen
#define PL_reg_whilem_seen (*Perl_Treg_whilem_seen_ptr(aTHXo))
#undef PL_regbol
Shuts down a Perl interpreter. See L<perlembed>.
- void perl_destruct(PerlInterpreter* interp)
+ int perl_destruct(PerlInterpreter* interp)
=for hackers
Found in file perl.c
TAINT_IF((pm->op_pmflags & PMf_LOCALE) &&
(pm->op_pmflags & (PMf_WHITE | PMf_SKIPWHITE)));
+ PL_reg_sv_utf8 = do_utf8;
+
if (pm->op_pmreplroot) {
#ifdef USE_ITHREADS
ary = GvAVn((GV*)PL_curpad[(PADOFFSET)pm->op_pmreplroot]);
TARG = DEFSV;
EXTEND(SP,1);
}
- PL_reg_sv = TARG;
+
PUTBACK; /* EVAL blocks need stack_sp. */
s = SvPV(TARG, len);
strend = s + len;
(PL_tainted && (pm->op_pmflags & PMf_RETAINT)));
TAINT_NOT;
+ PL_reg_sv_utf8 = DO_UTF8(TARG);
+
if (pm->op_pmdynflags & PMdf_USED) {
failure:
if (gimme == G_ARRAY)
if (global) {
rx->subbeg = truebase;
rx->startp[0] = s - truebase;
- if (DO_UTF8(PL_reg_sv)) {
+ if (PL_reg_sv_utf8) {
char *t = (char*)utf8_hop((U8*)s, rx->minlen);
rx->endp[0] = t - truebase;
}
STRLEN len;
int force_on_match = 0;
I32 oldsave = PL_savestack_ix;
- bool do_utf8;
STRLEN slen;
/* known replacement string? */
TARG = DEFSV;
EXTEND(SP,1);
}
- PL_reg_sv = TARG;
- do_utf8 = DO_UTF8(PL_reg_sv);
+
if (SvFAKE(TARG) && SvREADONLY(TARG))
sv_force_normal(TARG);
if (SvREADONLY(TARG)
rxtainted |= 2;
TAINT_NOT;
+ PL_reg_sv_utf8 = DO_UTF8(TARG);
+
force_it:
if (!pm || !s)
DIE(aTHX_ "panic: pp_subst");
strend = s + len;
- slen = do_utf8 ? utf8_length((U8*)s, (U8*)strend) : len;
+ slen = PL_reg_sv_utf8 ? utf8_length((U8*)s, (U8*)strend) : len;
maxiters = 2 * slen + 10; /* We can match twice at each
position, once with zero-length,
second time with non-zero. */
SAVEVPTR(PL_reg_re); /* from regexec.c */
SAVEPPTR(PL_reg_ganch); /* from regexec.c */
SAVESPTR(PL_reg_sv); /* from regexec.c */
+ SAVEI32(PL_reg_sv_utf8); /* from regexec.c */
SAVEVPTR(PL_reg_magic); /* from regexec.c */
SAVEI32(PL_reg_oldpos); /* from regexec.c */
SAVEVPTR(PL_reg_oldcurpm); /* from regexec.c */
*/
#define CHR_SVLEN(sv) (UTF ? sv_len_utf8(sv) : SvCUR(sv))
-#define CHR_DIST(a,b) (DO_UTF8(PL_reg_sv) ? utf8_distance(a,b) : a - b)
+#define CHR_DIST(a,b) (PL_reg_sv_utf8 ? utf8_distance(a,b) : a - b)
#define reghop_c(pos,off) ((char*)reghop((U8*)pos, off))
#define reghopmaybe_c(pos,off) ((char*)reghopmaybe((U8*)pos, off))
-#define HOP(pos,off) (DO_UTF8(PL_reg_sv) ? reghop((U8*)pos, off) : (U8*)(pos + off))
-#define HOPMAYBE(pos,off) (DO_UTF8(PL_reg_sv) ? reghopmaybe((U8*)pos, off) : (U8*)(pos + off))
+#define HOP(pos,off) (PL_reg_sv_utf8 ? reghop((U8*)pos, off) : (U8*)(pos + off))
+#define HOPMAYBE(pos,off) (PL_reg_sv_utf8 ? reghopmaybe((U8*)pos, off) : (U8*)(pos + off))
#define HOPc(pos,off) ((char*)HOP(pos,off))
#define HOPMAYBEc(pos,off) ((char*)HOPMAYBE(pos,off))
#define HOPBACK(pos, off) ( \
- (UTF && DO_UTF8(PL_reg_sv)) \
+ (UTF && PL_reg_sv_utf8) \
? reghopmaybe((U8*)pos, -off) \
: (pos - off >= PL_bostr) \
? (U8*)(pos - off) \
#define reghop3_c(pos,off,lim) ((char*)reghop3((U8*)pos, off, (U8*)lim))
#define reghopmaybe3_c(pos,off,lim) ((char*)reghopmaybe3((U8*)pos, off, (U8*)lim))
-#define HOP3(pos,off,lim) (DO_UTF8(PL_reg_sv) ? reghop3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
-#define HOPMAYBE3(pos,off,lim) (DO_UTF8(PL_reg_sv) ? reghopmaybe3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
+#define HOP3(pos,off,lim) (PL_reg_sv_utf8 ? reghop3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
+#define HOPMAYBE3(pos,off,lim) (PL_reg_sv_utf8 ? reghopmaybe3((U8*)pos, off, (U8*)lim) : (U8*)(pos + off))
#define HOP3c(pos,off,lim) ((char*)HOP3(pos,off,lim))
#define HOPMAYBE3c(pos,off,lim) ((char*)HOPMAYBE3(pos,off,lim))
unsigned int c2;
char *e;
register I32 tmp = 1; /* Scratch variable? */
- register bool do_utf8 = DO_UTF8(PL_reg_sv);
+ register bool do_utf8 = PL_reg_sv_utf8;
/* We know what class it must start with. */
switch (OP(c)) {
#if 0
I32 firstcp = PL_savestack_ix;
#endif
- register bool do_utf8 = DO_UTF8(PL_reg_sv);
+ register bool do_utf8 = PL_reg_sv_utf8;
#ifdef DEBUGGING
PL_regindent++;
register I32 c;
register char *loceol = PL_regeol;
register I32 hardcount = 0;
- register bool do_utf8 = DO_UTF8(PL_reg_sv);
+ register bool do_utf8 = PL_reg_sv_utf8;
scan = PL_reginput;
if (max != REG_INFTY && max < loceol - scan)
return 0;
start = PL_reginput;
- if (DO_UTF8(PL_reg_sv)) {
+ if (PL_reg_sv_utf8) {
while (PL_reginput < loceol && (scan = PL_reginput, res = regmatch(p))) {
if (!count++) {
l = 0;
PL_reg_re = (regexp*)NULL;
PL_reg_ganch = Nullch;
PL_reg_sv = Nullsv;
+ PL_reg_sv_utf8 = FALSE;
PL_reg_magic = (MAGIC*)NULL;
PL_reg_oldpos = 0;
PL_reg_oldcurpm = (PMOP*)NULL;
$| = 1;
-print "1..684\n";
+print "1..686\n";
BEGIN {
chdir 't' if -d 't';
$c = pos;
print "$a $b $c" eq 'ba:ba ad:ae 10' ? "ok 684\n" : "not ok 684\t# $a $b $c\n";
}
+
+{
+ package ID_20010407_006;
+
+ sub x {
+ "a\x{1234}";
+ }
+
+ my $x = x;
+ my $y;
+
+ $x =~ /(..)/; $y = $1;
+ print "not " unless length($y) == 2 && $y eq $x;
+ print "ok 685\n" if length($y) == 2;
+
+ x =~ /(..)/; $y = $1;
+ print "not " unless length($y) == 2 && $y eq $x;
+ print "ok 686\n";
+}
PERLVAR(trailing_nul, char) /* For the sake of thrsv and oursv */
PERLVAR(thr_done, bool) /* True when the thread has finished */
+
#endif /* USE_THREADS */
+
+PERLVAR(Treg_sv_utf8, bool) /* was what we matched against utf8 */
+