]> Kevux Git Server - rit/commit
meson: detect broken iconv that requires ICONV_RESTART_RESET
authorPatrick Steinhardt <ps@pks.im>
Thu, 5 Mar 2026 11:20:22 +0000 (12:20 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 5 Mar 2026 19:19:56 +0000 (11:19 -0800)
commitf1d734bf25570e3355c3c147e71e075a2f8f98f2
treea36d9e3fc25340d645135de0c57a287a6397716b
parent4cae5847694f0d62b6da3b55164f7749c0a19fef
meson: detect broken iconv that requires ICONV_RESTART_RESET

In d0cec08d70 (utf8.c: prepare workaround for iconv under macOS 14/15,
2026-01-12) we have introduced a new workaround for a broken version of
libiconv on macOS. This workaround has for now only been wired up for
our Makefile, so using Meson with such a broken version will fail.

We can rather easily detect the broken behaviour. Some encodings have
different modes that can be switched to via an escape sequence. In the
case of ISO-2022-JP this can be done via "<Esc>$B" and "<Esc>(J" to
switch between ASCII and JIS modes. The bug now triggers when one does
multiple calls to iconv(3p) to convert a string piece by piece, where
the first call enters JIS mode. The second call forgets about the fact
that it is still in JIS mode, and consequently it will incorrectly treat
the input as ASCII, and thus the produced output is of course garbage.

Wire up a test that exercises this in Meson and, if it fails, set the
`ICONV_RESTART_RESET` define.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
meson.build