aboutsummaryrefslogtreecommitdiffstats
path: root/regex.c
diff options
context:
space:
mode:
Diffstat (limited to 'regex.c')
-rw-r--r--regex.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/regex.c b/regex.c
index 28686ee..e926872 100644
--- a/regex.c
+++ b/regex.c
@@ -210,6 +210,7 @@ regmatch(regexchar * re, char *str, int len, int firstp, char **lastpos)
char *lpos, *llpos = NULL;
longchar k;
+ *lastpos = NULL;
#ifdef REGEX_DEBUG
debugre(re, str);
#endif /* REGEX_DEBUG */
@@ -220,21 +221,16 @@ regmatch(regexchar * re, char *str, int len, int firstp, char **lastpos)
re++;
}
else if (re->mode & RE_ANYTIME) {
- short matched = 0, ok = 0;
- do {
+ short matched, ok = 0;
+ for (;;) {
+ matched = 0;
if (regmatch(re + 1, p, ep - p, firstp, &lpos) == 1) {
llpos = lpos;
matched = 1;
- }
- else if (matched) {
ok = 1;
- break;
}
- if (p >= ep) {
- if (matched)
- ok = 1;
+ if (p >= ep)
break;
- }
#ifdef JP_CHARSET
if (IS_KANJI1(*p)) {
k = RE_KANJI(p);
@@ -243,8 +239,6 @@ regmatch(regexchar * re, char *str, int len, int firstp, char **lastpos)
*lastpos = llpos;
p += 2;
}
- else if (matched)
- ok = 1;
else
break;
}
@@ -257,12 +251,10 @@ regmatch(regexchar * re, char *str, int len, int firstp, char **lastpos)
if (lastpos != NULL)
*lastpos = llpos;
}
- else if (matched)
- ok = 1;
else
- break;
+ break;
}
- } while (!ok);
+ }
if (lastpos != NULL)
*lastpos = llpos;
return ok;