sbase

suckless unix tools
git clone git://git.2f30.org/sbase.git
Log | Files | Refs | README | LICENSE

commit 2b31049d009534fbf5d52d17a1463fe9dd32481b
parent a290073fdccea7a7c870caa1ff2cf0bf3d52e354
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu Jan  7 12:34:40 +0100

Stop matching when lastmatch points to '\n'

This situation happens with something like s/$/test/,
where rm_so == rm_eo == 0. Without this check, ed
keeps looping forever.

Diffstat:
ed.c | 2+-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ed.c b/ed.c @@ -1005,7 +1005,7 @@ subline(int num, int nth) static size_t siz, cap; i = changed = siz = 0; - for (m = match(num); m; m = rematch(num)) { + for (m = match(num); m && *lastmatch != '\n'; m = rematch(num)) { addpre(&s, &cap, &siz); changed |= addsub(&s, &cap, &siz, nth, ++i); }