From c9f2fdaede9414e65f4c19174b0c4e8244830e28 Mon Sep 17 00:00:00 2001 From: Steve Bennett Date: Sat, 3 Dec 2022 11:15:02 +1000 Subject: regexp: fix end of word check The end of word check was wrong and return true when it should not. Fixes #246 Signed-off-by: Steve Bennett --- jimregexp.c | 2 +- tests/regexp2.test | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/jimregexp.c b/jimregexp.c index e66fabe..49c04af 100644 --- a/jimregexp.c +++ b/jimregexp.c @@ -1499,7 +1499,7 @@ static int regmatch(regex_t *preg, int prog) /* Can't match at BOL */ if (preg->reginput > preg->regbol) { /* Current must be EOL or nonword */ - if (reg_iseol(preg, c) || !isalnum(UCHAR(c)) || c != '_') { + if (reg_iseol(preg, c) || !(isalnum(UCHAR(c)) || c == '_')) { c = preg->reginput[-1]; /* Previous must be word */ if (isalnum(UCHAR(c)) || c == '_') { diff --git a/tests/regexp2.test b/tests/regexp2.test index 9b6cdcf..156454f 100644 --- a/tests/regexp2.test +++ b/tests/regexp2.test @@ -940,4 +940,8 @@ test regexp-25.2 {Single braced count} { regexp "a{4}" baaaad } 1 +test regexp-25.3 {End of word} { + regexp {\mcd\M} cdef +} 0 + testreport -- cgit v1.1