diff options
author | Steve Bennett <steveb@workware.net.au> | 2022-12-03 11:15:02 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2022-12-03 11:18:01 +1000 |
commit | c9f2fdaede9414e65f4c19174b0c4e8244830e28 (patch) | |
tree | 522ef8da25b79dd2b64385704b452e2ebe6853ff | |
parent | 7bc75b1a8a3b6f8fadd8a45c7e7e2f1b2473a5b6 (diff) | |
download | jimtcl-c9f2fdaede9414e65f4c19174b0c4e8244830e28.zip jimtcl-c9f2fdaede9414e65f4c19174b0c4e8244830e28.tar.gz jimtcl-c9f2fdaede9414e65f4c19174b0c4e8244830e28.tar.bz2 |
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 <steveb@workware.net.au>
-rw-r--r-- | jimregexp.c | 2 | ||||
-rw-r--r-- | tests/regexp2.test | 4 |
2 files changed, 5 insertions, 1 deletions
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 |