# HG changeset patch # User Bruno Haible # Date 1297032340 -3600 # Node ID aef6efcc4045718c8ba567d6ad4436adfbbc421d # Parent 18ad0b0246fcfae6fbd3ad5c6d69cb928bf74b77 New module 'wctype'. * modules/wctype: Change to represent the wctype() substitute. * lib/wctype.in.h (wctype): New declaration. * lib/wctype.c: New file. * lib/wctype-impl.h: New file. * m4/wctype.m4: New file. * m4/wctype_h.m4 (gl_WCTYPE_H): Test whether wctype is declared. (gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_WCTYPE. * modules/wctype-h (Makefile.am): Substitute GNULIB_WCTYPE. * tests/test-wctype-h-c++.cc: Test the declaration of wctype. * doc/posix-functions/wctype.texi: Mention the new module and the HP-UX 11.00 problem. diff -r 18ad0b0246fc -r aef6efcc4045 ChangeLog --- a/ChangeLog Sun Feb 06 23:18:30 2011 +0100 +++ b/ChangeLog Sun Feb 06 23:45:40 2011 +0100 @@ -1,3 +1,18 @@ +2011-02-06 Bruno Haible + + New module 'wctype'. + * modules/wctype: Change to represent the wctype() substitute. + * lib/wctype.in.h (wctype): New declaration. + * lib/wctype.c: New file. + * lib/wctype-impl.h: New file. + * m4/wctype.m4: New file. + * m4/wctype_h.m4 (gl_WCTYPE_H): Test whether wctype is declared. + (gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_WCTYPE. + * modules/wctype-h (Makefile.am): Substitute GNULIB_WCTYPE. + * tests/test-wctype-h-c++.cc: Test the declaration of wctype. + * doc/posix-functions/wctype.texi: Mention the new module and the + HP-UX 11.00 problem. + 2011-02-06 Bruno Haible wctype-h: Ensure wctype_t and wctrans_t are defined. diff -r 18ad0b0246fc -r aef6efcc4045 doc/posix-functions/wctype.texi --- a/doc/posix-functions/wctype.texi Sun Feb 06 23:18:30 2011 +0100 +++ b/doc/posix-functions/wctype.texi Sun Feb 06 23:45:40 2011 +0100 @@ -4,18 +4,22 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/wctype.html} -Gnulib module: --- +Gnulib module: wctype 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, mingw. -@item On AIX and Windows platforms, @code{wchar_t} is a 16-bit type and therefore cannot accommodate all Unicode characters. @end itemize diff -r 18ad0b0246fc -r aef6efcc4045 lib/wctype-impl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/wctype-impl.h Sun Feb 06 23:45:40 2011 +0100 @@ -0,0 +1,96 @@ +/* Get descriptor for a wide character 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 . */ + +wctype_t +wctype (const char* name) +{ + switch (name[0]) + { + case 'a': + switch (name[1]) + { + case 'l': + switch (name[2]) + { + case 'n': + if (strcmp (name + 3, "um") == 0) + return (wctype_t) iswalnum; + break; + case 'p': + if (strcmp (name + 3, "ha") == 0) + return (wctype_t) iswalpha; + break; + default: + break; + } + break; + default: + break; + } + break; + case 'b': + if (strcmp (name + 1, "lank") == 0) + return (wctype_t) iswblank; + break; + case 'c': + if (strcmp (name + 1, "ntrl") == 0) + return (wctype_t) iswcntrl; + break; + case 'd': + if (strcmp (name + 1, "igit") == 0) + return (wctype_t) iswdigit; + break; + case 'g': + if (strcmp (name + 1, "raph") == 0) + return (wctype_t) iswgraph; + break; + case 'l': + if (strcmp (name + 1, "ower") == 0) + return (wctype_t) iswlower; + break; + case 'p': + switch (name[1]) + { + case 'r': + if (strcmp (name + 2, "int") == 0) + return (wctype_t) iswprint; + break; + case 'u': + if (strcmp (name + 2, "nct") == 0) + return (wctype_t) iswpunct; + break; + default: + break; + } + break; + case 's': + if (strcmp (name + 1, "pace") == 0) + return (wctype_t) iswspace; + break; + case 'u': + if (strcmp (name + 1, "pper") == 0) + return (wctype_t) iswupper; + break; + case 'x': + if (strcmp (name + 1, "digit") == 0) + return (wctype_t) iswxdigit; + break; + default: + break; + } + return NULL; +} diff -r 18ad0b0246fc -r aef6efcc4045 lib/wctype.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/wctype.c Sun Feb 06 23:45:40 2011 +0100 @@ -0,0 +1,25 @@ +/* Get descriptor for a wide character 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 + +#include "wctype-impl.h" diff -r 18ad0b0246fc -r aef6efcc4045 lib/wctype.in.h --- a/lib/wctype.in.h Sun Feb 06 23:18:30 2011 +0100 +++ b/lib/wctype.in.h Sun Feb 06 23:45:40 2011 +0100 @@ -384,6 +384,21 @@ # endif #endif +/* Get a descriptor for a wide character property. */ +#if @GNULIB_WCTYPE@ +# if !@HAVE_WCTYPE_T@ +_GL_FUNCDECL_SYS (wctype, wctype_t, (const char *name)); +# endif +_GL_CXXALIAS_SYS (wctype, wctype_t, (const char *name)); +_GL_CXXALIASWARN (wctype); +#elif defined GNULIB_POSIXCHECK +# undef wctype +# if HAVE_RAW_DECL_WCTYPE +_GL_WARN_ON_USE (wctype, "wctype is unportable - " + "use gnulib module wctype 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 -r 18ad0b0246fc -r aef6efcc4045 m4/wctype.m4 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/m4/wctype.m4 Sun Feb 06 23:45:40 2011 +0100 @@ -0,0 +1,14 @@ +# wctype.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_WCTYPE], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + if test $HAVE_WCTYPE_T = 0; then + AC_LIBOBJ([wctype]) + fi +]) diff -r 18ad0b0246fc -r aef6efcc4045 m4/wctype_h.m4 --- a/m4/wctype_h.m4 Sun Feb 06 23:18:30 2011 +0100 +++ b/m4/wctype_h.m4 Sun Feb 06 23:45:40 2011 +0100 @@ -130,6 +130,24 @@ if test $gl_cv_type_wctrans_t = no; then HAVE_WCTRANS_T=0 fi + + dnl Check for declarations of anything we want to poison if the + dnl corresponding gnulib module is not in use. + gl_WARN_ON_USE_PREPARE([[ +/* Tru64 with Desktop Toolkit C has a bug: must be included before + . + BSD/OS 4.0.1 has a bug: , and must be + included before . */ +#if !(defined __GLIBC__ && !defined __UCLIBC__) +# include +# include +# include +# include +#endif +#include + ]], + [wctype + ]) ]) AC_DEFUN([gl_WCTYPE_MODULE_INDICATOR], @@ -144,6 +162,7 @@ AC_DEFUN([gl_WCTYPE_H_DEFAULTS], [ GNULIB_ISWBLANK=0; AC_SUBST([GNULIB_ISWBLANK]) + GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE]) 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 -r 18ad0b0246fc -r aef6efcc4045 modules/wctype --- a/modules/wctype Sun Feb 06 23:18:30 2011 +0100 +++ b/modules/wctype Sun Feb 06 23:45:40 2011 +0100 @@ -1,12 +1,24 @@ Description: -A that conforms better to C99. +wctype() function: get descriptor for a wide character property. + +Status: +obsolete + +Notice: +This module is obsolete. Files: +lib/wctype.c +lib/wctype-impl.h +m4/wctype.m4 Depends-on: wctype-h +iswblank configure.ac: +gl_FUNC_WCTYPE +gl_WCTYPE_MODULE_INDICATOR([wctype]) Makefile.am: diff -r 18ad0b0246fc -r aef6efcc4045 modules/wctype-h --- a/modules/wctype-h Sun Feb 06 23:18:30 2011 +0100 +++ b/modules/wctype-h Sun Feb 06 23:45:40 2011 +0100 @@ -28,6 +28,7 @@ -e 's|@''PRAGMA_COLUMNS''@|@PRAGMA_COLUMNS@|g' \ -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/@''HAVE_ISWBLANK''@/$(HAVE_ISWBLANK)/g' \ -e 's/@''HAVE_ISWCNTRL''@/$(HAVE_ISWCNTRL)/g' \ -e 's/@''HAVE_WCTYPE_T''@/$(HAVE_WCTYPE_T)/g' \ diff -r 18ad0b0246fc -r aef6efcc4045 tests/test-wctype-h-c++.cc --- a/tests/test-wctype-h-c++.cc Sun Feb 06 23:18:30 2011 +0100 +++ b/tests/test-wctype-h-c++.cc Sun Feb 06 23:45:40 2011 +0100 @@ -39,6 +39,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::iswupper, int, (wint_t)); SIGNATURE_CHECK (GNULIB_NAMESPACE::iswxdigit, int, (wint_t)); +#if GNULIB_TEST_WCTYPE +SIGNATURE_CHECK (GNULIB_NAMESPACE::wctype, wctype_t, (const char *)); +#endif + SIGNATURE_CHECK (GNULIB_NAMESPACE::towlower, wint_t, (wint_t)); SIGNATURE_CHECK (GNULIB_NAMESPACE::towupper, wint_t, (wint_t));