summaryrefslogtreecommitdiffstats
path: root/text-utils/column.c
diff options
context:
space:
mode:
authorSami Kerola2014-05-04 17:39:38 +0200
committerKarel Zak2014-05-07 11:28:48 +0200
commitacb5f9b56e14db9b684e245bfdf647522c9a57b4 (patch)
treef6f3a855706b0bde4d7d0ba1133d3c3dd32197dd /text-utils/column.c
parentMerge branch 'kill-tests' of https://github.com/rudimeier/util-linux (diff)
downloadkernel-qcow2-util-linux-acb5f9b56e14db9b684e245bfdf647522c9a57b4.tar.gz
kernel-qcow2-util-linux-acb5f9b56e14db9b684e245bfdf647522c9a57b4.tar.xz
kernel-qcow2-util-linux-acb5f9b56e14db9b684e245bfdf647522c9a57b4.zip
column: inform user when multibyte conversion error occurs
The column(1) read input until conversion error, and used incomplete input when outputing, that made at least me to wonder where the rest disappeared without explanation. IMHO it is better to fail immediately rather than do only half of the task. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'text-utils/column.c')
-rw-r--r--text-utils/column.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/text-utils/column.c b/text-utils/column.c
index e34184e05..0ee5a9e89 100644
--- a/text-utils/column.c
+++ b/text-utils/column.c
@@ -376,7 +376,13 @@ static int input(FILE *fp, int *maxlength, wchar_t ***list, int *entries)
if (!local_list)
local_list = xcalloc(maxentry, sizeof(wchar_t *));
- while (fgetws(buf, MAXLINELEN, fp)) {
+ while (1) {
+ if (fgetws(buf, MAXLINELEN, fp) == NULL) {
+ if (feof(fp))
+ break;
+ else
+ err(EXIT_FAILURE, _("read failed"));
+ }
for (p = buf; *p && iswspace(*p); ++p)
;
if (!*p)