[hackers] [sbase][PATCH] Stop matching when lastmatch points to '\n'

From: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
Date: Thu, 7 Jan 2016 12:34:40 +0100

This situation happens with something like s/$/test/,
where rm_so == rm_eo == 0. Without this check, ed
keeps looping forever.
---
 ed.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ed.c b/ed.c
index 69c7422..9dc6fda 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -1007,7 +1007,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);
 	}
-- 
2.1.4
Received on Thu Jan 07 2016 - 12:34:40 CET

This archive was generated by hypermail 2.3.0 : Thu Jan 07 2016 - 12:36:13 CET