diff --git a/usr.bin/iconv/iconv.c b/usr.bin/iconv/iconv.c --- a/usr.bin/iconv/iconv.c +++ b/usr.bin/iconv/iconv.c @@ -77,9 +77,16 @@ 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) {