From ec285472ea54acd77f5a98c8e5b865cd55954d3c Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Fri, 6 Oct 2017 22:06:55 +0900 Subject: [PATCH] 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. --- ChangeLog | 6 ++++++ lib/wchar.in.h | 7 +------ m4/wcwidth.m4 | 17 +++++++++++++++-- 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 + + 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 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 +#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. -- 2.39.5