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.
This commit is contained in:
parent
0b117ab6c0
commit
cf868c8eeb
2
ed.c
2
ed.c
@ -1005,7 +1005,7 @@ subline(int num, int nth)
|
|||||||
static size_t siz, cap;
|
static size_t siz, cap;
|
||||||
|
|
||||||
i = changed = siz = 0;
|
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);
|
addpre(&s, &cap, &siz);
|
||||||
changed |= addsub(&s, &cap, &siz, nth, ++i);
|
changed |= addsub(&s, &cap, &siz, nth, ++i);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user