aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2023-08-23 03:40:45 +0000
committerKyle Evans <kevans@FreeBSD.org>2023-08-23 03:40:45 +0000
commite2030ca246a777c50a7aacb3a35f88addded21cf (patch)
treef95b9856cccb82581a9cdd98bcc05769b220134c
parentc7df87209634129df476049c2f38cd4ebefa386f (diff)
libc: fix c*rtomb/mbrtoc*
In 693f88c9da8d ("iconv_std: complete the //IGNORE support"), we more completely implemented //IGNORE, which changed the semantics of ci_discard_ilseq. DISCARD_ILSEQ semantics are supposed to match //IGNORE, so we really can't do much about that particular incompatibility. This broke c*rtomb and mbrtoc* handling of invalid sequences, but it turns out they don't want DISCARD_ILSEQ semantics at all; they really want the subset that we call _CITRUS_ICONV_F_HIDE_INVALID. This restores the exact flow in iconv_std to precisely how it happened prior to 693f88c9da8d. PR: 265871 Fixes: 693f88c9da8d ("iconv_std: complete the //IGNORE support") Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D41513
-rw-r--r--lib/libc/locale/cXXrtomb_iconv.h4
-rw-r--r--lib/libc/locale/mbrtocXX_iconv.h4
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/libc/locale/cXXrtomb_iconv.h b/lib/libc/locale/cXXrtomb_iconv.h
index cf171a49d439..8f123e85c66d 100644
--- a/lib/libc/locale/cXXrtomb_iconv.h
+++ b/lib/libc/locale/cXXrtomb_iconv.h
@@ -75,7 +75,7 @@ cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps,
errno = EINVAL;
return (-1);
}
- handle->cv_shared->ci_discard_ilseq = true;
+ handle->cv_shared->ci_discard_ilseq = false;
handle->cv_shared->ci_hooks = NULL;
cs->srcbuf_len = 0;
cs->initialized = true;
@@ -92,7 +92,7 @@ cXXrtomb_l(char * __restrict s, charXX_t c, mbstate_t * __restrict ps,
dst = s;
dstleft = MB_CUR_MAX_L(locale);
err = _citrus_iconv_convert(handle, &src, &srcleft, &dst, &dstleft,
- 0, &invlen);
+ _CITRUS_ICONV_F_HIDE_INVALID, &invlen);
/* Character is part of a surrogate pair. We need more input. */
if (err == EINVAL)
diff --git a/lib/libc/locale/mbrtocXX_iconv.h b/lib/libc/locale/mbrtocXX_iconv.h
index 148ba55e548a..22b8a7d4031c 100644
--- a/lib/libc/locale/mbrtocXX_iconv.h
+++ b/lib/libc/locale/mbrtocXX_iconv.h
@@ -78,7 +78,7 @@ mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n,
errno = EINVAL;
return (-1);
}
- handle->cv_shared->ci_discard_ilseq = true;
+ handle->cv_shared->ci_discard_ilseq = false;
handle->cv_shared->ci_hooks = NULL;
cs->srcbuf_len = cs->dstbuf_len = 0;
cs->initialized = true;
@@ -110,7 +110,7 @@ mbrtocXX_l(charXX_t * __restrict pc, const char * __restrict s, size_t n,
assert(srcleft <= sizeof(cs->srcbuf) &&
dstleft <= sizeof(cs->dstbuf.bytes));
err = _citrus_iconv_convert(handle, &src, &srcleft,
- &dst, &dstleft, 0, &invlen);
+ &dst, &dstleft, _CITRUS_ICONV_F_HIDE_INVALID, &invlen);
cs->dstbuf_len = (dst - cs->dstbuf.bytes) / sizeof(charXX_t);
/* Got new character(s). Return the first. */