Using cygwin to cross-compile to mingw, I got: $ CFLAGS='-Wall -O2' CC='gcc -mno-cygwin' ./gnulib-tool --test mbchar ... gcc -mno-cygwin -DHAVE_CONFIG_H -I. -I../../lib -I.. -Wall -O2 - c ../../lib/mbchar.c In file included from ../../lib/mbchar.c:24: ../../lib/mbchar.h: In function `mb_width_aux': ../../lib/mbchar.h:243: warning: implicit declaration of function `wcwidth' rm -f libgnu.a
I note that mbswidth.c takes precautions to ensure wcwidth exists; should we break that out into a wcwidth module and make both mbchar and mbswidth depend on it? This patch is my first cut at it; Bruno, I think you would be better as the maintainer since I broke it out of your mbswidth. ChangeLog: 2006-06-27 Eric Blake <[EMAIL PROTECTED]> * modules/wcwidth: New file. * modules/mbchar (Depends-on): Add wcwidth. * modules/mbswidth (Depends-on): Add wcwidth. * MODULES.html.sh: Add wcwidth. lib/ChangeLog: 2006-06-27 Eric Blake <[EMAIL PROTECTED]> * mbchar.h (wcwidth): Include wcwidth.h. * mbswidth.c (wcwidth): Move from here... * wcwidth.h: ...to this new file. m4/ChangeLog: 2006-06-27 Eric Blake <[EMAIL PROTECTED]> * mbswidth.m4 (gl_MBSWIDTH): Move wcwidth from here... * wcwidth.m4 (gl_WCWIDTH): ...to this new file. Index: MODULES.html.sh =================================================================== RCS file: /sources/gnulib/gnulib/MODULES.html.sh,v retrieving revision 1.117 diff -u -r1.117 MODULES.html.sh --- MODULES.html.sh 21 Jun 2006 10:00:08 -0000 1.117 +++ MODULES.html.sh 27 Jun 2006 15:42:53 -0000 @@ -1775,6 +1775,7 @@ func_module mbiter func_module mbuiter func_module mbfile + func_module wcwidth func_end_table element="Support for systems lacking POSIX:2001" Index: lib/mbchar.h =================================================================== RCS file: /sources/gnulib/gnulib/lib/mbchar.h,v retrieving revision 1.2 diff -u -r1.2 mbchar.h --- lib/mbchar.h 16 Aug 2005 16:07:59 -0000 1.2 +++ lib/mbchar.h 27 Jun 2006 15:42:54 -0000 @@ -1,5 +1,5 @@ /* Multibyte character data type. - Copyright (C) 2001, 2005 Free Software Foundation, Inc. + Copyright (C) 2001, 2005-2006 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 @@ -158,6 +158,8 @@ #include <wctype.h> +#include "wcwidth.h" + #define MBCHAR_BUF_SIZE 24 struct mbchar Index: lib/mbswidth.c =================================================================== RCS file: /sources/gnulib/gnulib/lib/mbswidth.c,v retrieving revision 1.14 diff -u -r1.14 mbswidth.c --- lib/mbswidth.c 14 May 2005 06:03:58 -0000 1.14 +++ lib/mbswidth.c 27 Jun 2006 15:42:54 -0000 @@ -1,5 +1,5 @@ /* Determine the number of screen columns needed for a string. - Copyright (C) 2000-2005 Free Software Foundation, Inc. + Copyright (C) 2000-2006 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 @@ -60,20 +60,8 @@ # endif #endif -#ifndef HAVE_DECL_WCWIDTH -"this configure-time declaration test was not run" -#endif -#if !HAVE_DECL_WCWIDTH -int wcwidth (); -#endif - -#ifndef wcwidth -# if !HAVE_WCWIDTH -/* wcwidth doesn't exist, so assume all printable characters have - width 1. */ -# define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -1) -# endif -#endif +/* Get wcwidth. */ +#include "wcwidth.h" /* Get ISPRINT. */ #if defined (STDC_HEADERS) || (!defined (isascii) && !defined (HAVE_ISASCII)) Index: lib/wcwidth.h =================================================================== RCS file: lib/wcwidth.h diff -N lib/wcwidth.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/wcwidth.h 27 Jun 2006 15:42:54 -0000 @@ -0,0 +1,34 @@ +/* Determine the number of screen columns needed for a character. + Copyright (C) 2000-2006 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 HAVE_DECL_WCWIDTH +"this configure-time declaration test was not run" +#endif +#if !HAVE_DECL_WCWIDTH +# ifdef __cplusplus +extern "C" +# endif +int wcwidth (); +#endif + +#ifndef wcwidth +# if !HAVE_WCWIDTH +/* wcwidth doesn't exist, so assume all printable characters have + width 1. */ +# define wcwidth(wc) ((wc) == 0 ? 0 : iswprint (wc) ? 1 : -1) +# endif +#endif Index: m4/mbswidth.m4 =================================================================== RCS file: /sources/gnulib/gnulib/m4/mbswidth.m4,v retrieving revision 1.14 diff -u -r1.14 mbswidth.m4 --- m4/mbswidth.m4 18 Jan 2005 13:07:56 -0000 1.14 +++ m4/mbswidth.m4 27 Jun 2006 15:42:54 -0000 @@ -1,5 +1,5 @@ -# mbswidth.m4 serial 11 -dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc. +# mbswidth.m4 serial 12 +dnl Copyright (C) 2000-2002, 2004, 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. @@ -11,31 +11,9 @@ [ AC_CHECK_HEADERS_ONCE(wchar.h wctype.h) AC_CHECK_FUNCS_ONCE(isascii iswprint mbsinit) - AC_CHECK_FUNCS(iswcntrl wcwidth) + AC_CHECK_FUNCS(iswcntrl) gl_FUNC_MBRTOWC - AC_CACHE_CHECK([whether wcwidth is declared], ac_cv_have_decl_wcwidth, - [AC_TRY_COMPILE([ -/* AIX 3.2.5 declares wcwidth in <string.h>. */ -#if HAVE_STRING_H -# include <string.h> -#endif -#if HAVE_WCHAR_H -# include <wchar.h> -#endif -], [ -#ifndef wcwidth - char *p = (char *) wcwidth; -#endif -], ac_cv_have_decl_wcwidth=yes, ac_cv_have_decl_wcwidth=no)]) - if test $ac_cv_have_decl_wcwidth = yes; then - ac_val=1 - else - ac_val=0 - fi - AC_DEFINE_UNQUOTED(HAVE_DECL_WCWIDTH, $ac_val, - [Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.]) - dnl UnixWare 7.1.1 <wchar.h> has a declaration of a function mbswidth() dnl that clashes with ours. AC_CACHE_CHECK([whether mbswidth is declared in <wchar.h>], Index: m4/wcwidth.m4 =================================================================== RCS file: m4/wcwidth.m4 diff -N m4/wcwidth.m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ m4/wcwidth.m4 27 Jun 2006 15:42:54 -0000 @@ -0,0 +1,34 @@ +# wcwidth.m4 serial 1 +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_WCWIDTH], +[ + AC_CHECK_FUNCS([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>. */ +#if HAVE_STRING_H +# include <string.h> +#endif +#if HAVE_WCHAR_H +# include <wchar.h> +#endif +], [ +#ifndef wcwidth + char *p = (char *) wcwidth; +#endif +])], [ac_cv_have_decl_wcwidth=yes], [ac_cv_have_decl_wcwidth=no])]) + if test $ac_cv_have_decl_wcwidth = yes; then + ac_val=1 + else + ac_val=0 + fi + AC_DEFINE_UNQUOTED([HAVE_DECL_WCWIDTH], [$ac_val], + [Define to 1 if you have the declaration of wcwidth(), and to 0 otherwise.]) +]) Index: modules/mbchar =================================================================== RCS file: /sources/gnulib/gnulib/modules/mbchar,v retrieving revision 1.2 diff -u -r1.2 mbchar --- modules/mbchar 26 Sep 2005 13:58:51 -0000 1.2 +++ modules/mbchar 27 Jun 2006 15:42:54 -0000 @@ -8,6 +8,7 @@ Depends-on: stdbool +wcwidth configure.ac: gl_MBCHAR Index: modules/mbswidth =================================================================== RCS file: /sources/gnulib/gnulib/modules/mbswidth,v retrieving revision 1.4 diff -u -r1.4 mbswidth --- modules/mbswidth 22 Sep 2004 15:11:04 -0000 1.4 +++ modules/mbswidth 27 Jun 2006 15:42:54 -0000 @@ -9,6 +9,7 @@ m4/mbswidth.m4 Depends-on: +wcwidth configure.ac: gl_MBSWIDTH Index: modules/wcwidth =================================================================== RCS file: modules/wcwidth diff -N modules/wcwidth --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/wcwidth 27 Jun 2006 15:42:54 -0000 @@ -0,0 +1,23 @@ +Description: +Determine the number of screen columns needed for a character. + +Files: +lib/wcwidth.h +m4/wcwidth.m4 + +Depends-on: + +configure.ac: +gl_WCWIDTH + +Makefile.am: +lib_SOURCES += wcwidth.h + +Include: +"wcwidth.h" + +License: +GPL + +Maintainer: +Bruno Haible