[hackers] [sbase] Stop matching when lastmatch points to '\n' || Roberto E. Vargas Caballero

From: <git_AT_suckless.org>
Date: Mon, 11 Jan 2016 16:38:03 +0100 (CET)

commit cf868c8eeb45f47063cc5d30b04b552e7dd5a7c4
Author: Roberto E. Vargas Caballero <k0ga_AT_shike2.com>
AuthorDate: Thu Jan 7 12:34:40 2016 +0100
Commit: sin <sin_AT_2f30.org>
CommitDate: Mon Jan 11 15:37:58 2016 +0000

    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.

diff --git a/ed.c b/ed.c
index 67ffdb8..4a872ed 100644
--- a/ed.c
+++ b/ed.c
_AT_@ -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);
         }
Received on Mon Jan 11 2016 - 16:38:03 CET

This archive was generated by hypermail 2.3.0 : Mon Jan 11 2016 - 16:48:23 CET