1
0
mirror of https://git.savannah.gnu.org/git/gnulib.git synced 2026-10-24 00:48:56 +03:00

tests: Check that c32isprint is consistent with isprint in the C locale.

* tests/test-c32isprint.c: Include <ctype.h>.
(main): In the C locale, check that c32isprint is consistent with
isprint.
This commit is contained in:
Bruno Haible
2026-08-28 00:43:56 +02:00
parent 27353a8efc
commit de054f5dc8
2 changed files with 20 additions and 0 deletions

View File

@@ -1,5 +1,10 @@
2026-08-27 Bruno Haible <bruno@clisp.org>
tests: Check that c32isprint is consistent with isprint in the C locale.
* tests/test-c32isprint.c: Include <ctype.h>.
(main): In the C locale, check that c32isprint is consistent with
isprint.
mbrtoc32: Make c32isprint compatible with isprint in the C locale.
Reported by Paul Eggert in
<https://lists.gnu.org/archive/html/bug-gnulib/2026-08/msg00222.html>.

View File

@@ -21,6 +21,7 @@
#include "signature.h"
SIGNATURE_CHECK (c32isprint, int, (wint_t));
#include <ctype.h>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
@@ -106,6 +107,20 @@ main (int argc, char *argv[])
{
case '0':
/* C locale; tested above. */
#if !defined __ANDROID__
/* On Android ≥ 5.0, the default locale is the "C.UTF-8" locale, not the
"C" locale. Furthermore, when you attempt to set the "C" or "POSIX"
locale via setlocale(), what you get is a "C" locale with UTF-8
encoding, that is, effectively the "C.UTF-8" locale. */
/* Check that c32isprint is consistent with isprint. */
for (int c = 0x80; c < 0x100; c++)
{
ASSERT (!isprint ((unsigned char) c));
buf[0] = (unsigned char) c;
is = for_character (buf, 1);
ASSERT (is == 0);
}
#endif
return test_exit_status;
case '1':