--- sort.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/sort.c b/sort.c index fbb1abf..dd992e0 100644 --- a/sort.c +++ b/sort.c _AT_@ -123,11 +123,7 @@ columns(struct line *line, const struct keydef *kd, struct column *col) end.len = 1; } col->line.len = MAX(0, end.data - start.data); - if (!(col->line.data) || col->cap < col->line.len + 1) { - free(col->line.data); - col->line.data = emalloc(col->line.len + 1); - } - memcpy(col->line.data, start.data, col->line.len); + col->line.data = start.data; col->line.data[col->line.len] = '\0'; } _AT_@ -423,6 +419,7 @@ main(int argc, char *argv[]) for (i = 0; i < linebuf.nlines; i++) { if (!uflag || i == 0 || slinecmp(&linebuf.lines[i], &linebuf.lines[i - 1])) { + linebuf.lines[i].data[linebuf.lines[i].len-1] = '\n'; fwrite(linebuf.lines[i].data, 1, linebuf.lines[i].len, ofp); } -- 2.43.0Received on Mon Feb 26 2024 - 23:07:47 CET
This archive was generated by hypermail 2.3.0 : Tue Feb 27 2024 - 00:00:55 CET