register I32 paren;
register I32 i;
register REGEXP *rx;
+ I32 s1, t1;
switch (*mg->mg_ptr) {
case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9': case '&':
if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
- I32 s1, t1;
paren = atoi(mg->mg_ptr);
getparen:
(t1 = rx->endp[paren]) != -1)
{
i = t1 - s1;
+ getlen:
+ if (i > 0 && (PL_curpm->op_pmdynflags & PMdf_UTF8) && !IN_BYTE) {
+ char *s = rx->subbeg + s1;
+ char *send = rx->subbeg + t1;
+ i = 0;
+ while (s < send) {
+ s += UTF8SKIP(s);
+ i++;
+ }
+ }
if (i >= 0)
return i;
}
if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
if (rx->startp[0] != -1) {
i = rx->startp[0];
- if (i >= 0)
- return i;
+ if (i > 0) {
+ s1 = 0;
+ t1 = i;
+ goto getlen;
+ }
}
}
return 0;
if (PL_curpm && (rx = PL_curpm->op_pmregexp)) {
if (rx->endp[0] != -1) {
i = rx->sublen - rx->endp[0];
- if (i >= 0)
- return i;
+ if (i > 0) {
+ s1 = rx->endp[0];
+ t1 = rx->sublen;
+ goto getlen;
+ }
}
}
return 0;
}
}
-print "1..12\n";
+print "1..60\n";
my $test = 1;
ok $1, '123alpha';
$test++;
}
+{
+ use utf8;
+
+ $_ = "\x{263A}>\x{263A}\x{263A}";
+
+ ok length, 4;
+ $test++;
+
+ ok length((m/>(.)/)[0]), 1;
+ $test++;
+
+ ok length($&), 2;
+ $test++;
+
+ ok length($'), 1;
+ $test++;
+
+ ok length($`), 1;
+ $test++;
+
+ ok length($1), 1;
+ $test++;
+
+ ok length($tmp=$&), 2;
+ $test++;
+
+ ok length($tmp=$'), 1;
+ $test++;
+
+ ok length($tmp=$`), 1;
+ $test++;
+
+ ok length($tmp=$1), 1;
+ $test++;
+
+ ok $&, pack("C*", ord(">"), 0342, 0230, 0272);
+ $test++;
+
+ ok $', pack("C*", 0342, 0230, 0272);
+ $test++;
+
+ ok $`, pack("C*", 0342, 0230, 0272);
+ $test++;
+
+ ok $1, pack("C*", 0342, 0230, 0272);
+ $test++;
+
+ {
+ use bytes;
+ no utf8;
+
+ ok length, 10;
+ $test++;
+
+ ok length((m/>(.)/)[0]), 1;
+ $test++;
+
+ ok length($&), 2;
+ $test++;
+
+ ok length($'), 5;
+ $test++;
+
+ ok length($`), 3;
+ $test++;
+
+ ok length($1), 1;
+ $test++;
+
+ ok $&, pack("C*", ord(">"), 0342);
+ $test++;
+
+ ok $', pack("C*", 0230, 0272, 0342, 0230, 0272);
+ $test++;
+
+ ok $`, pack("C*", 0342, 0230, 0272);
+ $test++;
+
+ ok $1, pack("C*", 0342);
+ $test++;
+
+ }
+
+
+ {
+ no utf8;
+ $_="\342\230\272>\342\230\272\342\230\272";
+ }
+
+ ok length, 10;
+ $test++;
+
+ ok length((m/>(.)/)[0]), 1;
+ $test++;
+
+ ok length($&), 2;
+ $test++;
+
+ ok length($'), 1;
+ $test++;
+
+ ok length($`), 1;
+ $test++;
+
+ ok length($1), 1;
+ $test++;
+
+ ok length($tmp=$&), 2;
+ $test++;
+
+ ok length($tmp=$'), 1;
+ $test++;
+
+ ok length($tmp=$`), 1;
+ $test++;
+
+ ok length($tmp=$1), 1;
+ $test++;
+
+ ok $&, pack("C*", ord(">"), 0342, 0230, 0272);
+ $test++;
+
+ ok $', pack("C*", 0342, 0230, 0272);
+ $test++;
+
+ ok $`, pack("C*", 0342, 0230, 0272);
+ $test++;
+
+ ok $1, pack("C*", 0342, 0230, 0272);
+ $test++;
+
+ {
+ use bytes;
+ no utf8;
+
+ ok length, 10;
+ $test++;
+
+ ok length((m/>(.)/)[0]), 1;
+ $test++;
+
+ ok length($&), 2;
+ $test++;
+
+ ok length($'), 5;
+ $test++;
+
+ ok length($`), 3;
+ $test++;
+
+ ok length($1), 1;
+ $test++;
+
+ ok $&, pack("C*", ord(">"), 0342);
+ $test++;
+
+ ok $', pack("C*", 0230, 0272, 0342, 0230, 0272);
+ $test++;
+
+ ok $`, pack("C*", 0342, 0230, 0272);
+ $test++;
+
+ ok $1, pack("C*", 0342);
+ $test++;
+
+ }
+}