changeset 38883:bbc77710939e

wcwidth: check a macro version of wcwidth () as well Check the functionality of a macro version wcwidth () as well as a real function. This is better than undefining wcwidth on OS/2 kLIBC without functional check. * lib/wchar.in.h: Revert commit caee51. * m4/wcwidth.m4 (gl_cv_func_wcwidth_macro): Check if wcwidth () is a macro.
author KO Myung-Hun <komh@chollian.net>
date Fri, 06 Oct 2017 22:06:55 +0900
parents ceeaebdb337f
children 3b3a14a120ae
files ChangeLog lib/wchar.in.h m4/wcwidth.m4
diffstat 3 files changed, 22 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Fri Oct 06 21:51:53 2017 +0200
+++ b/ChangeLog	Fri Oct 06 22:06:55 2017 +0900
@@ -1,3 +1,9 @@
+2017-10-06  KO Myung-Hun  <komh@chollian.net>
+
+	wcwidth: check a macro version of wcwidth () as well
+	* lib/wchar.in.h: Revert commit from 2016-01-14.
+	* m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Test if wcwidth is a macro.
+
 2017-10-06  Bruno Haible  <bruno@clisp.org>
 
 	getopt-posix: Clarify copyright header.
--- a/lib/wchar.in.h	Fri Oct 06 21:51:53 2017 +0200
+++ b/lib/wchar.in.h	Fri Oct 06 22:06:55 2017 +0900
@@ -31,7 +31,7 @@
 @PRAGMA_COLUMNS@
 
 #if (((defined __need_mbstate_t || defined __need_wint_t)               \
-      && !defined __MINGW32__ && !defined __KLIBC__)                    \
+      && !defined __MINGW32__)                                          \
      || (defined __hpux                                                 \
          && ((defined _INTTYPES_INCLUDED && !defined strtoimax)         \
              || defined _GL_JUST_INCLUDE_SYSTEM_WCHAR_H))               \
@@ -452,11 +452,6 @@
 #  if !@HAVE_DECL_WCWIDTH@
 /* wcwidth exists but is not declared.  */
 _GL_FUNCDECL_SYS (wcwidth, int, (wchar_t) _GL_ATTRIBUTE_PURE);
-#  elif defined __KLIBC__
-/* On OS/2 kLIBC, wcwidth is a macro that expands to the name of a
-   static inline function.  The implementation of wcwidth in wcwidth.c
-   causes a "conflicting types" error. */
-#   undef wcwidth
 #  endif
 _GL_CXXALIAS_SYS (wcwidth, int, (wchar_t));
 # endif
--- a/m4/wcwidth.m4	Fri Oct 06 21:51:53 2017 +0200
+++ b/m4/wcwidth.m4	Fri Oct 06 22:06:55 2017 +0900
@@ -1,4 +1,4 @@
-# wcwidth.m4 serial 23
+# wcwidth.m4 serial 24
 dnl Copyright (C) 2006-2017 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -34,7 +34,20 @@
     HAVE_DECL_WCWIDTH=0
   fi
 
-  if test $ac_cv_func_wcwidth = yes; then
+  if test $ac_cv_func_wcwidth != yes; then
+    AC_CACHE_CHECK([whether wcwidth is a macro],
+      [gl_cv_func_wcwidth_macro],
+      [AC_EGREP_CPP([wchar_header_defines_wcwidth], [
+#include <wchar.h>
+#ifdef wcwidth
+ wchar_header_defines_wcwidth
+#endif],
+         [gl_cv_func_wcwidth_macro=yes],
+         [gl_cv_func_wcwidth_macro=no])
+      ])
+  fi
+
+  if test $ac_cv_func_wcwidth = yes -o "$gl_cv_func_wcwidth_macro" = yes; then
     HAVE_WCWIDTH=1
     dnl On Mac OS X 10.3, wcwidth(0x0301) (COMBINING ACUTE ACCENT) returns 1.
     dnl On OpenBSD 5.0, wcwidth(0x05B0) (HEBREW POINT SHEVA) returns 1.