On FreeBSD 12.0, I'm seeing this test failure: ../../gltests/test-unicodeio.c:67: assertion 'strcmp (result, TEST_CODE_AS_UTF8) == 0' failed Abort trap (core dumped) FAIL test-unicodeio1.sh (exit status: 134)
This patch fixes it, by generalizing the patch that I added for NetBSD on 2020-07-10. 2020-12-07 Bruno Haible <br...@clisp.org> unicodeio: Fix wrong result on FreeBSD. * lib/unicodeio.c (unicode_to_mb): Handle question mark fallback characters on all platforms. diff --git a/lib/unicodeio.c b/lib/unicodeio.c index d587a27..3d7a602 100644 --- a/lib/unicodeio.c +++ b/lib/unicodeio.c @@ -142,9 +142,9 @@ unicode_to_mb (unsigned int code, # if !defined _LIBICONV_VERSION && (defined sgi || defined __sgi) || (res > 0 && code != 0 && outptr - outbuf == 1 && *outbuf == '\0') # endif - /* NetBSD iconv() and Solaris 11 iconv() insert a '?' if they cannot - convert. */ -# if !defined _LIBICONV_VERSION && (defined __NetBSD__ || defined __sun) + /* FreeBSD iconv(), NetBSD iconv(), and Solaris 11 iconv() insert + a '?' if they cannot convert. */ +# if !defined _LIBICONV_VERSION || (res > 0 && outptr - outbuf == 1 && *outbuf == '?') # endif /* musl libc iconv() inserts a '*' if it cannot convert. */