trstr: fix matching patterns like ^pat$ - neatvi - [fork] simple vi-type editor… | |
git clone git://src.adamsgaard.dk/neatvi | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit e111e19608ce73e841506964dbd5dae4eff68ea1 | |
parent 0af6ff63f3ec0fe5b29b036110a61a499cfd1ff4 | |
Author: Ali Gholami Rudi <[email protected]> | |
Date: Sat, 16 Apr 2022 22:10:22 +0430 | |
rstr: fix matching patterns like ^pat$ | |
Reported by Kyryl Melekhin <[email protected]>. | |
Diffstat: | |
M rstr.c | 4 ++-- | |
A test/e11.sh | 13 +++++++++++++ | |
2 files changed, 15 insertions(+), 2 deletions(-) | |
--- | |
diff --git a/rstr.c b/rstr.c | |
t@@ -89,10 +89,10 @@ int rstr_find(struct rstr *rs, char *s, int n, int *grps, … | |
end = s + strlen(s) - len - 1; | |
if (end < beg) | |
return -1; | |
- if (rs->lbeg) | |
- end = beg; | |
if (rs->lend) | |
beg = end; | |
+ if (rs->lbeg) | |
+ end = s; | |
for (r = beg; r <= end; r++) { | |
if (rs->wbeg && r > s && (isword(r - 1) || !isword(r))) | |
continue; | |
diff --git a/test/e11.sh b/test/e11.sh | |
t@@ -0,0 +1,13 @@ | |
+# vi commands | |
+echo ":e $1" | |
+echo ":a" | |
+echo "a" | |
+echo "ab" | |
+echo "." | |
+echo ':%s/^a$/x/' | |
+echo ":w" | |
+echo ":q" | |
+ | |
+# the expected output | |
+echo "x" >&2 | |
+echo "ab" >&2 |