diff options
-rw-r--r-- | jimregexp.c | 11 | ||||
-rw-r--r-- | jimregexp.h | 1 | ||||
-rw-r--r-- | tests/regcount.test | 3 |
3 files changed, 8 insertions, 7 deletions
diff --git a/jimregexp.c b/jimregexp.c index f67031b..8da9347 100644 --- a/jimregexp.c +++ b/jimregexp.c @@ -455,6 +455,11 @@ static int *regpiece(regex_t *preg, int *flagp) return(ret); } + if (!(flags&HASWIDTH) && op != '?') { + preg->err = REG_ERR_OPERAND_COULD_BE_EMPTY; + return NULL; + } + /* Handle braces (counted repetition) by expansion */ if (op == '{') { char *end; @@ -1290,11 +1295,7 @@ static int regmatchrepeat(regex_t *preg, int *scan, int matchmin) int max = scan[2]; int min = scan[3]; - if (preg->reginput == preg->prev) { - /* If we haven't moved, no match */ - return 0; - } - preg->prev = save = preg->reginput; + save = preg->reginput; /* Have we reached min? */ if (scan[4] < min) { diff --git a/jimregexp.h b/jimregexp.h index f4f420b..5d7dc94 100644 --- a/jimregexp.h +++ b/jimregexp.h @@ -66,7 +66,6 @@ typedef struct regexp { const char *start; /* Initial string pointer. */ const char *reginput; /* Current input pointer. */ const char *regbol; /* Beginning of input, for ^ check. */ - const char *prev; /* Ensure we don't try to match nothing more than once */ /* Input to regexec() */ regmatch_t *pmatch; /* submatches will be stored here */ diff --git a/tests/regcount.test b/tests/regcount.test index e359389..6b05686 100644 --- a/tests/regcount.test +++ b/tests/regcount.test @@ -92,8 +92,9 @@ foreach {pat str exp} { {ab*c} xnbbmbbbc {} {.^xxx} yyy {} {\mb} " abc " "" - ((a*)*b)*b aaaaaaaaaaaaaaaaaaaaaaaaab {b {} {}} + ####((a*)*b)*b aaaaaaaaaaaaaaaaaaaaaaaaab {b {} {}} ####(a*)* aab {aa {}} + {^([^:=]*)(:)?(=)?$} version {version version {} {}} } { if {[string match #* $pat]} { continue |