about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorFabrice Bellard <fabrice@bellard.org>2024-05-30 16:41:37 +0200
committerbptato <nincsnevem662@gmail.com>2024-05-30 18:55:56 +0200
commit76fb1173641abd7f1b2ada2e346ef0c426663256 (patch)
tree40ea5eed22d84a96660ac75aa7098aa028067004
parent5b52f020c29fe790de9bf469de1d048b787fe87b (diff)
downloadchawan-76fb1173641abd7f1b2ada2e346ef0c426663256.tar.gz
regexp: fix non greedy quantizers with zero length matches
-rw-r--r--lib/quickjs/libregexp.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/quickjs/libregexp.c b/lib/quickjs/libregexp.c
index 8d087ae3..e5693e1b 100644
--- a/lib/quickjs/libregexp.c
+++ b/lib/quickjs/libregexp.c
@@ -1488,15 +1488,13 @@ static int re_parse_term(REParseState *s, BOOL is_backward_dir)
 
                 if (dbuf_error(&s->byte_code))
                     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;