mirror of
https://github.com/bellard/quickjs.git
synced 2024-11-27 08:08:12 +08:00
regexp: fix non greedy quantizers with zero length matches
This commit is contained in:
parent
d86aaf0b8f
commit
36911f0d3a
14
libregexp.c
14
libregexp.c
@ -1488,15 +1488,13 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
|
|||||||
|
|
||||||
if (dbuf_error(&s->byte_code))
|
if (dbuf_error(&s->byte_code))
|
||||||
goto out_of_memory;
|
goto out_of_memory;
|
||||||
/* the spec tells that if there is no advance when
|
|
||||||
running the atom after the first quant_min times,
|
|
||||||
then there is no match. We remove this test when we
|
|
||||||
are sure the atom always advances the position. */
|
|
||||||
add_zero_advance_check = re_need_check_advance(s->byte_code.buf + last_atom_start,
|
|
||||||
s->byte_code.size - last_atom_start);
|
|
||||||
} else {
|
|
||||||
add_zero_advance_check = FALSE;
|
|
||||||
}
|
}
|
||||||
|
/* the spec tells that if there is no advance when
|
||||||
|
running the atom after the first quant_min times,
|
||||||
|
then there is no match. We remove this test when we
|
||||||
|
are sure the atom always advances the position. */
|
||||||
|
add_zero_advance_check = re_need_check_advance(s->byte_code.buf + last_atom_start,
|
||||||
|
s->byte_code.size - last_atom_start);
|
||||||
|
|
||||||
{
|
{
|
||||||
int len, pos;
|
int len, pos;
|
||||||
|
@ -678,6 +678,8 @@ function test_regexp()
|
|||||||
assert(a, ["a", undefined]);
|
assert(a, ["a", undefined]);
|
||||||
a = /(?:|[\w])+([0-9])/.exec("123a23");
|
a = /(?:|[\w])+([0-9])/.exec("123a23");
|
||||||
assert(a, ["123a23", "3"]);
|
assert(a, ["123a23", "3"]);
|
||||||
|
a = /()*?a/.exec(",");
|
||||||
|
assert(a, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_symbol()
|
function test_symbol()
|
||||||
|
Loading…
Reference in New Issue
Block a user