diff options
author | Sami Kerola <kerolasa@iki.fi> | 2010-10-09 19:59:48 +0200 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2010-10-21 09:38:17 +0200 |
commit | 80fa094c9016e95c70224d6e9a918a96d5131129 (patch) | |
tree | a0e329adca65189666e2cb947c16ba7d86d7f7e3 /text-utils | |
parent | 973af806428c0f853ac0241ab46faee6ccdaab26 (diff) | |
download | util-linux-old-80fa094c9016e95c70224d6e9a918a96d5131129.tar.gz |
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')
-rw-r--r-- | text-utils/column.c | 5 |
1 files changed, 3 insertions, 2 deletions
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; |