Remove the wcwidth.h file. Move wcwidth's declaration to wchar_.h.
authorBruno Haible <bruno@clisp.org>
Sat, 7 Jul 2007 20:59:43 +0000 (20:59 +0000)
committerBruno Haible <bruno@clisp.org>
Sat, 7 Jul 2007 20:59:43 +0000 (20:59 +0000)
ChangeLog
NEWS
lib/mbchar.h
lib/mbswidth.c
lib/wchar_.h
lib/wcwidth.c
lib/wcwidth.h [deleted file]
m4/wchar.m4
m4/wcwidth.m4
modules/wchar
modules/wcwidth

index 7f2b4c8..35b4e12 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,27 @@
 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.
        * lib/wcwidth.h: Don't include wctype.h. Replace inline function
        definition with an external declaration.
diff --git a/NEWS b/NEWS
index 9e95b24..f3040a4 100644 (file)
--- 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
+                            <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.)
 
index f3e28ef..213d425 100644 (file)
@@ -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
 #include <wchar.h>
 #include <wctype.h>
 
-#include "wcwidth.h"
-
 #define MBCHAR_BUF_SIZE 24
 
 struct mbchar
index 0bc1a68..012576e 100644 (file)
 /* 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>
 
index 1d52b1d..924a338 100644 (file)
@@ -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
 #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 */
index 6317083..57fb0a4 100644 (file)
@@ -18,7 +18,7 @@
 #include <config.h>
 
 /* Specification.  */
-#include "wcwidth.h"
+#include <wchar.h>
 
 /* Get iswprint.  */
 #include <wctype.h>
diff --git a/lib/wcwidth.h b/lib/wcwidth.h
deleted file mode 100644 (file)
index 8294458..0000000
+++ /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 */
index bf32d28..70b1248 100644 (file)
@@ -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 <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])
 ])
index fce3281..b6cedc2 100644 (file)
@@ -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 <wchar.h> to declare wcwidth().
   AC_REQUIRE([AC_GNU_SOURCE])
 
@@ -27,8 +29,18 @@ AC_DEFUN([gl_FUNC_WCWIDTH],
 #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
 ])
index 7cb8db3..a24f877 100644 (file)
@@ -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 $@
index a10d34a..622fa22 100644 (file)
@@ -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"
+<wchar.h>
 
 License:
 LGPL