Fixes after wcwidth module creation.
authorBruno Haible <bruno@clisp.org>
Wed, 28 Jun 2006 17:03:53 +0000 (17:03 +0000)
committerBruno Haible <bruno@clisp.org>
Wed, 28 Jun 2006 17:03:53 +0000 (17:03 +0000)
ChangeLog
lib/ChangeLog
lib/mbswidth.c
lib/wcwidth.h
m4/ChangeLog
m4/wcwidth.m4
modules/wcwidth

index 479f08fd472d161b5e88d39c584c9b3c1f657d32..fc2109a172b3830b0dac61530fc5e87f5e64021f 100644 (file)
--- 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.
index c2c012a697a51a5920a46b8813f4e5bbf40aa64c..9a7894c186e8f3e26adcb58dae8d5973106ea813 100644 (file)
@@ -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.
index 754d6df411f97de534591963c230dfef7ada48fe..ef8398a78674063d5c8b992c26287e07ca36e9b8 100644 (file)
 /* 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
index 80c0d9cda7510b3a5dec218cd5154d34db387963..9af75e0a775841d38a455f232a5bd0429fa8d2bb 100644 (file)
 #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 @@ wcwidth (wchar_t wc)
   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 */
index 9ab3570ac2bac782b4ef8ae423cb1adc6205d380..3ac1c64ca8d49b0400e7eb72ea81ab05345edc42 100644 (file)
@@ -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...
index 01e554409c33aa69a25c24e86e6a9b1e2dec0e9c..19bcce6d63c9fff3eec85e6c66c02cf4ae9b9aff 100644 (file)
@@ -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],
-[ AC_CHECK_HEADERS_ONCE([wchar.h wctype.h])
-  AC_CHECK_FUNCS_ONCE([iswprint wcwidth])
-
+[
+  dnl Persuade glibc <wchar.h> to declare wcwidth().
   AC_REQUIRE([AC_GNU_SOURCE])
 
+  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_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>. */
index 6afb420631b6b4b05b79b3c0980b3a5cb6768b15..060b0fb220c1ea757513e2cb84241457650122ed 100644 (file)
@@ -4,6 +4,7 @@ Determine the number of screen columns needed for a character.
 Files:
 lib/wcwidth.h
 m4/wcwidth.m4
+m4/wchar_t.m4
 
 Depends-on: