mirror of git://git.suckless.org/sbase
ed: Fix makeline
Strings without newlines created problems in the function and the global field was not updated, making that new lines added were marked as global being processed in the current global command.
This commit is contained in:
parent
09dc00f995
commit
54a0fc3ecc
5
ed.c
5
ed.c
|
@ -185,19 +185,20 @@ makeline(char *s, int *off)
|
|||
if (lastidx >= idxsize) {
|
||||
lp = NULL;
|
||||
if (idxsize <= SIZE_MAX - NUMLINES)
|
||||
lp = reallocarray(zero, idxsize + NUMLINES, sizeof(*lp));
|
||||
lp = reallocarray(zero, idxsize + NUMLINES, sizeof(*lp));
|
||||
if (!lp)
|
||||
error("out of memory");
|
||||
idxsize += NUMLINES;
|
||||
zero = lp;
|
||||
}
|
||||
lp = zero + lastidx;
|
||||
lp->global = 0;
|
||||
|
||||
if (!s) {
|
||||
lp->seek = -1;
|
||||
len = 0;
|
||||
} else {
|
||||
while ((c = *s++) != '\n')
|
||||
while ((c = *s++) && c != '\n')
|
||||
/* nothing */;
|
||||
len = s - begin;
|
||||
if ((lp->seek = lseek(scratch, 0, SEEK_END)) < 0 ||
|
||||
|
|
Loading…
Reference in New Issue