pike.c: fix edge case
This commit is contained in:
8
pike.c
8
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));
|
memcpy(&code[PC], &code[term], size*sizeof(int));
|
||||||
PC += size;
|
PC += size;
|
||||||
}
|
}
|
||||||
|
if (!mincnt) {
|
||||||
|
nojmp = 2;
|
||||||
|
mincnt++;
|
||||||
|
}
|
||||||
for (i = maxcnt-mincnt; i > 0; i--) {
|
for (i = maxcnt-mincnt; i > 0; i--) {
|
||||||
EMIT(PC++, SPLIT);
|
EMIT(PC++, SPLIT);
|
||||||
EMIT(PC++, REL(PC, PC+((size+2)*i)));
|
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));
|
memcpy(&code[PC], &code[term], size*sizeof(int));
|
||||||
PC += size;
|
PC += size;
|
||||||
}
|
}
|
||||||
if (!mincnt && maxcnt) {
|
if (nojmp == 2)
|
||||||
nojmp = 1;
|
|
||||||
goto zcase;
|
goto zcase;
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case '?':
|
case '?':
|
||||||
if (PC == term)
|
if (PC == term)
|
||||||
|
|||||||
3
test.sh
3
test.sh
@@ -1,6 +1,7 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
regex="\
|
regex="\
|
||||||
|
(aaaa){0,2}
|
||||||
a{0}
|
a{0}
|
||||||
(aaaa){0,}
|
(aaaa){0,}
|
||||||
(aaaa){0,0}
|
(aaaa){0,0}
|
||||||
@@ -209,6 +210,7 @@ aaaaa(aa)aa(aa(a)a)?aa
|
|||||||
(((?:(?:(?:ffffff(a)?ffff)+)+?)*)*)+
|
(((?:(?:(?:ffffff(a)?ffff)+)+?)*)*)+
|
||||||
"
|
"
|
||||||
input="\
|
input="\
|
||||||
|
aaaaaaaaaaaa
|
||||||
aaaaaaaaaa
|
aaaaaaaaaa
|
||||||
aaaaaaaaaa
|
aaaaaaaaaa
|
||||||
aaaaaaaaaa
|
aaaaaaaaaa
|
||||||
@@ -417,6 +419,7 @@ fffffaffffffffff
|
|||||||
fffffffffffffffffffffffff
|
fffffffffffffffffffffffff
|
||||||
"
|
"
|
||||||
expect="\
|
expect="\
|
||||||
|
(0,8)(4,8)
|
||||||
(0,0)
|
(0,0)
|
||||||
(0,8)(4,8)
|
(0,8)(4,8)
|
||||||
(0,0)(?,?)
|
(0,0)(?,?)
|
||||||
|
|||||||
Reference in New Issue
Block a user