diff options
Diffstat (limited to 'lgl')
-rw-r--r-- | lgl/Makefile.am | 4 | ||||
-rw-r--r-- | lgl/m4/wchar.m4 | 46 | ||||
-rw-r--r-- | lgl/wchar_.h | 35 |
3 files changed, 70 insertions, 15 deletions
diff --git a/lgl/Makefile.am b/lgl/Makefile.am index c880187d89..a143df0719 100644 --- a/lgl/Makefile.am +++ b/lgl/Makefile.am @@ -641,6 +641,10 @@ wchar.h: wchar_.h sed -e 's/@''INCLUDE_NEXT''@/$(INCLUDE_NEXT)/g' \ -e 's|@''NEXT_WCHAR_H''@|$(NEXT_WCHAR_H)|g' \ -e 's/@''HAVE_WCHAR_H''@/$(HAVE_WCHAR_H)/g' \ + -e 's|@''GNULIB_WCWIDTH''@|$(GNULIB_WCWIDTH)|g' \ + -e 's|@''HAVE_DECL_WCWIDTH''@|$(HAVE_DECL_WCWIDTH)|g' \ + -e 's|@''REPLACE_WCWIDTH''@|$(REPLACE_WCWIDTH)|g' \ + -e '/definition of GL_LINK_WARNING/r $(LINK_WARNING_H)' \ < $(srcdir)/wchar_.h; \ } > $@-t mv $@-t $@ diff --git a/lgl/m4/wchar.m4 b/lgl/m4/wchar.m4 index bf32d2831e..70b1248f8f 100644 --- a/lgl/m4/wchar.m4 +++ b/lgl/m4/wchar.m4 @@ -7,30 +7,48 @@ dnl with or without modifications, as long as this notice is preserved. dnl Written by Eric Blake. -# wchar.m4 serial 3 +# wchar.m4 serial 4 AC_DEFUN([gl_WCHAR_H], [ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) AC_CACHE_CHECK([whether <wchar.h> is standalone], [gl_cv_header_wchar_h_standalone], [AC_COMPILE_IFELSE([[#include <wchar.h> wchar_t w;]], [gl_cv_header_wchar_h_standalone=yes], [gl_cv_header_wchar_h_standalone=no])]) - if test $gl_cv_header_wchar_h_standalone = yes; then - WCHAR_H= - else - dnl Check for <wchar.h> (missing in Linux uClibc when built without wide - dnl character support). - AC_CHECK_HEADERS_ONCE([wchar.h]) - if test $ac_cv_header_wchar_h = yes; then - HAVE_WCHAR_H=1 - else - HAVE_WCHAR_H=0 - fi - AC_SUBST([HAVE_WCHAR_H]) - gl_CHECK_NEXT_HEADERS([wchar.h]) + if test $gl_cv_header_wchar_h_standalone != yes; then WCHAR_H=wchar.h fi + + dnl Prepare for creating substitute <wchar.h>. + dnl Do it always: WCHAR_H may be empty here but can be set later. + dnl Check for <wchar.h> (missing in Linux uClibc when built without wide + dnl character support). + AC_CHECK_HEADERS_ONCE([wchar.h]) + if test $ac_cv_header_wchar_h = yes; then + HAVE_WCHAR_H=1 + else + HAVE_WCHAR_H=0 + fi + AC_SUBST([HAVE_WCHAR_H]) + gl_CHECK_NEXT_HEADERS([wchar.h]) +]) + +AC_DEFUN([gl_WCHAR_MODULE_INDICATOR], +[ + dnl Use AC_REQUIRE here, so that the default settings are expanded once only. + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1 +]) + +AC_DEFUN([gl_WCHAR_H_DEFAULTS], +[ + GNULIB_WCWIDTH=0; AC_SUBST([GNULIB_WCWIDTH]) + dnl Assume proper GNU behavior unless another module says otherwise. + HAVE_DECL_WCWIDTH=1; AC_SUBST([HAVE_DECL_WCWIDTH]) + REPLACE_WCWIDTH=0; AC_SUBST([REPLACE_WCWIDTH]) + WCHAR_H= AC_SUBST([WCHAR_H]) ]) diff --git a/lgl/wchar_.h b/lgl/wchar_.h index 5b6a5f173d..0aba1cac10 100644 --- a/lgl/wchar_.h +++ b/lgl/wchar_.h @@ -22,7 +22,8 @@ * ISO C 99 <wchar.h> for platforms that have issues. * <http://www.opengroup.org/susv3xbd/wchar.h.html> * - * For now, this just ensures proper prerequisite inclusion order. + * For now, this just ensures proper prerequisite inclusion order and + * the declaration of wcwidth(). */ #ifndef _GL_WCHAR_H @@ -45,5 +46,37 @@ #ifndef _GL_WCHAR_H #define _GL_WCHAR_H +/* The definition of GL_LINK_WARNING is copied here. */ + +#ifdef __cplusplus +extern "C" { +#endif + + +/* Return the number of screen columns needed for WC. */ +#if @GNULIB_WCWIDTH@ +# if @REPLACE_WCWIDTH@ +# undef wcwidth +# define wcwidth rpl_wcwidth +extern int wcwidth (wchar_t); +# else +# if !defined wcwidth && !@HAVE_DECL_WCWIDTH@ +/* wcwidth exists but is not declared. */ +extern int wcwidth (int /* actually wchar_t */); +# endif +# endif +#elif defined GNULIB_POSIXCHECK +# undef wcwidth +# define wcwidth(w) \ + (GL_LINK_WARNING ("wcwidth is unportable - " \ + "use gnulib module wcwidth for portability"), \ + wcwidth (w)) +#endif + + +#ifdef __cplusplus +} +#endif + #endif /* _GL_WCHAR_H */ #endif /* _GL_WCHAR_H */ |