diff --git a/pike.c b/pike.c index 3d689b3..f2d7693 100644 --- a/pike.c +++ b/pike.c @@ -298,6 +298,10 @@ static int compilecode(const char *re_loc, rcode *prog, int sizecode) memcpy(&code[PC], &code[term], size*sizeof(int)); PC += size; } + if (!mincnt) { + nojmp = 2; + mincnt++; + } for (i = maxcnt-mincnt; i > 0; i--) { EMIT(PC++, SPLIT); EMIT(PC++, REL(PC, PC+((size+2)*i))); @@ -305,10 +309,8 @@ static int compilecode(const char *re_loc, rcode *prog, int sizecode) memcpy(&code[PC], &code[term], size*sizeof(int)); PC += size; } - if (!mincnt && maxcnt) { - nojmp = 1; + if (nojmp == 2) goto zcase; - } break; case '?': if (PC == term) diff --git a/test.sh b/test.sh index 2432ea0..1aa69a8 100755 --- a/test.sh +++ b/test.sh @@ -1,6 +1,7 @@ #!/bin/sh regex="\ +(aaaa){0,2} a{0} (aaaa){0,} (aaaa){0,0} @@ -209,6 +210,7 @@ aaaaa(aa)aa(aa(a)a)?aa (((?:(?:(?:ffffff(a)?ffff)+)+?)*)*)+ " input="\ +aaaaaaaaaaaa aaaaaaaaaa aaaaaaaaaa aaaaaaaaaa @@ -417,6 +419,7 @@ fffffaffffffffff fffffffffffffffffffffffff " expect="\ +(0,8)(4,8) (0,0) (0,8)(4,8) (0,0)(?,?)