From eb944d1d03d408d829b4fa68eefd3a1ae94f9eb5 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 6 Feb 2011 23:59:34 +0100 Subject: [PATCH] New module 'iswctype'. * modules/iswctype: New file. * lib/wctype.in.h (iswctype): New declaration. * lib/iswctype.c: New file. * lib/iswctype-impl.h: New file. * m4/iswctype.m4: New file. * m4/wctype_h.m4 (gl_WCTYPE_H): Test whether iswctype is declared. (gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_ISWCTYPE. * modules/wctype-h (Makefile.am): Substitute GNULIB_ISWCTYPE. * tests/test-wctype-h-c++.cc: Test the declaration of iswctype. * doc/posix-functions/iswctype.texi: Mention the new module and the HP-UX 11.00 problem. --- ChangeLog | 15 +++++++++++++++ doc/posix-functions/iswctype.texi | 12 ++++++++---- lib/iswctype-impl.h | 22 ++++++++++++++++++++++ lib/iswctype.c | 23 +++++++++++++++++++++++ lib/wctype.in.h | 17 +++++++++++++++++ m4/iswctype.m4 | 14 ++++++++++++++ m4/wctype_h.m4 | 3 ++- modules/iswctype | 31 +++++++++++++++++++++++++++++++ modules/wctype-h | 1 + tests/test-wctype-h-c++.cc | 4 ++++ 10 files changed, 137 insertions(+), 5 deletions(-) create mode 100644 lib/iswctype-impl.h create mode 100644 lib/iswctype.c create mode 100644 m4/iswctype.m4 create mode 100644 modules/iswctype diff --git a/ChangeLog b/ChangeLog index daf65354e..a37ab001c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,20 @@ 2011-02-06 Bruno Haible + New module 'iswctype'. + * modules/iswctype: New file. + * lib/wctype.in.h (iswctype): New declaration. + * lib/iswctype.c: New file. + * lib/iswctype-impl.h: New file. + * m4/iswctype.m4: New file. + * m4/wctype_h.m4 (gl_WCTYPE_H): Test whether iswctype is declared. + (gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_ISWCTYPE. + * modules/wctype-h (Makefile.am): Substitute GNULIB_ISWCTYPE. + * tests/test-wctype-h-c++.cc: Test the declaration of iswctype. + * doc/posix-functions/iswctype.texi: Mention the new module and the + HP-UX 11.00 problem. + +2011-02-06 Bruno Haible + New module 'wctype'. * modules/wctype: Change to represent the wctype() substitute. * lib/wctype.in.h (wctype): New declaration. diff --git a/doc/posix-functions/iswctype.texi b/doc/posix-functions/iswctype.texi index 5691b1d6c..144df4a14 100644 --- a/doc/posix-functions/iswctype.texi +++ b/doc/posix-functions/iswctype.texi @@ -4,18 +4,22 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/iswctype.html} -Gnulib module: --- +Gnulib module: iswctype Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +IRIX 5.3, Solaris 2.5.1. +@item +This function is declared in @code{}, not in @code{}, on +some platforms: +HP-UX 11.00. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -IRIX 5.3, Solaris 2.5.1. -@item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff --git a/lib/iswctype-impl.h b/lib/iswctype-impl.h new file mode 100644 index 000000000..8a88d6f34 --- /dev/null +++ b/lib/iswctype-impl.h @@ -0,0 +1,22 @@ +/* Test whether a wide character has a given property. + Copyright (C) 2011 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + 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 3 of the License, 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, see . */ + +int +iswctype (wint_t wc, wctype_t desc) +{ + return ((int (*) (wint_t)) desc) (wc); +} diff --git a/lib/iswctype.c b/lib/iswctype.c new file mode 100644 index 000000000..6f4c3626c --- /dev/null +++ b/lib/iswctype.c @@ -0,0 +1,23 @@ +/* Test whether a wide character has a given property. + Copyright (C) 2011 Free Software Foundation, Inc. + Written by Bruno Haible , 2011. + + 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 3 of the License, 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, see . */ + +#include + +/* Specification. */ +#include + +#include "iswctype-impl.h" diff --git a/lib/wctype.in.h b/lib/wctype.in.h index f88e506b9..a295a091f 100644 --- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -399,6 +399,23 @@ _GL_WARN_ON_USE (wctype, "wctype is unportable - " # endif #endif +/* Test whether a wide character has a given property. + The argument WC must be either a wchar_t value or WEOF. + The argument DESC must have been returned by the wctype() function. */ +#if @GNULIB_ISWCTYPE@ +# if !@HAVE_WCTYPE_T@ +_GL_FUNCDECL_SYS (iswctype, int, (wint_t wc, wctype_t desc)); +# endif +_GL_CXXALIAS_SYS (iswctype, int, (wint_t wc, wctype_t desc)); +_GL_CXXALIASWARN (iswctype); +#elif defined GNULIB_POSIXCHECK +# undef iswctype +# if HAVE_RAW_DECL_ISWCTYPE +_GL_WARN_ON_USE (iswctype, "iswctype is unportable - " + "use gnulib module iswctype for portability"); +# endif +#endif + #if @REPLACE_ISWCNTRL@ || defined __MINGW32__ _GL_CXXALIAS_RPL (towlower, wint_t, (wint_t wc)); _GL_CXXALIAS_RPL (towupper, wint_t, (wint_t wc)); diff --git a/m4/iswctype.m4 b/m4/iswctype.m4 new file mode 100644 index 000000000..2f0120f16 --- /dev/null +++ b/m4/iswctype.m4 @@ -0,0 +1,14 @@ +# iswctype.m4 serial 1 +dnl Copyright (C) 2011 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. + +AC_DEFUN([gl_FUNC_ISWCTYPE], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + if test $HAVE_WCTYPE_T = 0; then + AC_LIBOBJ([iswctype]) + fi +]) diff --git a/m4/wctype_h.m4 b/m4/wctype_h.m4 index 23f91759c..584083dee 100644 --- a/m4/wctype_h.m4 +++ b/m4/wctype_h.m4 @@ -146,7 +146,7 @@ AC_DEFUN([gl_WCTYPE_H], #endif #include ]], - [wctype + [wctype iswctype ]) ]) @@ -163,6 +163,7 @@ AC_DEFUN([gl_WCTYPE_H_DEFAULTS], [ GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK]) GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE]) + GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE]) dnl Assume proper GNU behavior unless another module says otherwise. HAVE_ISWBLANK=1; AC_SUBST([HAVE_ISWBLANK]) HAVE_WCTYPE_T=1; AC_SUBST([HAVE_WCTYPE_T]) diff --git a/modules/iswctype b/modules/iswctype new file mode 100644 index 000000000..7054eaa31 --- /dev/null +++ b/modules/iswctype @@ -0,0 +1,31 @@ +Description: +iswctype() function: test whether a wide character has a given property. + +Status: +obsolete + +Notice: +This module is obsolete. + +Files: +lib/iswctype.c +lib/iswctype-impl.h +m4/iswctype.m4 + +Depends-on: +wctype-h + +configure.ac: +gl_FUNC_ISWCTYPE +gl_WCTYPE_MODULE_INDICATOR([iswctype]) + +Makefile.am: + +Include: + + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/wctype-h b/modules/wctype-h index 4c3bdebf7..8ff881c4c 100644 --- a/modules/wctype-h +++ b/modules/wctype-h @@ -29,6 +29,7 @@ wctype.h: wctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) -e 's|@''NEXT_WCTYPE_H''@|$(NEXT_WCTYPE_H)|g' \ -e 's/@''GNULIB_ISWBLANK''@/$(GNULIB_ISWBLANK)/g' \ -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \ + -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \ -e 's/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ diff --git a/tests/test-wctype-h-c++.cc b/tests/test-wctype-h-c++.cc index 51e9213ce..17337cc90 100644 --- a/tests/test-wctype-h-c++.cc +++ b/tests/test-wctype-h-c++.cc @@ -43,6 +43,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::iswxdigit, int, (wint_t)); SIGNATURE_CHECK (GNULIB_NAMESPACE::wctype, wctype_t, (const char *)); #endif +#if GNULIB_TEST_ISWCTYPE +SIGNATURE_CHECK (GNULIB_NAMESPACE::iswctype, int, (wint_t, wctype_t)); +#endif + SIGNATURE_CHECK (GNULIB_NAMESPACE::towlower, wint_t, (wint_t)); SIGNATURE_CHECK (GNULIB_NAMESPACE::towupper, wint_t, (wint_t)); -- 2.11.0