+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.
+ * m4/wcwidth.m4 (gl_FUNC_WCWIDTH): Use wcwidth.c when wcwidth is not
+ defined as a function.
+ * modules/wcwidth (Files): Add lib/wcwidth.c.
+ (Makefile.am): Remove redundant statement.
+
2007-07-07 Bruno Haible <bruno@clisp.org>
* MODULES.html.sh (Unicode string functions): Add the new modules.
--- /dev/null
+/* 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. */
+
+#include <config.h>
+
+/* Specification. */
+#include "wcwidth.h"
+
+/* Get iswprint. */
+#include <wctype.h>
+
+int
+rpl_wcwidth (wchar_t wc)
+{
+ return wc == 0 ? 0 : iswprint (wc) ? 1 : -1;
+}
/* Get wcwidth if available, along with wchar_t. */
# include <wchar.h>
-/* Get iswprint. */
-# include <wctype.h>
-
# 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. */
-static inline int
-wcwidth (wchar_t wc)
-{
- return wc == 0 ? 0 : iswprint (wc) ? 1 : -1;
-}
+/* Defined by gnulib. */
+# define wcwidth rpl_wcwidth
+extern int wcwidth (wchar_t);
# elif !HAVE_DECL_WCWIDTH
-# wcwidth.m4 serial 8
+# 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,
#include <stdio.h>
#include <time.h>
#include <wchar.h>
-])])
+])
+
+ if test $ac_cv_func_wcwidth = no; then
+ AC_LIBOBJ([wcwidth])
+ fi
+])
Files:
lib/wcwidth.h
+lib/wcwidth.c
m4/wcwidth.m4
m4/wchar_t.m4
m4/wint_t.m4
gl_FUNC_WCWIDTH
Makefile.am:
-lib_SOURCES += wcwidth.h
Include:
"wcwidth.h"