]> git.neil.brown.name Git - edlib.git/commitdiff
rexel: fix return value in one case.
authorNeilBrown <neil@brown.name>
Sun, 27 Aug 2023 00:18:50 +0000 (10:18 +1000)
committerNeilBrown <neil@brown.name>
Sun, 27 Aug 2023 03:33:13 +0000 (13:33 +1000)
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 <neil@brown.name>
DOC/TODO.md
rexel.c
tests.d/00-basic

index b78379f2c8e6610d9a58b54dbcb6410e2c5c41f1..a7b7620c37c5394c6b67a8da44da8363281bf9c3 100644 (file)
@@ -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 90134c10082f48393852fb4d92b651991cf52550..be492a5722938396712af5e32598fb3e33833919 100644 (file)
--- 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)
index 0d0d09682e02689b881390ec57165471633cceed..2c0e10916c499fda37272b966ebfe478637cc5c8 100644 (file)
@@ -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