diff options
author | Bruno Haible <bruno@clisp.org> | 2020-05-09 10:51:57 +0200 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-05-09 10:51:57 +0200 |
commit | 0026bb83b67abedfcaf765f3a62bd583611c6b56 (patch) | |
tree | 4b9a8b8df22d282f66678cb2ce3965177645d828 /m4/uchar.m4 | |
parent | 2bbe201944c2e65a49e71c6d3d3bfefb0049e899 (diff) | |
download | gnulib-0026bb83b67abedfcaf765f3a62bd583611c6b56.tar.gz |
uchar: Work around incorrect char16_t, char32_t types on Haiku 2020.
* lib/uchar.in.h (char16_t): Define as macro if
GNULIB_OVERRIDES_CHAR16_T.
(char32_t): Define as macro if GNULIB_OVERRIDES_CHAR32_T.
* m4/uchar.m4 (gl_TYPE_CHAR16_T, gl_TYPE_CHAR32_T): New macros.
(gl_UCHAR_H): Invoke them.
(gl_UCHAR_H_DEFAULTS): Initialize GNULIB_OVERRIDES_CHAR16_T,
GNULIB_OVERRIDES_CHAR32_T.
* m4/mbrtoc32.m4 (gl_FUNC_MBRTOC32, gl_MBRTOC32_SANITYCHECK): Require
gl_TYPE_CHAR32_T and test GNULIB_OVERRIDES_CHAR32_T.
* modules/uchar (Makefile.am): Substitute GNULIB_OVERRIDES_CHAR16_T,
GNULIB_OVERRIDES_CHAR32_T.
Diffstat (limited to 'm4/uchar.m4')
-rw-r--r-- | m4/uchar.m4 | 104 |
1 files changed, 77 insertions, 27 deletions
diff --git a/m4/uchar.m4 b/m4/uchar.m4 index 63d8b13408..0875caa36d 100644 --- a/m4/uchar.m4 +++ b/m4/uchar.m4 @@ -1,4 +1,4 @@ -# uchar.m4 serial 13 +# uchar.m4 serial 14 dnl Copyright (C) 2019-2020 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -19,6 +19,9 @@ AC_DEFUN_ONCE([gl_UCHAR_H], fi AC_SUBST([HAVE_UCHAR_H]) + gl_TYPE_CHAR16_T + gl_TYPE_CHAR32_T + dnl Test whether a 'char32_t' can hold more characters than a 'wchar_t'. gl_STDINT_BITSIZEOF([wchar_t], [gl_STDINT_INCLUDES]) if test $BITSIZEOF_WCHAR_T -lt 32; then @@ -36,6 +39,51 @@ AC_DEFUN_ONCE([gl_UCHAR_H], ]], [c32rtomb mbrtoc32]) ]) +dnl On Haiku 2020, char16_t and char32_t are incorrectly defined. +dnl See <https://dev.haiku-os.org/ticket/15990>. +AC_DEFUN_ONCE([gl_TYPE_CHAR16_T], +[ + AC_REQUIRE([gl_UCHAR_H_DEFAULTS]) + dnl Determine whether gnulib's <uchar.h> would, if present, override char16_t. + AC_CACHE_CHECK([whether char16_t is correctly defined], + [gl_cv_type_char16_t_works], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include <uchar.h> + /* For simplicity, assume that uint16_least_t is equivalent to + 'unsigned short'. */ + int verify[(char16_t)(-1) >= 0 && sizeof (char16_t) == sizeof (unsigned short) ? 1 : -1]; + ]]) + ], + [gl_cv_type_char16_t_works=yes], + [gl_cv_type_char16_t_works=no]) + ]) + if test $gl_cv_type_char16_t_works = no; then + GNULIB_OVERRIDES_CHAR16_T=1 + fi +]) +AC_DEFUN_ONCE([gl_TYPE_CHAR32_T], +[ + AC_REQUIRE([gl_UCHAR_H_DEFAULTS]) + dnl Determine whether gnulib's <uchar.h> would, if present, override char32_t. + AC_CACHE_CHECK([whether char32_t is correctly defined], + [gl_cv_type_char32_t_works], + [AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[ + #include <uchar.h> + /* For simplicity, assume that uint32_least_t is equivalent to + 'unsigned int'. */ + int verify[(char32_t)(-1) >= 0 && sizeof (char32_t) == sizeof (unsigned int) ? 1 : -1]; + ]]) + ], + [gl_cv_type_char32_t_works=yes], + [gl_cv_type_char32_t_works=no]) + ]) + if test $gl_cv_type_char32_t_works = no; then + GNULIB_OVERRIDES_CHAR32_T=1 + fi +]) + AC_DEFUN([gl_UCHAR_MODULE_INDICATOR], [ dnl Use AC_REQUIRE here, so that the default settings are expanded once only. @@ -47,31 +95,33 @@ AC_DEFUN([gl_UCHAR_MODULE_INDICATOR], AC_DEFUN([gl_UCHAR_H_DEFAULTS], [ - GNULIB_BTOC32=0; AC_SUBST([GNULIB_BTOC32]) - GNULIB_C32ISALNUM=0; AC_SUBST([GNULIB_C32ISALNUM]) - GNULIB_C32ISALPHA=0; AC_SUBST([GNULIB_C32ISALPHA]) - GNULIB_C32ISBLANK=0; AC_SUBST([GNULIB_C32ISBLANK]) - GNULIB_C32ISCNTRL=0; AC_SUBST([GNULIB_C32ISCNTRL]) - GNULIB_C32ISDIGIT=0; AC_SUBST([GNULIB_C32ISDIGIT]) - GNULIB_C32ISGRAPH=0; AC_SUBST([GNULIB_C32ISGRAPH]) - GNULIB_C32ISLOWER=0; AC_SUBST([GNULIB_C32ISLOWER]) - GNULIB_C32ISPRINT=0; AC_SUBST([GNULIB_C32ISPRINT]) - GNULIB_C32ISPUNCT=0; AC_SUBST([GNULIB_C32ISPUNCT]) - GNULIB_C32ISSPACE=0; AC_SUBST([GNULIB_C32ISSPACE]) - GNULIB_C32ISUPPER=0; AC_SUBST([GNULIB_C32ISUPPER]) - GNULIB_C32ISXDIGIT=0; AC_SUBST([GNULIB_C32ISXDIGIT]) - GNULIB_C32RTOMB=0; AC_SUBST([GNULIB_C32RTOMB]) - GNULIB_C32SNRTOMBS=0; AC_SUBST([GNULIB_C32SNRTOMBS]) - GNULIB_C32SRTOMBS=0; AC_SUBST([GNULIB_C32SRTOMBS]) - GNULIB_C32STOMBS=0; AC_SUBST([GNULIB_C32STOMBS]) - GNULIB_C32TOB=0; AC_SUBST([GNULIB_C32TOB]) - GNULIB_MBRTOC32=0; AC_SUBST([GNULIB_MBRTOC32]) - GNULIB_MBSNRTOC32S=0; AC_SUBST([GNULIB_MBSNRTOC32S]) - GNULIB_MBSRTOC32S=0; AC_SUBST([GNULIB_MBSRTOC32S]) - GNULIB_MBSTOC32S=0; AC_SUBST([GNULIB_MBSTOC32S]) + GNULIB_OVERRIDES_CHAR16_T=0; AC_SUBST([GNULIB_OVERRIDES_CHAR16_T]) + GNULIB_OVERRIDES_CHAR32_T=0; AC_SUBST([GNULIB_OVERRIDES_CHAR32_T]) + GNULIB_BTOC32=0; AC_SUBST([GNULIB_BTOC32]) + GNULIB_C32ISALNUM=0; AC_SUBST([GNULIB_C32ISALNUM]) + GNULIB_C32ISALPHA=0; AC_SUBST([GNULIB_C32ISALPHA]) + GNULIB_C32ISBLANK=0; AC_SUBST([GNULIB_C32ISBLANK]) + GNULIB_C32ISCNTRL=0; AC_SUBST([GNULIB_C32ISCNTRL]) + GNULIB_C32ISDIGIT=0; AC_SUBST([GNULIB_C32ISDIGIT]) + GNULIB_C32ISGRAPH=0; AC_SUBST([GNULIB_C32ISGRAPH]) + GNULIB_C32ISLOWER=0; AC_SUBST([GNULIB_C32ISLOWER]) + GNULIB_C32ISPRINT=0; AC_SUBST([GNULIB_C32ISPRINT]) + GNULIB_C32ISPUNCT=0; AC_SUBST([GNULIB_C32ISPUNCT]) + GNULIB_C32ISSPACE=0; AC_SUBST([GNULIB_C32ISSPACE]) + GNULIB_C32ISUPPER=0; AC_SUBST([GNULIB_C32ISUPPER]) + GNULIB_C32ISXDIGIT=0; AC_SUBST([GNULIB_C32ISXDIGIT]) + GNULIB_C32RTOMB=0; AC_SUBST([GNULIB_C32RTOMB]) + GNULIB_C32SNRTOMBS=0; AC_SUBST([GNULIB_C32SNRTOMBS]) + GNULIB_C32SRTOMBS=0; AC_SUBST([GNULIB_C32SRTOMBS]) + GNULIB_C32STOMBS=0; AC_SUBST([GNULIB_C32STOMBS]) + GNULIB_C32TOB=0; AC_SUBST([GNULIB_C32TOB]) + GNULIB_MBRTOC32=0; AC_SUBST([GNULIB_MBRTOC32]) + GNULIB_MBSNRTOC32S=0; AC_SUBST([GNULIB_MBSNRTOC32S]) + GNULIB_MBSRTOC32S=0; AC_SUBST([GNULIB_MBSRTOC32S]) + GNULIB_MBSTOC32S=0; AC_SUBST([GNULIB_MBSTOC32S]) dnl Assume proper GNU behavior unless another module says otherwise. - HAVE_C32RTOMB=1; AC_SUBST([HAVE_C32RTOMB]) - HAVE_MBRTOC32=1; AC_SUBST([HAVE_MBRTOC32]) - REPLACE_C32RTOMB=0; AC_SUBST([REPLACE_C32RTOMB]) - REPLACE_MBRTOC32=0; AC_SUBST([REPLACE_MBRTOC32]) + HAVE_C32RTOMB=1; AC_SUBST([HAVE_C32RTOMB]) + HAVE_MBRTOC32=1; AC_SUBST([HAVE_MBRTOC32]) + REPLACE_C32RTOMB=0; AC_SUBST([REPLACE_C32RTOMB]) + REPLACE_MBRTOC32=0; AC_SUBST([REPLACE_MBRTOC32]) ]) |