+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.
+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.
/* 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
#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. */
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 */
+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...
-# 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>. */
Files:
lib/wcwidth.h
m4/wcwidth.m4
+m4/wchar_t.m4
Depends-on: