AV *ary;
register I32 limit = POPi; /* note, negative is forever */
SV *sv = POPs;
- bool isutf = DO_UTF8(sv);
+ bool doutf8 = DO_UTF8(sv);
STRLEN len;
register char *s = SvPV(sv, len);
char *strend = s + len;
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
- if (isutf)
+ if (doutf8)
(void)SvUTF8_on(dstr);
XPUSHs(dstr);
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
- if (isutf)
+ if (doutf8)
(void)SvUTF8_on(dstr);
XPUSHs(dstr);
s = m;
&& !(rx->reganch & ROPT_ANCH)) {
int tail = (rx->reganch & RE_INTUIT_TAIL);
SV *csv = CALLREG_INTUIT_STRING(aTHX_ rx);
- char c;
len = rx->minlen;
if (len == 1 && !tail) {
- c = *SvPV(csv,len);
+ STRLEN n_a;
+ char c = *SvPV(csv, n_a);
while (--limit) {
/*SUPPRESS 530*/
for (m = s; m < strend && *m != c; m++) ;
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
- if (isutf)
+ if (doutf8)
(void)SvUTF8_on(dstr);
XPUSHs(dstr);
- s = m + 1;
+ /* The rx->minlen is in characters but we want to step
+ * s ahead by bytes. */
+ s = m + (doutf8 ? SvCUR(csv) : len);
}
}
else {
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
- if (isutf)
+ if (doutf8)
(void)SvUTF8_on(dstr);
XPUSHs(dstr);
- s = m + len; /* Fake \n at the end */
+ /* The rx->minlen is in characters but we want to step
+ * s ahead by bytes. */
+ s = m + (doutf8 ? SvCUR(csv) : len); /* Fake \n at the end */
}
}
}
sv_setpvn(dstr, s, m-s);
if (make_mortal)
sv_2mortal(dstr);
- if (isutf)
+ if (doutf8)
(void)SvUTF8_on(dstr);
XPUSHs(dstr);
if (rx->nparens) {
dstr = NEWSV(33, 0);
if (make_mortal)
sv_2mortal(dstr);
- if (isutf)
+ if (doutf8)
(void)SvUTF8_on(dstr);
XPUSHs(dstr);
}
/* keep field after final delim? */
if (s < strend || (iters && origlimit)) {
- dstr = NEWSV(34, strend-s);
- sv_setpvn(dstr, s, strend-s);
+ STRLEN l = strend - s;
+ dstr = NEWSV(34, l);
+ sv_setpvn(dstr, s, l);
if (make_mortal)
sv_2mortal(dstr);
- if (isutf)
+ if (doutf8)
(void)SvUTF8_on(dstr);
XPUSHs(dstr);
iters++;
}
}
-print "1..82\n";
+print "1..87\n";
my $test = 1;
print "ok $test\n";
$test++;
}
+
+{
+ # bug id 20000426.003
+
+ use utf8;
+
+ my $s = "\x20\x40\x{80}\x{100}\x{80}\x40\x20";
+
+ my ($a, $b, $c) = split(/\x40/, $s);
+ print "not "
+ unless $a eq "\x20" && $b eq "\x{80}\x{100}\x{80}" && $c eq $a;
+ print "ok $test\n";
+ $test++;
+
+ my ($a, $b) = split(/\x{100}/, $s);
+ print "not " unless $a eq "\x20\x40\x{80}" && $b eq "\x{80}\x40\x20";
+ print "ok $test\n";
+ $test++;
+
+ my ($a, $b) = split(/\x{80}\x{100}\x{80}/, $s);
+ print "not " unless $a eq "\x20\x40" && $b eq "\x40\x20";
+ print "ok $test\n";
+ $test++;
+
+ my ($a, $b) = split(/\x40\x{80}/, $s);
+ print "not " unless $a eq "\x20" && $b eq "\x{100}\x{80}\x40\x20";
+ print "ok $test\n";
+ $test++;
+
+ my ($a, $b, $c) = split(/[\x40\x{80}]+/, $s);
+ print "not " unless $a eq "\x20" && $b eq "\x{100}" && $c eq "\x20";
+ print "ok $test\n";
+ $test++;
+}