summaryrefslogtreecommitdiff
path: root/regexec.c
diff options
context:
space:
mode:
authorJarkko Hietaniemi <jhi@iki.fi>2002-04-01 02:17:50 +0000
committerJarkko Hietaniemi <jhi@iki.fi>2002-04-01 02:17:50 +0000
commitb2f2f093d7e1865d949bed11ba0faa613aba5701 (patch)
treeb05d5cd8cf6fd2d394654a9bdf60a705883d4b3a /regexec.c
parent50a63b21cf78090f08412144f4af089922f60e2d (diff)
downloadperl-b2f2f093d7e1865d949bed11ba0faa613aba5701.tar.gz
Regex fix from Hugo: in UTF-8 locales the character
counting code didn't work right for minimal matches. p4raw-id: //depot/perl@15645
Diffstat (limited to 'regexec.c')
-rw-r--r--regexec.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/regexec.c b/regexec.c
index f2d4b3dfa4..be4b362349 100644
--- a/regexec.c
+++ b/regexec.c
@@ -3568,6 +3568,7 @@ S_regmatch(pTHX_ regnode *prog)
if (c1 != -1000) {
char *e; /* Should not check after this */
char *old = locinput;
+ int count = 0;
if (n == REG_INFTY) {
e = PL_regeol - 1;
@@ -3587,7 +3588,6 @@ S_regmatch(pTHX_ regnode *prog)
e = PL_regeol - 1;
}
while (1) {
- int count;
/* Find place 'next' could work */
if (!do_utf8) {
if (c1 == c2) {
@@ -3605,18 +3605,20 @@ S_regmatch(pTHX_ regnode *prog)
else {
STRLEN len;
if (c1 == c2) {
- for (count = 0;
- locinput <= e &&
- utf8_to_uvchr((U8*)locinput, &len) != c1;
- count++)
+ /* count initialised to 0 or 1 */
+ while (locinput <= e &&
+ utf8_to_uvchr((U8*)locinput, &len) != c1) {
locinput += len;
-
+ count++;
+ }
} else {
- for (count = 0; locinput <= e; count++) {
+ /* count initialised to 0 or 1 */
+ while (locinput <= e) {
UV c = utf8_to_uvchr((U8*)locinput, &len);
if (c == c1 || c == c2)
break;
- locinput += len;
+ locinput += len;
+ count++;
}
}
}
@@ -3638,6 +3640,7 @@ S_regmatch(pTHX_ regnode *prog)
locinput += UTF8SKIP(locinput);
else
locinput++;
+ count = 1;
}
}
else