diff options
author | Karel Zak | 2017-11-22 14:43:36 +0100 |
---|---|---|
committer | Karel Zak | 2017-11-22 14:43:36 +0100 |
commit | dda229c7b2b16a31fae8e99079ab4f4ae5bc8eac (patch) | |
tree | bf80d2123515d017c79421afa2fe018b6f77b13a /text-utils/column.c | |
parent | lib/mbsalign: add mbs_invalid_encode() (diff) | |
download | kernel-qcow2-util-linux-dda229c7b2b16a31fae8e99079ab4f4ae5bc8eac.tar.gz kernel-qcow2-util-linux-dda229c7b2b16a31fae8e99079ab4f4ae5bc8eac.tar.xz kernel-qcow2-util-linux-dda229c7b2b16a31fae8e99079ab4f4ae5bc8eac.zip |
column: use \x<hex> for invalid multibyte seq.
Addresses: https://github.com/karelzak/util-linux/issues/542
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'text-utils/column.c')
-rw-r--r-- | text-utils/column.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/text-utils/column.c b/text-utils/column.c index ad6c2b20e..1484d783d 100644 --- a/text-utils/column.c +++ b/text-utils/column.c @@ -52,6 +52,7 @@ #include "ttyutils.h" #include "strv.h" #include "optutils.h" +#include "mbsalign.h" #include "libsmartcols.h" @@ -485,8 +486,18 @@ static int read_input(struct column_control *ctl, FILE *fp) continue; wcs = mbs_to_wcs(str); - if (!wcs) - err(EXIT_FAILURE, _("read failed")); + if (!wcs) { + /* + * Convert broken sequences to \x<hex> and continue. + */ + size_t tmpsz = 0; + char *tmp = mbs_invalid_encode(str, &tmpsz); + + if (!tmp) + err(EXIT_FAILURE, _("read failed")); + wcs = mbs_to_wcs(tmp); + free(tmp); + } switch (ctl->mode) { case COLUMN_MODE_TABLE: @@ -618,6 +629,7 @@ static void __attribute__((__noreturn__)) usage(void) fputs(_(" -s, --separator <string> possible table delimiters\n"), out); fputs(_(" -x, --fillrows fill rows before columns\n"), out); + fputs(USAGE_SEPARATOR, out); printf(USAGE_HELP_OPTIONS(34)); printf(USAGE_MAN_TAIL("column(1)")); |