Mercurial > hg > octave-lyh > gnulib-hg
changeset 9073:eff03f4ce262
Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h.
author | Bruno Haible <bruno@clisp.org> |
---|---|
date | Sat, 07 Jul 2007 20:59:43 +0000 |
parents | afbf42785753 |
children | 3948e119dd4f |
files | ChangeLog NEWS lib/mbchar.h lib/mbswidth.c lib/wchar_.h lib/wcwidth.c lib/wcwidth.h m4/wchar.m4 m4/wcwidth.m4 modules/wchar modules/wcwidth |
diffstat | 11 files changed, 114 insertions(+), 76 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2007-07-07 Bruno Haible <bruno@clisp.org> + + * lib/wchar_.h: Include the GL_LINK_WARNING macro. + (wcwidth): New declaration. + * m4/wchar.m4 (gl_WCHAR_MODULE_INDICATOR, gl_WCHAR_H_DEFAULTS): New + macros. + (gl_WCHAR_H): Require gl_WCHAR_H_DEFAULTS. Don't set WCHAR_H to empty + here. Prepare for creating <wchar.h> unconditionally. + * modules/wchar (Depends-on): Add link-warning. + (Makefile.am): Substitute also GNULIB_WCWIDTH, HAVE_DECL_WCWIDTH, + REPLACE_WCWIDTH, and GL_LINK_WARNING. + * lib/wcwidth.h: Remove file. + * m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Require gl_WCHAR_H_DEFAULTS. Set + HAVE_DECL_WCWIDTH, REPLACE_WCWIDTH, WCHAR_H. + * modules/wcwidth (Files): Remove lib/wcwidth.h. + (configure.ac): Invoke gl_WCHAR_MODULE_INDICATOR. + (Include): Replace wcwidth.h with <wchar.h>. + * lib/wcwidth.c: Include <wchar.h> instead of wcwidth.h. + * lib/mbchar.h: Don't include wcwidth.h. + * lib/mbswidth.c: Likewise. + * NEWS: Mention the change. + 2007-07-07 Bruno Haible <bruno@clisp.org> * lib/wcwidth.c: New file, extracted from lib/wcwidth.h.
--- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ Date Modules Changes +2007-07-07 wcwidth The include file is changed from "wcwidth.h" to + <wchar.h>. + 2007-07-02 gpl, lgpl Renamed to gpl-2.0 and lgpl-2.1 respectively. (There is also a new module gpl-3.0.)
--- a/lib/mbchar.h +++ b/lib/mbchar.h @@ -1,5 +1,5 @@ /* Multibyte character data type. - Copyright (C) 2001, 2005-2006 Free Software Foundation, Inc. + Copyright (C) 2001, 2005-2007 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -157,8 +157,6 @@ #include <wchar.h> #include <wctype.h> -#include "wcwidth.h" - #define MBCHAR_BUF_SIZE 24 struct mbchar
--- a/lib/mbswidth.c +++ b/lib/mbswidth.c @@ -30,12 +30,9 @@ /* Get isprint(). */ #include <ctype.h> -/* Get mbstate_t, mbrtowc(), mbsinit(). */ +/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ #include <wchar.h> -/* Get wcwidth(). */ -#include "wcwidth.h" - /* Get iswcntrl(). */ #include <wctype.h>
--- a/lib/wchar_.h +++ b/lib/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 */
--- a/lib/wcwidth.c +++ b/lib/wcwidth.c @@ -18,7 +18,7 @@ #include <config.h> /* Specification. */ -#include "wcwidth.h" +#include <wchar.h> /* Get iswprint. */ #include <wctype.h>
deleted file mode 100644 --- a/lib/wcwidth.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Determine the number of screen columns needed for a character. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2, or (at your option) - any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ - -#ifndef _gl_WCWIDTH_H -#define _gl_WCWIDTH_H - -#if HAVE_WCHAR_T - -/* Get wcwidth if available, along with wchar_t. */ -# include <wchar.h> - -# ifndef HAVE_DECL_WCWIDTH -"this configure-time declaration test was not run" -# endif -# ifndef wcwidth -# if !HAVE_WCWIDTH - -/* Defined by gnulib. */ -# define wcwidth rpl_wcwidth -extern int wcwidth (wchar_t); - -# 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_T */ - -#endif /* _gl_WCWIDTH_H */
--- a/m4/wchar.m4 +++ b/m4/wchar.m4 @@ -7,30 +7,48 @@ 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]) ])
--- a/m4/wcwidth.m4 +++ b/m4/wcwidth.m4 @@ -1,4 +1,4 @@ -# wcwidth.m4 serial 9 +# wcwidth.m4 serial 10 dnl Copyright (C) 2006, 2007 Free Software Foundation, Inc. dnl This file is free software; the Free Software Foundation dnl gives unlimited permission to copy and/or distribute it, @@ -6,6 +6,8 @@ AC_DEFUN([gl_FUNC_WCWIDTH], [ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + dnl Persuade glibc <wchar.h> to declare wcwidth(). AC_REQUIRE([AC_GNU_SOURCE]) @@ -27,8 +29,18 @@ #include <time.h> #include <wchar.h> ]) + if test $ac_cv_have_decl_wcwidth != yes; then + HAVE_DECL_WCWIDTH=0 + fi if test $ac_cv_func_wcwidth = no; then + REPLACE_WCWIDTH=1 + fi + if test $REPLACE_WCWIDTH = 1; then AC_LIBOBJ([wcwidth]) fi + + if test $REPLACE_WCWIDTH = 1 || test $HAVE_DECL_WCWIDTH = 0; then + WCHAR_H=wchar.h + fi ])
--- a/modules/wchar +++ b/modules/wchar @@ -7,6 +7,7 @@ Depends-on: include_next +link-warning configure.ac: gl_WCHAR_H @@ -22,6 +23,10 @@ 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 $@
--- a/modules/wcwidth +++ b/modules/wcwidth @@ -2,7 +2,6 @@ Determine the number of screen columns needed for a character. Files: -lib/wcwidth.h lib/wcwidth.c m4/wcwidth.m4 m4/wchar_t.m4 @@ -14,11 +13,12 @@ configure.ac: gl_FUNC_WCWIDTH +gl_WCHAR_MODULE_INDICATOR([wcwidth]) Makefile.am: Include: -"wcwidth.h" +<wchar.h> License: LGPL