From: Bruno Haible Date: Sun, 6 Feb 2011 23:29:31 +0000 (+0100) Subject: New module 'towctrans'. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d3042e83ace41dcd72fdf8d5173ddf55ac645459;p=pspp New module 'towctrans'. * modules/towctrans: New file. * lib/wctype.in.h (towctrans): New declaration. * lib/towctrans.c: New file. * lib/towctrans-impl.h: New file. * m4/towctrans.m4: New file. * m4/wctype_h.m4 (gl_WCTYPE_H): Test whether towctrans is declared. (gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_TOWCTRANS. * modules/wctype-h (Makefile.am): Substitute GNULIB_TOWCTRANS. * tests/test-wctype-h-c++.cc: Test the declaration of towctrans. * doc/posix-functions/towctrans.texi: Mention the new module. --- diff --git a/ChangeLog b/ChangeLog index 3d4e23f348..c17461a8fb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-02-06 Bruno Haible + + New module 'towctrans'. + * modules/towctrans: New file. + * lib/wctype.in.h (towctrans): New declaration. + * lib/towctrans.c: New file. + * lib/towctrans-impl.h: New file. + * m4/towctrans.m4: New file. + * m4/wctype_h.m4 (gl_WCTYPE_H): Test whether towctrans is declared. + (gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_TOWCTRANS. + * modules/wctype-h (Makefile.am): Substitute GNULIB_TOWCTRANS. + * tests/test-wctype-h-c++.cc: Test the declaration of towctrans. + * doc/posix-functions/towctrans.texi: Mention the new module. + 2011-02-06 Bruno Haible New module 'wctrans'. diff --git a/doc/posix-functions/towctrans.texi b/doc/posix-functions/towctrans.texi index 5449f7fcac..d99c6adbed 100644 --- a/doc/posix-functions/towctrans.texi +++ b/doc/posix-functions/towctrans.texi @@ -4,18 +4,18 @@ POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/towctrans.html} -Gnulib module: --- +Gnulib module: towctrans Portability problems fixed by Gnulib: @itemize +@item +This function is missing on some platforms: +HP-UX 11.00, IRIX 6.5, Solaris 2.5.1, mingw, Interix 3.5. @end itemize Portability problems not fixed by Gnulib: @itemize @item -This function is missing on some platforms: -HP-UX 11.00, IRIX 6.5, Solaris 2.5.1, mingw, Interix 3.5. -@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/towctrans-impl.h b/lib/towctrans-impl.h new file mode 100644 index 0000000000..9e640fe694 --- /dev/null +++ b/lib/towctrans-impl.h @@ -0,0 +1,22 @@ +/* Convert a wide character using a case mapping. + 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 . */ + +wint_t +towctrans (wint_t wc, wctrans_t desc) +{ + return ((wint_t (*) (wint_t)) desc) (wc); +} diff --git a/lib/towctrans.c b/lib/towctrans.c new file mode 100644 index 0000000000..3bf42ad462 --- /dev/null +++ b/lib/towctrans.c @@ -0,0 +1,23 @@ +/* Convert a wide character using a case mapping. + 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 "towctrans-impl.h" diff --git a/lib/wctype.in.h b/lib/wctype.in.h index 99d8635b0a..feef37dbe3 100644 --- a/lib/wctype.in.h +++ b/lib/wctype.in.h @@ -448,6 +448,23 @@ _GL_WARN_ON_USE (wctrans, "wctrans is unportable - " # endif #endif +/* Perform a given case conversion on a wide character. + The argument WC must be either a wchar_t value or WEOF. + The argument DESC must have been returned by the wctrans() function. */ +#if @GNULIB_TOWCTRANS@ +# if !@HAVE_WCTRANS_T@ +_GL_FUNCDECL_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +# endif +_GL_CXXALIAS_SYS (towctrans, wint_t, (wint_t wc, wctrans_t desc)); +_GL_CXXALIASWARN (towctrans); +#elif defined GNULIB_POSIXCHECK +# undef towctrans +# if HAVE_RAW_DECL_TOWCTRANS +_GL_WARN_ON_USE (towctrans, "towctrans is unportable - " + "use gnulib module towctrans for portability"); +# endif +#endif + #endif /* _GL_WCTYPE_H */ #endif /* _GL_WCTYPE_H */ diff --git a/m4/towctrans.m4 b/m4/towctrans.m4 new file mode 100644 index 0000000000..2c6c2988de --- /dev/null +++ b/m4/towctrans.m4 @@ -0,0 +1,14 @@ +# towctrans.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_TOWCTRANS], +[ + AC_REQUIRE([gl_WCTYPE_H_DEFAULTS]) + AC_REQUIRE([gl_WCTYPE_H]) + if test $HAVE_WCTRANS_T = 0; then + AC_LIBOBJ([towctrans]) + fi +]) diff --git a/m4/wctype_h.m4 b/m4/wctype_h.m4 index a82dec6e6b..ef9fb049ce 100644 --- a/m4/wctype_h.m4 +++ b/m4/wctype_h.m4 @@ -146,7 +146,7 @@ AC_DEFUN([gl_WCTYPE_H], #endif #include ]], - [wctype iswctype wctrans + [wctype iswctype wctrans towctrans ]) ]) @@ -165,6 +165,7 @@ AC_DEFUN([gl_WCTYPE_H_DEFAULTS], GNULIB_WCTYPE=0; AC_SUBST([GNULIB_WCTYPE]) GNULIB_ISWCTYPE=0; AC_SUBST([GNULIB_ISWCTYPE]) GNULIB_WCTRANS=0; AC_SUBST([GNULIB_WCTRANS]) + GNULIB_TOWCTRANS=0; AC_SUBST([GNULIB_TOWCTRANS]) 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/towctrans b/modules/towctrans new file mode 100644 index 0000000000..3ad100d405 --- /dev/null +++ b/modules/towctrans @@ -0,0 +1,25 @@ +Description: +towctrans() function: convert a wide character using a case mapping. + +Files: +lib/towctrans.c +lib/towctrans-impl.h +m4/towctrans.m4 + +Depends-on: +wctype-h + +configure.ac: +gl_FUNC_TOWCTRANS +gl_WCTYPE_MODULE_INDICATOR([towctrans]) + +Makefile.am: + +Include: + + +License: +LGPL + +Maintainer: +Bruno Haible diff --git a/modules/wctype-h b/modules/wctype-h index 1879ed8f09..f0d7989fd5 100644 --- a/modules/wctype-h +++ b/modules/wctype-h @@ -31,6 +31,7 @@ wctype.h: wctype.in.h $(CXXDEFS_H) $(WARN_ON_USE_H) -e 's/@''GNULIB_WCTYPE''@/$(GNULIB_WCTYPE)/g' \ -e 's/@''GNULIB_ISWCTYPE''@/$(GNULIB_ISWCTYPE)/g' \ -e 's/@''GNULIB_WCTRANS''@/$(GNULIB_WCTRANS)/g' \ + -e 's/@''GNULIB_TOWCTRANS''@/$(GNULIB_TOWCTRANS)/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 1b02a9ed72..7208382506 100644 --- a/tests/test-wctype-h-c++.cc +++ b/tests/test-wctype-h-c++.cc @@ -54,6 +54,10 @@ SIGNATURE_CHECK (GNULIB_NAMESPACE::towupper, wint_t, (wint_t)); SIGNATURE_CHECK (GNULIB_NAMESPACE::wctrans, wctrans_t, (const char *)); #endif +#if GNULIB_TEST_TOWCTRANS +SIGNATURE_CHECK (GNULIB_NAMESPACE::towctrans, wint_t, (wint_t, wctrans_t)); +#endif + int main ()