trstr: fix matching patterns like ^pat$ - neatvi - [fork] simple vi-type editor with UTF-8 support
 (HTM) git clone git://src.adamsgaard.dk/neatvi
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
       ---
 (DIR) commit e111e19608ce73e841506964dbd5dae4eff68ea1
 (DIR) parent 0af6ff63f3ec0fe5b29b036110a61a499cfd1ff4
 (HTM) Author: Ali Gholami Rudi <ali@rudi.ir>
       Date:   Sat, 16 Apr 2022 22:10:22 +0430
       
       rstr: fix matching patterns like ^pat$
       
       Reported by Kyryl Melekhin <k.melekhin@gmail.com>.
       
       Diffstat:
         M rstr.c                              |       4 ++--
         A test/e11.sh                         |      13 +++++++++++++
       
       2 files changed, 15 insertions(+), 2 deletions(-)
       ---
 (DIR) 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, int flg)
                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;
 (DIR) 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