summaryrefslogtreecommitdiffstats
path: root/text-utils/col.c
diff options
context:
space:
mode:
authorKarel Zak2007-01-30 13:18:51 +0100
committerKarel Zak2007-01-30 13:52:48 +0100
commite9ce5ccc90c63cb1c499ad01800e638ece23f8b0 (patch)
tree251163add0f5966824a79409005502cb1c70e328 /text-utils/col.c
parentbuild-sys: fix ifdef ENABLE_WIDECHAR usage (diff)
downloadkernel-qcow2-util-linux-e9ce5ccc90c63cb1c499ad01800e638ece23f8b0.tar.gz
kernel-qcow2-util-linux-e9ce5ccc90c63cb1c499ad01800e638ece23f8b0.tar.xz
kernel-qcow2-util-linux-e9ce5ccc90c63cb1c499ad01800e638ece23f8b0.zip
col: getwchar() errors shouldn't be hidden
The col truncates output when multibyte errors is detected, but the problem is not reported to stderr and return code is still same like for successful exit. This stupid behaviour is fixed by this patch. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/col.c')
-rw-r--r--text-utils/col.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/text-utils/col.c b/text-utils/col.c
index 052d91e7a..3b81a891a 100644
--- a/text-utils/col.c
+++ b/text-utils/col.c
@@ -128,6 +128,7 @@ int main(int argc, char **argv)
int this_line; /* line l points to */
int nflushd_lines; /* number of lines that were flushed */
int adjust, opt, warned;
+ int ret = 0;
setlocale(LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
@@ -175,8 +176,16 @@ int main(int argc, char **argv)
cur_line = max_line = nflushd_lines = this_line = 0;
cur_set = last_set = CS_NORMAL;
lines = l = alloc_line();
-
- while ((ch = getwchar()) != WEOF) {
+
+ while (feof(stdin)==0) {
+ errno = 0;
+ if ((ch = getwchar()) == WEOF) {
+ if (errno==EILSEQ) {
+ perror("col");
+ ret = 1;
+ }
+ break;
+ }
if (!iswgraph(ch)) {
switch (ch) {
case BS: /* can't go back further */
@@ -332,7 +341,7 @@ int main(int argc, char **argv)
flush_blanks();
if (ferror(stdout) || fclose(stdout))
return 1;
- return 0;
+ return ret;
}
void flush_lines(int nflush)