]> Savannah Git Hosting - gnulib.git/commitdiff
mbrtoc32: Avoid compilation failure on Haiku.
authorBruno Haible <bruno@clisp.org>
Sat, 9 May 2020 00:52:48 +0000 (02:52 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 9 May 2020 00:52:48 +0000 (02:52 +0200)
* m4/mbrtoc32.m4 (gl_CHECK_FUNC_MBRTOC32): New macro.
(gl_FUNC_MBRTOC32, gl_MBRTOC32_SANITYCHECK): Use it instead of
AC_CHECK_FUNCS_ONCE.
* doc/posix-functions/mbrtoc32.texi: Mention the Haiku problem.

ChangeLog
doc/posix-functions/mbrtoc32.texi
m4/mbrtoc32.m4

index 0a9cca9738db54af0996198a77f5ad93e5e33c2e..53a672a42ba0d6084598360b632189ac133f5b66 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2020-05-08  Bruno Haible  <bruno@clisp.org>
+
+       mbrtoc32: Avoid compilation failure on Haiku.
+       * m4/mbrtoc32.m4 (gl_CHECK_FUNC_MBRTOC32): New macro.
+       (gl_FUNC_MBRTOC32, gl_MBRTOC32_SANITYCHECK): Use it instead of
+       AC_CHECK_FUNCS_ONCE.
+       * doc/posix-functions/mbrtoc32.texi: Mention the Haiku problem.
+
 2020-05-08  Bruno Haible  <bruno@clisp.org>
 
        limits-h: Define LONG_BIT correctly on Haiku/x86_64.
index 3151a09fe256c567115db2a8a708eec744aa4ba8..647beb9ee470c9384febcce7934dcae24257b90f 100644 (file)
@@ -25,4 +25,7 @@ FreeBSD 12, Solaris 11.4, mingw, MSVC 14.
 
 Portability problems not fixed by Gnulib:
 @itemize
+@item
+This function is only defined as an inline function on some platforms:
+Haiku 2020.
 @end itemize
index a5dc51a7a0b092939a7ed4795c7fd9e4e0e5ec78..991bbc87cbe6abf568fd94fe9c144adfd861011d 100644 (file)
@@ -1,4 +1,4 @@
-# mbrtoc32.m4 serial 3
+# mbrtoc32.m4 serial 4
 dnl Copyright (C) 2014-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,
@@ -13,8 +13,8 @@ AC_DEFUN([gl_FUNC_MBRTOC32],
 
   AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
 
-  AC_CHECK_FUNCS_ONCE([mbrtoc32])
-  if test $ac_cv_func_mbrtoc32 = no; then
+  AC_REQUIRE([gl_CHECK_FUNC_MBRTOC32])
+  if test $gl_cv_func_mbrtoc32 = no; then
     HAVE_MBRTOC32=0
   else
     if test $REPLACE_MBSTATE_T = 1; then
@@ -43,6 +43,25 @@ AC_DEFUN([gl_FUNC_MBRTOC32],
   fi
 ])
 
+dnl We can't use AC_CHECK_FUNC here, because mbrtoc32() is defined as a
+dnl static inline function on Haiku 2020.
+AC_DEFUN([gl_CHECK_FUNC_MBRTOC32],
+[
+  AC_CACHE_CHECK([for mbrtoc32], [gl_cv_func_mbrtoc32],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <stdlib.h>
+            #include <uchar.h>
+          ]],
+          [[char32_t c;
+            return mbrtoc32 (&c, "", 1, NULL) == 0;
+          ]])
+       ],
+       [gl_cv_func_mbrtoc32=yes],
+       [gl_cv_func_mbrtoc32=no])
+    ])
+])
+
 AC_DEFUN([gl_MBRTOC32_EMPTY_INPUT],
 [
   AC_REQUIRE([AC_PROG_CC])
@@ -122,11 +141,11 @@ dnl Result is HAVE_WORKING_MBRTOC32.
 AC_DEFUN([gl_MBRTOC32_SANITYCHECK],
 [
   AC_REQUIRE([AC_PROG_CC])
-  AC_CHECK_FUNCS_ONCE([mbrtoc32])
+  AC_REQUIRE([gl_CHECK_FUNC_MBRTOC32])
   AC_REQUIRE([gt_LOCALE_FR])
   AC_REQUIRE([gt_LOCALE_ZH_CN])
   AC_REQUIRE([AC_CANONICAL_HOST]) dnl for cross-compiles
-  if test $ac_cv_func_mbrtoc32 = no; then
+  if test $gl_cv_func_mbrtoc32 = no; then
     HAVE_WORKING_MBRTOC32=0
   else
     AC_CACHE_CHECK([whether mbrtoc32 works as well as mbrtowc],