[PATCH 1/3] text-utils/column.c: EOF handling bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
---
 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 e7cd334..6371a98 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;
-- 
1.7.3.1

--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux