From: Sami Kerola Date: Sat, 9 Oct 2010 17:59:48 +0000 (+0200) Subject: column: EOF handling bug X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=80fa094c9016e95c70224d6e9a918a96d5131129;p=util-linux column: EOF handling bug For the last line of the file lenght of line should be determined where the EOF is instead of new line. Old output was $ printf "1 2\n3" | column -t column: line too long 1 2 which this commit will change to $ printf "1 2\n3" | column -t 1 2 3 Signed-off-by: Sami Kerola Signed-off-by: Karel Zak --- diff --git a/text-utils/column.c b/text-utils/column.c index e7cd3346..c8c40664 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -322,12 +322,13 @@ input(fp) for (p = buf; *p && iswspace(*p); ++p); if (!*p) continue; - if (!(p = wcschr(p, '\n'))) { + if (!(p = wcschr(p, '\n')) && !feof(fp)) { warnx(_("line too long")); eval = 1; continue; } - *p = '\0'; + if (!feof(fp)) + *p = '\0'; len = wcs_width(buf); /* len = p - buf; */ if (maxlength < len) maxlength = len;