Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Sep 2022 06:27:07 GMT
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 426e7ab3cacc - stable/13 - iconv: only conditionally use ICONV_SET_DISCARD_ILSEQ
Message-ID:  <202209180627.28I6R7nj067847@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=426e7ab3caccf5f54b38161dd8a7bf8f2d0a3855

commit 426e7ab3caccf5f54b38161dd8a7bf8f2d0a3855
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2022-02-22 05:05:28 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2022-09-18 06:26:39 +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.
    
    (cherry picked from commit ea0f37dec65daf2b7e05712738cd1720aae129eb)
---
 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) {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202209180627.28I6R7nj067847>