From: Stefan Monnier Date: Sat, 25 Nov 2023 16:03:08 +0000 (-0500) Subject: regex-emacs.c (forall_firstchar): Fix regression bug#67226 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=82bba6713fc9d5c7cc24c182236df4f16545e941;p=emacs.git regex-emacs.c (forall_firstchar): Fix regression bug#67226 All zero-width operations need to be taken into account when reaching `succeed` in `mutually_exclusive_one`! * src/regex-emacs.c (forall_firstchar_1): Call `f` for all zero-width matching operators. (analyze_first_fastmap, analyze_first_null, mutually_exclusive_one): Adjust accordingly. --- diff --git a/src/regex-emacs.c b/src/regex-emacs.c index 95c3366652d..cb4fbd58faa 100644 --- a/src/regex-emacs.c +++ b/src/regex-emacs.c @@ -2857,6 +2857,9 @@ forall_firstchar_1 (re_char *p, re_char *pend, else switch (*p) { + case no_op: + p++; continue; + /* Cases which stop the iteration. */ case succeed: case exactn: @@ -2872,15 +2875,9 @@ forall_firstchar_1 (re_char *p, re_char *pend, /* Cases which may match the empty string. */ case at_dot: case begbuf: - case no_op: case wordbound: case notwordbound: case begline: - p++; - continue; - - /* Cases which may match the empty string and may - tell us something about the next char. */ case endline: case endbuf: case wordbeg: @@ -3201,6 +3198,11 @@ analyze_first_fastmap (const re_char *p, void *arg) } return true; + case at_dot: + case begbuf: + case wordbound: + case notwordbound: + case begline: case endline: case endbuf: case wordbeg: @@ -3244,6 +3246,11 @@ analyze_first_null (const re_char *p, void *arg) case notcategoryspec: return true; + case at_dot: + case begbuf: + case wordbound: + case notwordbound: + case begline: case endline: case endbuf: case wordbeg: @@ -3983,6 +3990,13 @@ mutually_exclusive_one (re_char *p2, void *arg) RETURN_CONSTRAIN (*data->p1 == syntaxspec && (data->p1[1] == Ssymbol || data->p1[1] == Sword)); + case at_dot: + case begbuf: + case wordbound: + case notwordbound: + case begline: + RETURN_CONSTRAIN (false); + case duplicate: /* At this point, we know nothing about what this can match, sadly. */ return false;