diff options
author | Bruno Haible <bruno@clisp.org> | 2020-01-09 01:56:35 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-01-09 01:56:35 +0100 |
commit | 4ec96253823bde7488bfee4ee5d890792d6b555b (patch) | |
tree | 04d9f4c525b5c2b9a77b9b7e17ebe7af1b7c71ea /m4 | |
parent | 9be236d67f3d78235c5cbe4381c5dd7b3cddb179 (diff) | |
download | gnulib-4ec96253823bde7488bfee4ee5d890792d6b555b.tar.gz |
c32rtomb: New module.
* lib/uchar.in.h (c32rtomb): New declaration.
* lib/c32rtomb.c: New file, based on lib/unistr/u8-uctomb-aux.c.
* m4/c32rtomb.m4: New file.
* m4/uchar.m4 (gl_UCHAR_H): Test whether c32rtomb is declared.
(gl_UCHAR_H_DEFAULTS): Initialize GNULIB_C32RTOMB, HAVE_C32RTOMB,
REPLACE_C32RTOMB.
* modules/uchar (Makefile.am): Substitute GNULIB_C32RTOMB,
HAVE_C32RTOMB, REPLACE_C32RTOMB.
* modules/c32rtomb: New file.
* tests/test-uchar-c++.cc: Test the signature of c32rtomb.
* doc/posix-functions/c32rtomb.texi: Document the new module.
* doc/posix-functions/wcrtomb.texi: Mention the new module.
Diffstat (limited to 'm4')
-rw-r--r-- | m4/c32rtomb.m4 | 55 | ||||
-rw-r--r-- | m4/uchar.m4 | 7 |
2 files changed, 60 insertions, 2 deletions
diff --git a/m4/c32rtomb.m4 b/m4/c32rtomb.m4 new file mode 100644 index 0000000000..4cf0e4deda --- /dev/null +++ b/m4/c32rtomb.m4 @@ -0,0 +1,55 @@ +# c32rtomb.m4 serial 1 +dnl Copyright (C) 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, +dnl with or without modifications, as long as this notice is preserved. + +AC_DEFUN([gl_FUNC_C32RTOMB], +[ + AC_REQUIRE([gl_UCHAR_H_DEFAULTS]) + + AC_REQUIRE([gl_MBRTOC32_SANITYCHECK]) + + AC_CHECK_FUNCS_ONCE([c32rtomb]) + if test $ac_cv_func_c32rtomb = no; then + HAVE_C32RTOMB=0 + else + dnl When we override mbrtoc32, redefining the meaning of the char32_t + dnl values, we need to override c32rtomb as well, for consistency. + if test $HAVE_WORKING_MBRTOC32 = 0; then + REPLACE_C32RTOMB=1 + fi + AC_CACHE_CHECK([whether c32rtomb return value is correct], + [gl_cv_func_c32rtomb_retval], + [ + dnl Initial guess, used when cross-compiling. +changequote(,)dnl + case "$host_os" in + # Guess no on AIX. + aix*) gl_cv_func_c32rtomb_retval="guessing no" ;; + # Guess yes otherwise. + *) gl_cv_func_c32rtomb_retval="guessing yes" ;; + esac +changequote([,])dnl + AC_RUN_IFELSE( + [AC_LANG_SOURCE([[ +#include <uchar.h> +int main () +{ + int result = 0; + if (c32rtomb (NULL, 0, NULL) != 1) + result |= 1; + return result; +}]])], + [gl_cv_func_c32rtomb_retval=yes], + [gl_cv_func_c32rtomb_retval=no], + [:]) + ]) + case "$gl_cv_func_c32rtomb_retval" in + *yes) ;; + *) AC_DEFINE([C32RTOMB_RETVAL_BUG], [1], + [Define if the wcrtomb function has an incorrect return value.]) + REPLACE_C32RTOMB=1 ;; + esac + fi +]) diff --git a/m4/uchar.m4 b/m4/uchar.m4 index 0b5c662953..be71196619 100644 --- a/m4/uchar.m4 +++ b/m4/uchar.m4 @@ -1,4 +1,4 @@ -# uchar.m4 serial 8 +# uchar.m4 serial 9 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, @@ -33,7 +33,7 @@ AC_DEFUN_ONCE([gl_UCHAR_H], dnl corresponding gnulib module is not in use, and which is not dnl guaranteed by C11. gl_WARN_ON_USE_PREPARE([[#include <uchar.h> - ]], [mbrtoc32]) + ]], [c32rtomb mbrtoc32]) ]) AC_DEFUN([gl_UCHAR_MODULE_INDICATOR], @@ -48,12 +48,15 @@ AC_DEFUN([gl_UCHAR_MODULE_INDICATOR], AC_DEFUN([gl_UCHAR_H_DEFAULTS], [ GNULIB_BTOC32=0; AC_SUBST([GNULIB_BTOC32]) + GNULIB_C32RTOMB=0; AC_SUBST([GNULIB_C32RTOMB]) 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]) ]) |