diff options
| author | Junio C Hamano <gitster@pobox.com> | 2026-01-21 08:28:57 -0800 |
|---|---|---|
| committer | Junio C Hamano <gitster@pobox.com> | 2026-01-21 08:28:57 -0800 |
| commit | 0a5dcc1259fa0c8f5c21352c90b3cd3d43273345 (patch) | |
| tree | 0b6e2f763b3f33d25f9ce51aa7b95d0d28c3d081 /utf8.c | |
| parent | 79e3055baba32e2952e6e8994cdcd4fc145ba7f0 (diff) | |
| parent | d28124151851e42a3bb92963f5b747ad843f33e0 (diff) | |
| download | git-0a5dcc1259fa0c8f5c21352c90b3cd3d43273345.tar.xz | |
Merge branch 'tb/macos-iconv-workarounds'
The iconv library on macOS fails to correctly handle stateful
ISO/IEC 2022 encoded strings. Work it around instead of replacing
it wholesale from homebrew.
* tb/macos-iconv-workarounds:
utf8.c: enable workaround for iconv under macOS 14/15
utf8.c: prepare workaround for iconv under macOS 14/15
Diffstat (limited to 'utf8.c')
| -rw-r--r-- | utf8.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -515,6 +515,19 @@ char *reencode_string_iconv(const char *in, size_t insz, iconv_t conv, out = xrealloc(out, outalloc); outpos = out + sofar; outsz = outalloc - sofar - 1; +#ifdef ICONV_RESTART_RESET + /* + * If iconv(3) messes up piecemeal conversions + * then restore the original pointers, sizes, + * and converter state, then retry converting + * the full string using the reallocated buffer. + */ + insz += cp - (iconv_ibp)in; /* Restore insz */ + cp = (iconv_ibp)in; /* original start value */ + outpos = out + bom_len; /* original start value */ + outsz = outalloc - bom_len - 1; /* new len */ + iconv(conv, NULL, NULL, NULL, NULL); /* reset iconv machinery */ +#endif } else { *outpos = '\0'; |
