Mercurial > hg > octave-lyh > gnulib-hg
changeset 6882:6f91a91ac710
Fixes after wcwidth module creation.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Wed, 28 Jun 2006 17:03:53 +0000 |
parents | b81cc83ca315 |
children | d15c3a06ecba |
files | ChangeLog lib/ChangeLog lib/mbswidth.c lib/wcwidth.h m4/ChangeLog m4/wcwidth.m4 modules/wcwidth |
diffstat | 7 files changed, 71 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2006-06-28 Bruno Haible <bruno@clisp.org> + + * modules/wcwidth (Files): Add m4/wchar_t.m4. + 2006-06-28 Eric Blake <ebb9@byu.net> * modules/wcwidth: New file.
--- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,9 @@ +2006-06-28 Bruno Haible <bruno@clisp.org> + + * wcwidth.h: Declare nothing if !HAVE_WCHAR_T. Provide a fallback + declaration for wcwidth. + * mbswidth.c: Restore the includes of <wchar.h> and <wctypes.h>. + 2006-06-28 Eric Blake <ebb9@byu.net> * xvasprintf.h: Fix comments.
--- a/lib/mbswidth.c +++ b/lib/mbswidth.c @@ -32,10 +32,24 @@ /* Get isprint(). */ #include <ctype.h> -/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ +/* Get mbstate_t, mbrtowc(), mbsinit(). */ +#if HAVE_WCHAR_H +/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before + <wchar.h>. + BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before + <wchar.h>. */ +# include <stdio.h> +# include <time.h> +# include <wchar.h> +#endif + +/* Get wcwidth(). */ #include "wcwidth.h" /* Get iswcntrl(). */ +#if HAVE_WCTYPE_H +# include <wctype.h> +#endif #if !defined iswcntrl && !HAVE_ISWCNTRL # define iswcntrl(wc) 0 #endif
--- 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: <stdio.h> must be included before <wchar.h>. BSD/OS 4.1 has a bug: <stdio.h> and <time.h> must be included before <wchar.h>. */ -# include <stdio.h> -# include <time.h> -# include <wchar.h> -#endif +# include <stdio.h> +# include <time.h> +# include <wchar.h> +# endif /* Get iswprint. */ -#if HAVE_WCTYPE_H -# include <wctype.h> -#endif -#if !defined iswprint && !HAVE_ISWPRINT -# define iswprint(wc) 1 -#endif +# if HAVE_WCTYPE_H +# include <wctype.h> +# 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 @@ 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 */
--- a/m4/ChangeLog +++ b/m4/ChangeLog @@ -1,3 +1,8 @@ +2006-06-28 Bruno Haible <bruno@clisp.org> + + * wcwidth.m4 (gl_FUNC_WCWIDTH): Also require AC_C_INLINE and + gt_TYPE_WCHAR_T. + 2006-06-28 Eric Blake <ebb9@byu.net> * mbswidth.m4 (gl_MBSDWIDTH): Move wcwidth from here...
--- 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], +[ + dnl Persuade glibc <wchar.h> to declare wcwidth(). + AC_REQUIRE([AC_GNU_SOURCE]) -AC_DEFUN([gl_FUNC_WCWIDTH], -[ AC_CHECK_HEADERS_ONCE([wchar.h wctype.h]) + 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_REQUIRE([AC_GNU_SOURCE]) - 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 <string.h>. */