summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--lib/ChangeLog6
-rw-r--r--lib/mbswidth.c16
-rw-r--r--lib/wcwidth.h44
-rw-r--r--m4/ChangeLog5
-rw-r--r--m4/wcwidth.m415
-rw-r--r--modules/wcwidth1
7 files changed, 71 insertions, 20 deletions
diff --git a/ChangeLog b/ChangeLog
index 479f08fd47..fc2109a172 100644
--- 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.
diff --git a/lib/ChangeLog b/lib/ChangeLog
index c2c012a697..9a7894c186 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -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.
diff --git a/lib/mbswidth.c b/lib/mbswidth.c
index 754d6df411..ef8398a786 100644
--- a/lib/mbswidth.c
+++ b/lib/mbswidth.c
@@ -32,10 +32,24 @@
/* 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
diff --git a/lib/wcwidth.h b/lib/wcwidth.h
index 80c0d9cda7..9af75e0a77 100644
--- a/lib/wcwidth.h
+++ b/lib/wcwidth.h
@@ -18,26 +18,32 @@
#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 */
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 9ab3570ac2..3ac1c64ca8 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -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...
diff --git a/m4/wcwidth.m4 b/m4/wcwidth.m4
index 01e554409c..19bcce6d63 100644
--- a/m4/wcwidth.m4
+++ b/m4/wcwidth.m4
@@ -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>. */
diff --git a/modules/wcwidth b/modules/wcwidth
index 6afb420631..060b0fb220 100644
--- a/modules/wcwidth
+++ b/modules/wcwidth
@@ -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: