From: Bruno Haible Date: Wed, 28 Jun 2006 17:03:53 +0000 (+0000) Subject: Fixes after wcwidth module creation. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d0bcee4e6a778c34a4d3e4c922789219c16bfe4b;p=pspp Fixes after wcwidth module creation. --- diff --git a/ChangeLog b/ChangeLog index 479f08fd47..fc2109a172 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-06-28 Bruno Haible + + * modules/wcwidth (Files): Add m4/wchar_t.m4. + 2006-06-28 Eric Blake * modules/wcwidth: New file. diff --git a/lib/ChangeLog b/lib/ChangeLog index c2c012a697..9a7894c186 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2006-06-28 Bruno Haible + + * wcwidth.h: Declare nothing if !HAVE_WCHAR_T. Provide a fallback + declaration for wcwidth. + * mbswidth.c: Restore the includes of and . + 2006-06-28 Eric Blake * xvasprintf.h: Fix comments. diff --git a/lib/mbswidth.c b/lib/mbswidth.c index 754d6df411..ef8398a786 100644 --- a/lib/mbswidth.c +++ b/lib/mbswidth.c @@ -32,10 +32,24 @@ /* Get isprint(). */ #include -/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ +/* Get mbstate_t, mbrtowc(), mbsinit(). */ +#if HAVE_WCHAR_H +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.1 has a bug: and must be included before + . */ +# include +# include +# include +#endif + +/* Get wcwidth(). */ #include "wcwidth.h" /* Get iswcntrl(). */ +#if HAVE_WCTYPE_H +# include +#endif #if !defined iswcntrl && !HAVE_ISWCNTRL # define iswcntrl(wc) 0 #endif diff --git a/lib/wcwidth.h b/lib/wcwidth.h index 80c0d9cda7..9af75e0a77 100644 --- a/lib/wcwidth.h +++ b/lib/wcwidth.h @@ -18,26 +18,32 @@ #ifndef _gl_WCWIDTH_H #define _gl_WCWIDTH_H +#if HAVE_WCHAR_T + /* Get wcwidth if available, along with wchar_t. */ -#if HAVE_WCHAR_H +# if HAVE_WCHAR_H /* Tru64 with Desktop Toolkit C has a bug: must be included before . BSD/OS 4.1 has a bug: and must be included before . */ -# include -# include -# include -#endif +# include +# include +# include +# endif /* Get iswprint. */ -#if HAVE_WCTYPE_H -# include -#endif -#if !defined iswprint && !HAVE_ISWPRINT -# define iswprint(wc) 1 -#endif +# if HAVE_WCTYPE_H +# include +# endif +# if !defined iswprint && !HAVE_ISWPRINT +# define iswprint(wc) 1 +# endif -#if !defined wcwidth && !HAVE_WCWIDTH +# ifndef HAVE_DECL_WCWIDTH +"this configure-time declaration test was not run" +# endif +# ifndef wcwidth +# if !HAVE_WCWIDTH /* wcwidth doesn't exist, so assume all printable characters have width 1. */ @@ -47,6 +53,18 @@ wcwidth (wchar_t wc) return wc == 0 ? 0 : iswprint (wc) ? 1 : -1; } -#endif +# elif !HAVE_DECL_WCWIDTH + +/* wcwidth exists but is not declared. */ +extern +# ifdef __cplusplus +"C" +# endif +int wcwidth (int /* actually wchar_t */); + +# endif +# endif + +#endif /* HAVE_WCHAR_H */ #endif /* _gl_WCWIDTH_H */ diff --git a/m4/ChangeLog b/m4/ChangeLog index 9ab3570ac2..3ac1c64ca8 100644 --- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,8 @@ +2006-06-28 Bruno Haible + + * wcwidth.m4 (gl_FUNC_WCWIDTH): Also require AC_C_INLINE and + gt_TYPE_WCHAR_T. + 2006-06-28 Eric Blake * mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here... diff --git a/m4/wcwidth.m4 b/m4/wcwidth.m4 index 01e554409c..19bcce6d63 100644 --- a/m4/wcwidth.m4 +++ b/m4/wcwidth.m4 @@ -1,17 +1,20 @@ -# wcwidth.m4 serial 1 +# wcwidth.m4 serial 2 dnl Copyright (C) 2006 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, dnl with or without modifications, as long as this notice is preserved. -dnl autoconf tests required for use of mbswidth.c - AC_DEFUN([gl_FUNC_WCWIDTH], -[ AC_CHECK_HEADERS_ONCE([wchar.h wctype.h]) - AC_CHECK_FUNCS_ONCE([iswprint wcwidth]) - +[ + dnl Persuade glibc to declare wcwidth(). AC_REQUIRE([AC_GNU_SOURCE]) + AC_REQUIRE([AC_C_INLINE]) + AC_REQUIRE([gt_TYPE_WCHAR_T]) + + AC_CHECK_HEADERS_ONCE([wchar.h wctype.h]) + AC_CHECK_FUNCS_ONCE([iswprint wcwidth]) + AC_CACHE_CHECK([whether wcwidth is declared], [ac_cv_have_decl_wcwidth], [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ /* AIX 3.2.5 declares wcwidth in . */ diff --git a/modules/wcwidth b/modules/wcwidth index 6afb420631..060b0fb220 100644 --- a/modules/wcwidth +++ b/modules/wcwidth @@ -4,6 +4,7 @@ Determine the number of screen columns needed for a character. Files: lib/wcwidth.h m4/wcwidth.m4 +m4/wchar_t.m4 Depends-on: