git: ea0f37dec65d - main - iconv: only conditionally use ICONV_SET_DISCARD_ILSEQ
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Thu, 11 Aug 2022 16:43:46 UTC
The branch main has been updated by kevans: URL: https://cgit.FreeBSD.org/src/commit/?id=ea0f37dec65daf2b7e05712738cd1720aae129eb commit ea0f37dec65daf2b7e05712738cd1720aae129eb Author: Kyle Evans <kevans@FreeBSD.org> AuthorDate: 2022-02-22 05:05:28 +0000 Commit: Kyle Evans <kevans@FreeBSD.org> CommitDate: 2022-08-11 16:33:28 +0000 iconv: only conditionally use ICONV_SET_DISCARD_ILSEQ If the -c flag is used, then we can set it with ICONV_SET_DISCARD_ILSEQ; otherwise, leave it alone. The user may have specified //IGNORE in the 'to' codeset specification, there's no reason we can't allow that but we'll currently turn it off. Reviewed by: thj Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D34342 --- usr.bin/iconv/iconv.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/usr.bin/iconv/iconv.c b/usr.bin/iconv/iconv.c index 7e911b4432e5..ba099f8af520 100644 --- a/usr.bin/iconv/iconv.c +++ b/usr.bin/iconv/iconv.c @@ -77,9 +77,16 @@ do_conv(FILE *fp, iconv_t cd, bool silent, bool hide_invalid) unsigned long long invalids; size_t inbytes, outbytes, ret; - int arg = (int)hide_invalid; - if (iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, (void *)&arg) == -1) - err(EXIT_FAILURE, "iconvctl(DISCARD_ILSEQ, %d)", arg); + /* + * Don't touch ICONV_SET_DISCARD_ILSEQ if -c wasn't specified. It may + * be that the user has specified //IGNORE in the -t specification, and + * we don't want to clobber that. + */ + if (hide_invalid) { + int arg = (int)hide_invalid; + if (iconvctl(cd, ICONV_SET_DISCARD_ILSEQ, (void *)&arg) == -1) + err(EXIT_FAILURE, "iconvctl(DISCARD_ILSEQ, %d)", arg); + } invalids = 0; while ((inbytes = fread(inbuf, 1, INBUFSIZE, fp)) > 0) {