-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Paul Eggert on 1/11/2007 10:39 AM: > Eric Blake <[EMAIL PROTECTED]> writes: > >> At this point, I really think it is easier to generate a replacement >> <wchar.h> that takes care of the intricacies, > > Yes, I'd like a wchar module that provides wchar.h, so that we can > remove HAVE_WCHAR_H from most of the code.
Here's my first cut at it. It currently assumes that absolute <wchar.h> exists. I'm not sure whether it is worth trying to check for HAVE_WCHAR_H, or to leave that until we actually get a report of a system that needs it. I tested this on cygwin (where <wchar.h> works, and the module didn't have to replace anything; then I intentionally corrupted the system <wchar.h> to remove it's inclusion of <stddef.h>, and the patch did indeed work around that). I've made another M4 snapshot, and if Chris can compile it successfully on his BSD/OS system, we have a workable solution, although there still remain further simplifications to make throughout the rest of gnulib. 2007-01-12 Eric Blake <[EMAIL PROTECTED]> Provide a robust <wchar.h>. Further simplifications are now possible in other modules, but not included here. * modules/wchar: New module. * m4/wchar.m4: New file. * lib/wchar_.h: Likewise. * modules/mbchar (Depends-on): Depend on wchar, as the first use of the new module. * MODULES.html.sh (Wide character manipulation): Rename section, and document wchar module. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFp7Wh84KuGfSFAYARAu5YAKCZeQxIEVKsPziFzJRjUJWsHjA5qACdFFAu udQZEJZ6aQJ8frEV/fc+THM= =k4eO -----END PGP SIGNATURE-----
Index: MODULES.html.sh =================================================================== RCS file: /sources/gnulib/gnulib/MODULES.html.sh,v retrieving revision 1.170 diff -u -p -r1.170 MODULES.html.sh --- MODULES.html.sh 9 Jan 2007 16:14:04 -0000 1.170 +++ MODULES.html.sh 12 Jan 2007 16:00:10 -0000 @@ -1844,13 +1844,14 @@ func_all_modules () func_module strtoumax func_end_table - element="Wide character classification and mapping utilities <wctype.h>" + element="Wide character manipulation <wchar.h> and <wctype.h>" element=`printf "%s" "$element" | sed -e "$sed_lt" -e "$sed_gt"` func_section_wrap isoc_sup_wctype func_wrap H3 func_echo "$element" func_begin_table + func_module wchar func_module wctype func_end_table Index: modules/mbchar =================================================================== RCS file: /sources/gnulib/gnulib/modules/mbchar,v retrieving revision 1.7 diff -u -p -r1.7 mbchar --- modules/mbchar 27 Dec 2006 19:54:25 -0000 1.7 +++ modules/mbchar 12 Jan 2007 16:00:10 -0000 @@ -8,6 +8,7 @@ m4/mbchar.m4 Depends-on: stdbool +wchar wctype wcwidth Index: modules/wchar =================================================================== RCS file: modules/wchar diff -N modules/wchar --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ modules/wchar 12 Jan 2007 16:00:10 -0000 @@ -0,0 +1,35 @@ +Description: +A <wchar.h> that works around platform issues. + +Files: +lib/wchar_.h +m4/wchar.m4 + +Depends-on: +absolute-header + +configure.ac: +gl_WCHAR_H + +Makefile.am: +BUILT_SOURCES += $(WCHAR_H) + +# We need the following in order to create <wchar.h> when the system +# version does not work standalone. +wchar.h: wchar_.h + rm -f [EMAIL PROTECTED] $@ + { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \ + sed -e 's|@''ABSOLUTE_WCHAR_H''@|$(ABSOLUTE_WCHAR_H)|g' \ + < $(srcdir)/wchar_.h; \ + } > [EMAIL PROTECTED] + mv [EMAIL PROTECTED] $@ +MOSTLYCLEANFILES += wchar.h wcchar.h-t + +Include: +#include <wchar.h> + +License: +LGPL + +Maintainer: +all Index: lib/wchar_.h =================================================================== RCS file: lib/wchar_.h diff -N lib/wchar_.h --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lib/wchar_.h 12 Jan 2007 16:00:11 -0000 @@ -0,0 +1,42 @@ +/* A substitute for ISO C99 <wchar.h>, for platforms that have issues. + + Copyright (C) 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. */ + +/* Written by Eric Blake. */ + +/* + * ISO C 99 <wchar.h> for platforms that have issues. + * <http://www.opengroup.org/susv3xbd/wchar.h.html> + * + * For now, this just ensures proper prerequisite inclusion order. + */ + +#ifndef _GL_WCHAR_H +#define _GL_WCHAR_H + +/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before + <wchar.h>. + BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be + included before <wchar.h>. */ +#include <stddef.h> +#include <stdio.h> +#include <time.h> + +/* Include the original <wchar.h>. */ +#include @ABSOLUTE_WCHAR_H@ + +#endif /* _GL_WCHAR_H */ Index: m4/wchar.m4 =================================================================== RCS file: m4/wchar.m4 diff -N m4/wchar.m4 --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ m4/wchar.m4 12 Jan 2007 16:00:11 -0000 @@ -0,0 +1,29 @@ +dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues. + +dnl Copyright (C) 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, +dnl with or without modifications, as long as this notice is preserved. + +dnl Written by Eric Blake. + +# wchar.m4 serial 1 + +AC_DEFUN([gl_WCHAR_H], +[ + AC_CACHE_CHECK([whether <wchar.h> is standalone], + [gl_cv_header_wchar_h_standalone], + [AC_COMPILE_IFELSE([[#include <wchar.h> +wchar_t w;]], + [gl_cv_header_wchar_h_standalone=yes], + [gl_cv_header_wchar_h_standalone=no])]) + if test X"$gl_cv_header_wchar_h_standalone" = Xyes; then + WCHAR_H= + else + gl_ABSOLUTE_HEADER([wchar.h]) + ABSOLUTE_WCHAR_H=\"$gl_cv_absolute_wchar_h\" + WCHAR_H=wchar.h + fi + AC_SUBST([ABSOLUTE_WCHAR_H]) + AC_SUBST([WCHAR_H]) +])