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. --- lib/wchar.in.h | 7 +------ m4/wcwidth.m4 | 13 ++++++++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/wchar.in.h b/lib/wchar.in.h index c65cc6668..3307e235e 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 58716416c..decceec8c 100644 --- a/m4/wcwidth.m4 +++ b/m4/wcwidth.m4 @@ -34,7 +34,18 @@ AC_DEFUN([gl_FUNC_WCWIDTH], HAVE_DECL_WCWIDTH=0 fi - 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)]) + + if test $ac_cv_func_wcwidth = yes || + test $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. -- 2.13.3