From: NeilBrown Date: Sun, 27 Aug 2023 00:18:50 +0000 (+1000) Subject: rexel: fix return value in one case. X-Git-Url: http://git.neil.brown.name/?a=commitdiff_plain;h=92e51b89ca280c65b052f4849d5b5660ef4b39fe;p=edlib.git rexel: fix return value in one case. If both a flag and the char match, we currently report just that the flag matched, which is wrong and results in lib-search thinking the match ended before it really did based on reported length. Signed-off-by: NeilBrown --- diff --git a/DOC/TODO.md b/DOC/TODO.md index b78379f2..a7b7620c 100644 --- a/DOC/TODO.md +++ b/DOC/TODO.md @@ -252,6 +252,7 @@ Module features - [ ] move to separate git repo and document well. - [ ] review return code of rxl_advance(). What should be returned if a flag allowed a match, but the char didn't. +- [ ] add self-tests which ensure that the return value is correct. - [ ] support backward search by compiling expression backwards - [ ] make prefix-fast-search work for case-insensitive matches?? - [ ] rexel term for "expression" with balanced brackets. diff --git a/rexel.c b/rexel.c index 90134c10..be492a57 100644 --- a/rexel.c +++ b/rexel.c @@ -843,6 +843,9 @@ enum rxl_found rxl_advance(struct match_state *st safe, wint_t ch) printf(" ... -> NOMATCH\n"); } #endif + /* 'ret' is the result of an flags, or RXL_NOMATCH. */ + if (ret >= RXL_MATCH && !flag && st->match >= 0) + return RXL_MATCH; if (ret >= RXL_MATCH_FLAG || (st->match >= 0 && flag)) return RXL_MATCH_FLAG; if (ret >= RXL_MATCH || st->match >= 0) diff --git a/tests.d/00-basic b/tests.d/00-basic index 0d0d0968..2c0e1091 100644 --- a/tests.d/00-basic +++ b/tests.d/00-basic @@ -721,11 +721,11 @@ Display 80,30 CF36D321FC2E8BBF753727F50A4462D5 34,0 Display 80,30 73141BC1B00150904D453A43CC32F667 34,0 Key ":C-S" Display 80,30 F4380BB2A1A540A385B373BB04B0DE14 34,0 -Display 80,30 DC891DB9A031F49837FC8F35941B52F6 34,0 +Display 80,30 DEC7E7D22971E6B081CE947B050B73F7 34,0 Key ":Enter" Display 80,30 29F3151EB6D0ED1BF8BC637E0E8F41CB 1,3 Key ":C-X" Display 80,30 6C71927B10030D3ABC828BF38CF37799 1,3 Key ":C-C" Display 80,30 39B814F1E8577AAD3DF0FAE0D5E0B412 21,8 -Close 1965 +Close 1967