From: Bruno Haible Date: Sat, 7 Jul 2007 20:59:43 +0000 (+0000) Subject: Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9e8ce574adfade2243a6141a1655addb92512aeb;hp=5407ddca850d0472f06fa0ef4ec8042e9353d25e;p=pspp Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h. --- diff --git a/ChangeLog b/ChangeLog index 7f2b4c883f..35b4e12cfe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2007-07-07 Bruno Haible + + * 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 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 . + * lib/wcwidth.c: Include 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 * lib/wcwidth.c: New file, extracted from lib/wcwidth.h. diff --git a/NEWS b/NEWS index 9e95b24e24..f3040a4a09 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,9 @@ User visible incompatible changes Date Modules Changes +2007-07-07 wcwidth The include file is changed from "wcwidth.h" to + . + 2007-07-02 gpl, lgpl Renamed to gpl-2.0 and lgpl-2.1 respectively. (There is also a new module gpl-3.0.) diff --git a/lib/mbchar.h b/lib/mbchar.h index f3e28ef5ca..213d425679 100644 --- 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 #include -#include "wcwidth.h" - #define MBCHAR_BUF_SIZE 24 struct mbchar diff --git a/lib/mbswidth.c b/lib/mbswidth.c index 0bc1a682c1..012576ed25 100644 --- a/lib/mbswidth.c +++ b/lib/mbswidth.c @@ -30,12 +30,9 @@ /* Get isprint(). */ #include -/* Get mbstate_t, mbrtowc(), mbsinit(). */ +/* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */ #include -/* Get wcwidth(). */ -#include "wcwidth.h" - /* Get iswcntrl(). */ #include diff --git a/lib/wchar_.h b/lib/wchar_.h index 1d52b1dd1d..924a3382d3 100644 --- a/lib/wchar_.h +++ b/lib/wchar_.h @@ -22,7 +22,8 @@ * ISO C 99 for platforms that have issues. * * - * 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 */ diff --git a/lib/wcwidth.c b/lib/wcwidth.c index 6317083435..57fb0a467b 100644 --- a/lib/wcwidth.c +++ b/lib/wcwidth.c @@ -18,7 +18,7 @@ #include /* Specification. */ -#include "wcwidth.h" +#include /* Get iswprint. */ #include diff --git a/lib/wcwidth.h b/lib/wcwidth.h deleted file mode 100644 index 8294458084..0000000000 --- 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 - -# 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 */ diff --git a/m4/wchar.m4 b/m4/wchar.m4 index bf32d2831e..70b1248f8f 100644 --- a/m4/wchar.m4 +++ b/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 is standalone], [gl_cv_header_wchar_h_standalone], [AC_COMPILE_IFELSE([[#include 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 (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 . + dnl Do it always: WCHAR_H may be empty here but can be set later. + dnl Check for (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/m4/wcwidth.m4 b/m4/wcwidth.m4 index fce3281577..b6cedc2430 100644 --- 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 @@ dnl with or without modifications, as long as this notice is preserved. AC_DEFUN([gl_FUNC_WCWIDTH], [ + AC_REQUIRE([gl_WCHAR_H_DEFAULTS]) + dnl Persuade glibc to declare wcwidth(). AC_REQUIRE([AC_GNU_SOURCE]) @@ -27,8 +29,18 @@ AC_DEFUN([gl_FUNC_WCWIDTH], #include #include ]) + 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 ]) diff --git a/modules/wchar b/modules/wchar index 7cb8db3920..a24f877ffc 100644 --- a/modules/wchar +++ b/modules/wchar @@ -7,6 +7,7 @@ m4/wchar.m4 Depends-on: include_next +link-warning configure.ac: gl_WCHAR_H @@ -22,6 +23,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/modules/wcwidth b/modules/wcwidth index a10d34a5fb..622fa228a8 100644 --- a/modules/wcwidth +++ b/modules/wcwidth @@ -2,7 +2,6 @@ Description: 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 @@ wctype configure.ac: gl_FUNC_WCWIDTH +gl_WCHAR_MODULE_INDICATOR([wcwidth]) Makefile.am: Include: -"wcwidth.h" + License: LGPL