summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKO Myung-Hun <komh@chollian.net>2017-10-06 22:06:55 +0900
committerBruno Haible <bruno@clisp.org>2017-10-07 09:17:33 +0200
commitec285472ea54acd77f5a98c8e5b865cd55954d3c (patch)
treea1fc7a358c9933e570deb5ff966579db17656458
parent66a99150e921aac152b8d748d19bfed43fcb4e58 (diff)
downloadgnulib-ec285472ea54acd77f5a98c8e5b865cd55954d3c.tar.gz
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.
-rw-r--r--ChangeLog6
-rw-r--r--lib/wchar.in.h7
-rw-r--r--m4/wcwidth.m417
3 files changed, 22 insertions, 8 deletions
diff --git a/ChangeLog b/ChangeLog
index f4fa9644e5..470012f4b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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.
diff --git a/lib/wchar.in.h b/lib/wchar.in.h
index c65cc6668e..3307e235e3 100644
--- a/lib/wchar.in.h
+++ b/lib/wchar.in.h
@@ -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 @@ _GL_CXXALIAS_RPL (wcwidth, int, (wchar_t));
# 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
diff --git a/m4/wcwidth.m4 b/m4/wcwidth.m4
index 58716416cf..b44a9ed0fd 100644
--- a/m4/wcwidth.m4
+++ b/m4/wcwidth.m4
@@ -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 @@ AC_DEFUN([gl_FUNC_WCWIDTH],
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.