* lib/wctype_.h, m4/wctype.m4, modules/wctype: New files.
* lib/fnmatch.c: Don't bother to include <wchar.h> before
<wctype.h>, since the new wctype module should fix this.
* lib/quotearg.c: Include <wctype.h> unconditionally, since
the wctype module should arrange for it.
* lib/regex_internal.h: Likewise.
* m4/quotearg.m4 (gl_QUOTEARG): Don't check for wctype.h or iswprint,
since the wctype module should handle this now.
* m4/regex.m4 (gl_PREREQ_REGEX): Don't check for wctype.h.
* modules/fnmatch (Depends-on): Add wctype.
* modules/quotearg (Depends-on): Likewise.
* modules/regex (Depends-on): Likewise.
+2006-12-21 Paul Eggert <eggert@cs.ucla.edu>
+
+ * MODULES.html.sh: New module wctype.
+ * lib/wctype_.h, m4/wctype.m4, modules/wctype: New files.
+ * lib/fnmatch.c: Don't bother to include <wchar.h> before
+ <wctype.h>, since the new wctype module should fix this.
+ * lib/quotearg.c: Include <wctype.h> unconditionally, since
+ the wctype module should arrange for it.
+ * lib/regex_internal.h: Likewise.
+ * m4/quotearg.m4 (gl_QUOTEARG): Don't check for wctype.h or iswprint,
+ since the wctype module should handle this now.
+ * m4/regex.m4 (gl_PREREQ_REGEX): Don't check for wctype.h.
+ * modules/fnmatch (Depends-on): Add wctype.
+ * modules/quotearg (Depends-on): Likewise.
+ * modules/regex (Depends-on): Likewise.
+
2006-12-19 Bruno Haible <bruno@clisp.org>
* lib/strdup.h [C++]: Wrap definitions in extern "C".
func_module strtoull
func_end_table
+ element="Wide character classification and mapping utilities <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 wctype
+ func_end_table
+
element="Functions for greatest-width integer types <inttypes.h>"
element=`printf "%s" "$element" | sed -e "$sed_lt" -e "$sed_gt"`
func_section_wrap isoc_sup_inttypes
/* For platform which support the ISO C amendement 1 functionality we
support user defined character classes. */
#if defined _LIBC || WIDE_CHAR_SUPPORT
-/* Solaris 2.5 has a bug: <wchar.h> must be included before <wctype.h>. */
-# include <wchar.h>
# include <wctype.h>
#endif
# define mbsinit(ps) 1
#endif
-#ifndef iswprint
-# if HAVE_WCTYPE_H
-# include <wctype.h>
-# endif
-# if !defined iswprint && !HAVE_ISWPRINT
-# define iswprint(wc) 1
-# endif
-#endif
+#include <wctype.h>
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t) -1)
#if defined HAVE_WCHAR_H || defined _LIBC
# include <wchar.h>
#endif /* HAVE_WCHAR_H || _LIBC */
-#if defined HAVE_WCTYPE_H || defined _LIBC
-# include <wctype.h>
-#endif /* HAVE_WCTYPE_H || _LIBC */
+#include <wctype.h>
#include <stdint.h>
#if defined _LIBC
# include <bits/libc-lock.h>
--- /dev/null
+/* A substitute for ISO C99 <wctype.h>, for platforms that lack it.
+
+ Copyright (C) 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. */
+
+/* Written by Bruno Haible and Paul Eggert. */
+
+/* iswctype, towctrans, towlower, towupper, wctrans, wctype,
+ wctrans_t, and wctype_t are not yet implemented. */
+
+#ifndef _GL_WCTYPE_H
+#define _GL_WCTYPE_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>
+
+#if @HAVE_WCTYPE_H@
+# include @ABSOLUTE_WCTYPE_H@
+#endif
+
+#if @HAVE_WCTYPE_CTMP_BUG@
+static wint_t _ctmp_;
+#endif
+
+/* FreeBSD 4.4 to 4.11 has <wctype.h> but lacks the functions.
+ Assume all 12 functions are implemented the same way, or not at all. */
+
+#if !defined iswalnum && !HAVE_ISWCNTRL
+static inline int
+iswalnum (wint_t wc)
+{
+ return ((wc >= '0' && wc <= '9')
+ || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z'));
+}
+# define iswalnum iswalnum
+#endif
+
+#if !defined iswalpha && !HAVE_ISWCNTRL
+static inline int
+iswalpha (wint_t wc)
+{
+ return (wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z';
+}
+# define iswalpha iswalpha
+#endif
+
+#if !defined iswblank && !HAVE_ISWCNTRL
+static inline int
+iswblank (wint_t wc)
+{
+ return wc == ' ' || wc == '\t';
+}
+# define iswblank iswblank
+#endif
+
+#if !defined iswcntrl && !HAVE_ISWCNTRL
+static inline int
+iswcntrl (wint_t wc)
+{
+ return (wc & ~0x1f) == 0 || wc == 0x7f;
+}
+# define iswcntrl iswcntrl
+#endif
+
+#if !defined iswdigit && !HAVE_ISWCNTRL
+static inline int
+iswdigit (wint_t wc)
+{
+ return wc >= '0' && wc <= '9';
+}
+# define iswdigit iswdigit
+#endif
+
+#if !defined iswgraph && !HAVE_ISWCNTRL
+static inline int
+iswgraph (wint_t wc)
+{
+ return wc >= '!' && wc <= '~';
+}
+# define iswgraph iswgraph
+#endif
+
+#if !defined iswlower && !HAVE_ISWCNTRL
+static inline int
+iswlower (wint_t wc)
+{
+ return wc >= 'a' && wc <= 'z';
+}
+# define iswlower iswlower
+#endif
+
+#if !defined iswprint && !HAVE_ISWCNTRL
+static inline int
+iswprint (wint_t wc)
+{
+ return wc >= ' ' && wc <= '~';
+}
+# define iswprint iswprint
+#endif
+
+#if !defined iswpunct && !HAVE_ISWCNTRL
+static inline int
+iswpunct (wint_t wc)
+{
+ return (wc >= '!' && wc <= '~'
+ && !((wc >= '0' && wc <= '9')
+ || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'Z')));
+}
+# define iswpunct iswpunct
+#endif
+
+#if !defined iswspace && !HAVE_ISWCNTRL
+static inline int
+iswspace (wint_t wc)
+{
+ return (wc == ' ' || wc == '\t'
+ || wc == '\n' || wc == '\v' || wc == '\f' || wc == '\r');
+}
+# define iswspace iswspace
+#endif
+
+#if !defined iswupper && !HAVE_ISWCNTRL
+static inline int
+iswupper (wint_t wc)
+{
+ return wc >= 'A' && wc <= 'Z';
+}
+# define iswupper iswupper
+#endif
+
+#if !defined iswxdigit && !HAVE_ISWCNTRL
+static inline int
+iswxdigit (wint_t wc)
+{
+ return ((wc >= '0' && wc <= '9')
+ || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F'));
+}
+# define iswxdigit iswxdigit
+#endif
+
+
+#endif /* _GL_WCTYPE_H */
AC_LIBOBJ([quotearg])
dnl Prerequisites of lib/quotearg.c.
- AC_CHECK_HEADERS_ONCE(wchar.h wctype.h)
- AC_CHECK_FUNCS_ONCE(iswprint mbsinit)
+ AC_CHECK_HEADERS_ONCE([wchar.h])
+ AC_CHECK_FUNCS_ONCE([mbsinit])
AC_TYPE_MBSTATE_T
gl_FUNC_MBRTOWC
])
AC_REQUIRE([AC_GNU_SOURCE])
AC_REQUIRE([AC_C_RESTRICT])
AC_REQUIRE([AM_LANGINFO_CODESET])
- AC_CHECK_HEADERS_ONCE([wchar.h wctype.h])
+ AC_CHECK_HEADERS_ONCE([wchar.h])
AC_CHECK_FUNCS_ONCE([iswctype mbrtowc mempcpy wcrtomb wcscoll])
AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
])
--- /dev/null
+dnl A placeholder for ISO C99 <wctype.h>, for platforms that lack it.
+
+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 Written by Paul Eggert.
+
+AC_DEFUN([gl_WCTYPE_H],
+[
+ AC_CHECK_FUNCS_ONCE([iswcntrl])
+ AC_CHECK_HEADERS_ONCE([wctype.h])
+ AC_REQUIRE([AC_C_INLINE])
+
+ if test $ac_cv_header_wctype_h = yes; then
+ gl_ABSOLUTE_HEADER([wctype.h])
+ ABSOLUTE_WCTYPE_H=\"$gl_cv_absolute_wctype_h\"
+ HAVE_WCTYPE_H=1
+ else
+ ABSOLUTE_WCTYPE_H=\"no/such/file/wctype.h\"
+ HAVE_WCTYPE_H=0
+ fi
+ AC_SUBST([ABSOLUTE_WCTYPE_H])
+ AC_SUBST([HAVE_WCTYPE_H])
+
+ WCTYPE_H=wctype.h
+ HAVE_WCTYPE_CTMP_BUG=0
+ if test $ac_cv_header_wctype_h = yes; then
+ AC_CACHE_CHECK([whether wctype macros need _ctmp_ declared],
+ [gl_cv_wctype_ctmp_bug],
+ [gl_cv_wctype_ctmp_bug=no
+ AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <wctype.h>
+ ]],
+ [[return iswprint (0);]])],
+ [gl_cv_wctype_ctmp_bug='no, but bare wctype.h does not work'],
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include <wctype.h>
+ static wint_t _ctmp_;]],
+ [[return iswprint (0);]])],
+ [gl_cv_wctype_ctmp_bug=yes])])])
+ case $gl_cv_wctype_ctmp_bug,$ac_cv_func_iswcntrl in #(
+ yes,*)
+ HAVE_WCTYPE_CTMP_BUG=1;; #(
+ no,yes)
+ WCTYPE_H=;;
+ esac
+ fi
+ AC_SUBST([WCTYPE_H])
+ AC_SUBST([HAVE_WCTYPE_CTMP_BUG])
+])
Depends-on:
alloca
stdbool
+wctype
configure.ac:
# No macro. You should also use one of fnmatch-posix or fnmatch-gnu.
xalloc
gettext-h
stdbool
+wctype
configure.ac:
gl_QUOTEARG
stdint
strcase
ssize_t
+wctype
configure.ac:
gl_REGEX
--- /dev/null
+Description:
+A <wctype.h> that conforms better to C99.
+
+Files:
+lib/wctype_.h
+m4/wctype.m4
+
+Depends-on:
+
+configure.ac:
+gl_WCTYPE_H
+
+Makefile.am:
+BUILT_SOURCES += $(WCTYPE_H)
+
+# We need the following in order to create <wctype.h> when the system
+# doesn't have one that works with the given compiler.
+wctype.h: wctype_.h
+ rm -f $@-t $@
+ { echo '/* DO NOT EDIT! GENERATED AUTOMATICALLY! */'; \
+ sed -e 's/@''HAVE_WCTYPE_H''@/$(HAVE_WCTYPE_H)/g' \
+ -e 's|@''ABSOLUTE_WCTYPE_H''@|$(ABSOLUTE_WCTYPE_H)|g' \
+ -e 's/@''HAVE_WCTYPE_CTMP_BUG''@/$(HAVE_WCTYPE_CTMP_BUG)/g' \
+ < $(srcdir)/wctype_.h; \
+ } > $@-t
+ mv $@-t $@
+MOSTLYCLEANFILES += wctype.h wctype.h-t
+
+Include:
+#include <wctype.h>
+
+License:
+LGPL
+
+Maintainer:
+all