[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wcwidth: remove wcwidth.h
From: |
Bruno Haible |
Subject: |
wcwidth: remove wcwidth.h |
Date: |
Sat, 7 Jul 2007 22:59:47 +0200 |
User-agent: |
KMail/1.5.4 |
Programs that use wcwidth() should, according to POSIX, include <wchar.h>.
There's no reason for gnulib having a separate "wcwidth.h" include file
(except that it was simpler in the beginning). This patch removes it.
2007-07-07 Bruno Haible <address@hidden>
* 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.
diff -c -3 -r1.21 NEWS
*** NEWS 2 Jul 2007 13:40:49 -0000 1.21
--- NEWS 7 Jul 2007 20:45:27 -0000
***************
*** 6,11 ****
--- 6,14 ----
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.)
*** lib/.cppi-disable 9 Jun 2007 11:27:30 -0000 1.29
--- lib/.cppi-disable 7 Jul 2007 20:45:27 -0000
***************
*** 39,42 ****
utimecmp.h
vasnprintf.h
vasprintf.h
- wcwidth.h
--- 39,41 ----
*** lib/mbchar.h 27 Dec 2006 19:54:25 -0000 1.10
--- lib/mbchar.h 7 Jul 2007 20:45:28 -0000
***************
*** 1,5 ****
/* Multibyte character data type.
! Copyright (C) 2001, 2005-2006 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
--- 1,5 ----
/* Multibyte character data type.
! 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,164 ****
#include <wchar.h>
#include <wctype.h>
- #include "wcwidth.h"
-
#define MBCHAR_BUF_SIZE 24
struct mbchar
--- 157,162 ----
*** lib/mbswidth.c 16 Jan 2007 16:31:23 -0000 1.21
--- lib/mbswidth.c 7 Jul 2007 20:45:28 -0000
***************
*** 30,41 ****
/* Get isprint(). */
#include <ctype.h>
! /* Get mbstate_t, mbrtowc(), mbsinit(). */
#include <wchar.h>
- /* Get wcwidth(). */
- #include "wcwidth.h"
-
/* Get iswcntrl(). */
#include <wctype.h>
--- 30,38 ----
/* Get isprint(). */
#include <ctype.h>
! /* Get mbstate_t, mbrtowc(), mbsinit(), wcwidth(). */
#include <wchar.h>
/* Get iswcntrl(). */
#include <wctype.h>
*** lib/wchar_.h 21 Jun 2007 04:39:11 -0000 1.7
--- lib/wchar_.h 7 Jul 2007 20:45:28 -0000
***************
*** 22,28 ****
* 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.
*/
#ifndef _GL_WCHAR_H
--- 22,29 ----
* 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 and
! * the declaration of wcwidth().
*/
#ifndef _GL_WCHAR_H
***************
*** 45,49 ****
--- 46,82 ----
#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 && address@hidden@
+ /* 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 */
*** lib/wcwidth.c 7 Jul 2007 19:27:06 -0000 1.1
--- lib/wcwidth.c 7 Jul 2007 20:45:28 -0000
***************
*** 18,24 ****
#include <config.h>
/* Specification. */
! #include "wcwidth.h"
/* Get iswprint. */
#include <wctype.h>
--- 18,24 ----
#include <config.h>
/* Specification. */
! #include <wchar.h>
/* Get iswprint. */
#include <wctype.h>
*** m4/wchar.m4 21 Jun 2007 04:39:10 -0000 1.3
--- m4/wchar.m4 7 Jul 2007 20:45:28 -0000
***************
*** 7,36 ****
dnl Written by Eric Blake.
! # wchar.m4 serial 3
AC_DEFUN([gl_WCHAR_H],
[
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])
WCHAR_H=wchar.h
fi
AC_SUBST([WCHAR_H])
])
--- 7,54 ----
dnl Written by Eric Blake.
! # 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=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])
])
*** m4/wcwidth.m4 7 Jul 2007 20:05:36 -0000 1.11
--- m4/wcwidth.m4 7 Jul 2007 20:45:28 -0000
***************
*** 1,4 ****
! # wcwidth.m4 serial 9
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,
--- 1,4 ----
! # 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,11 ****
--- 6,13 ----
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,34 ****
--- 29,46 ----
#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
])
*** modules/wchar 21 Jun 2007 04:39:11 -0000 1.4
--- modules/wchar 7 Jul 2007 20:45:28 -0000
***************
*** 7,12 ****
--- 7,13 ----
Depends-on:
include_next
+ link-warning
configure.ac:
gl_WCHAR_H
***************
*** 22,27 ****
--- 23,32 ----
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; \
} > address@hidden
mv address@hidden $@
*** modules/wcwidth 7 Jul 2007 19:27:06 -0000 1.7
--- modules/wcwidth 7 Jul 2007 20:45:28 -0000
***************
*** 2,8 ****
Determine the number of screen columns needed for a character.
Files:
- lib/wcwidth.h
lib/wcwidth.c
m4/wcwidth.m4
m4/wchar_t.m4
--- 2,7 ----
***************
*** 14,24 ****
configure.ac:
gl_FUNC_WCWIDTH
Makefile.am:
Include:
! "wcwidth.h"
License:
LGPL
--- 13,24 ----
configure.ac:
gl_FUNC_WCWIDTH
+ gl_WCHAR_MODULE_INDICATOR([wcwidth])
Makefile.am:
Include:
! <wchar.h>
License:
LGPL
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- wcwidth: remove wcwidth.h,
Bruno Haible <=