]> Savannah Git Hosting - gnulib.git/commitdiff
c32rtomb: Avoid compilation failure on Haiku.
authorBruno Haible <bruno@clisp.org>
Sat, 9 May 2020 00:55:06 +0000 (02:55 +0200)
committerBruno Haible <bruno@clisp.org>
Sat, 9 May 2020 00:55:06 +0000 (02:55 +0200)
* m4/c32rtomb.m4 (gl_FUNC_C32RTOMB): Test for c32rtomb without excluding
inline definitions.
* doc/posix-functions/c32rtomb.texi: Mention the Haiku problem.

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

index 53a672a42ba0d6084598360b632189ac133f5b66..c22d515af1e3ffcf54acd977a66ee0422e61993e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2020-05-08  Bruno Haible  <bruno@clisp.org>
+
+       c32rtomb: Avoid compilation failure on Haiku.
+       * m4/c32rtomb.m4 (gl_FUNC_C32RTOMB): Test for c32rtomb without excluding
+       inline definitions.
+       * doc/posix-functions/c32rtomb.texi: Mention the Haiku problem.
+
 2020-05-08  Bruno Haible  <bruno@clisp.org>
 
        mbrtoc32: Avoid compilation failure on Haiku.
index 4a1a617babfbfa4bb8c88e6e38243e3d55ed64f7..fd4ada6779d1551660a8df122622a0231827d0b8 100644 (file)
@@ -16,4 +16,7 @@ AIX 7.2.
 
 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 4cf0e4deda909a8d92922bf5ad724d29d0602e37..f55ce3161b8fc4fd5a69eb7df4037491f581d716 100644 (file)
@@ -1,4 +1,4 @@
-# c32rtomb.m4 serial 1
+# c32rtomb.m4 serial 2
 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,
@@ -10,8 +10,22 @@ AC_DEFUN([gl_FUNC_C32RTOMB],
 
   AC_REQUIRE([gl_MBRTOC32_SANITYCHECK])
 
-  AC_CHECK_FUNCS_ONCE([c32rtomb])
-  if test $ac_cv_func_c32rtomb = no; then
+  dnl We can't use AC_CHECK_FUNC here, because c32rtomb() is defined as a
+  dnl static inline function on Haiku 2020.
+  AC_CACHE_CHECK([for c32rtomb], [gl_cv_func_c32rtomb],
+    [AC_LINK_IFELSE(
+       [AC_LANG_PROGRAM(
+          [[#include <stdlib.h>
+            #include <uchar.h>
+          ]],
+          [[char buf[8];
+            return c32rtomb (buf, 0, NULL) == 0;
+          ]])
+       ],
+       [gl_cv_func_c32rtomb=yes],
+       [gl_cv_func_c32rtomb=no])
+    ])
+  if test $gl_cv_func_c32rtomb = no; then
     HAVE_C32RTOMB=0
   else
     dnl When we override mbrtoc32, redefining the meaning of the char32_t