Revert "fix length after '\' getline string termination"
Caused a regression in sed, revert until we investigate further.
This commit is contained in:
parent
fa18379a05
commit
ea0d16e928
4
cut.c
4
cut.c
|
@ -115,8 +115,8 @@ cut(FILE *fp, const char *fname)
|
||||||
Range *r;
|
Range *r;
|
||||||
|
|
||||||
while ((len = getline(&buf, &size, fp)) > 0) {
|
while ((len = getline(&buf, &size, fp)) > 0) {
|
||||||
if (buf[len - 1] == '\n')
|
if (len && buf[len - 1] == '\n')
|
||||||
buf[--len] = '\0';
|
buf[len - 1] = '\0';
|
||||||
if (mode == 'f' && !utfutf(buf, delim)) {
|
if (mode == 'f' && !utfutf(buf, delim)) {
|
||||||
if (!sflag)
|
if (!sflag)
|
||||||
puts(buf);
|
puts(buf);
|
||||||
|
|
2
head.c
2
head.c
|
@ -15,7 +15,7 @@ head(FILE *fp, const char *fname, size_t n)
|
||||||
|
|
||||||
while (i < n && (len = getline(&buf, &size, fp)) > 0) {
|
while (i < n && (len = getline(&buf, &size, fp)) > 0) {
|
||||||
fputs(buf, stdout);
|
fputs(buf, stdout);
|
||||||
i += (buf[len - 1] == '\n');
|
i += (len && (buf[len - 1] == '\n'));
|
||||||
}
|
}
|
||||||
free(buf);
|
free(buf);
|
||||||
if (ferror(fp))
|
if (ferror(fp))
|
||||||
|
|
4
sed.c
4
sed.c
|
@ -441,8 +441,8 @@ read_line(FILE *f, String *s)
|
||||||
eprintf("getline:");
|
eprintf("getline:");
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
if (s->str[len] == '\n')
|
if (s->str[--len] == '\n')
|
||||||
s->str[--len] = '\0';
|
s->str[len] = '\0';
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
tail.c
2
tail.c
|
@ -23,7 +23,7 @@ dropinit(FILE *fp, const char *str, size_t n)
|
||||||
|
|
||||||
if (mode == 'n') {
|
if (mode == 'n') {
|
||||||
while (i < n && (len = getline(&buf, &size, fp)) > 0)
|
while (i < n && (len = getline(&buf, &size, fp)) > 0)
|
||||||
if (buf[len - 1] == '\n')
|
if (len > 0 && buf[len - 1] == '\n')
|
||||||
i++;
|
i++;
|
||||||
} else {
|
} else {
|
||||||
while (i < n && (len = efgetrune(&r, fp, str)))
|
while (i < n && (len = efgetrune(&r, fp, str)))
|
||||||
|
|
|
@ -169,9 +169,9 @@ uudecode(FILE *fp, FILE *outfp)
|
||||||
while ((len = getline(&bufb, &n, fp)) > 0) {
|
while ((len = getline(&bufb, &n, fp)) > 0) {
|
||||||
p = bufb;
|
p = bufb;
|
||||||
/* trim newlines */
|
/* trim newlines */
|
||||||
if (bufb[len - 1] != '\n')
|
if (!len || bufb[len - 1] != '\n')
|
||||||
eprintf("no newline found, aborting\n");
|
eprintf("no newline found, aborting\n");
|
||||||
bufb[--len] = '\0';
|
bufb[len - 1] = '\0';
|
||||||
|
|
||||||
/* check for last line */
|
/* check for last line */
|
||||||
if ((i = DEC(*p)) <= 0)
|
if ((i = DEC(*p)) <= 0)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user