From 80fa094c9016e95c70224d6e9a918a96d5131129 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 9 Oct 2010 19:59:48 +0200 Subject: 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 --- text-utils/column.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'text-utils') 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; -- cgit v1.2.3