summaryrefslogtreecommitdiffstats
path: root/text-utils/column.c
diff options
context:
space:
mode:
authorSami Kerola2010-10-09 19:59:48 +0200
committerKarel Zak2010-10-21 09:38:17 +0200
commit80fa094c9016e95c70224d6e9a918a96d5131129 (patch)
treea0e329adca65189666e2cb947c16ba7d86d7f7e3 /text-utils/column.c
parentlibblkid: fix MBR detection on iPod and cleanup vfat code (diff)
downloadkernel-qcow2-util-linux-80fa094c9016e95c70224d6e9a918a96d5131129.tar.gz
kernel-qcow2-util-linux-80fa094c9016e95c70224d6e9a918a96d5131129.tar.xz
kernel-qcow2-util-linux-80fa094c9016e95c70224d6e9a918a96d5131129.zip
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 <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/column.c')
-rw-r--r--text-utils/column.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/text-utils/column.c b/text-utils/column.c
index e7cd33464..c8c40664a 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;