Alan Hourihane wrote: > > > nm exclude.o | grep towlower > > > U _towlower > > > > > > And my libc doesn't define towlower() either. > > > > I see. Perhaps it is defined elsewhere? Could you please check? > > The gnulib's wchar.h does not provide a wrapper for it, unfortunately. > > Just to re-iterate. My libc has no widechar support at all. > > So only tolower() and not towlower().
Like Solaris 2.5.1 and IRIX 5.3, you mean? This should do it. 2009-09-05 Bruno Haible <br...@clisp.org> Support towlower, towupper. * doc/posix-functions/towlower.texi: Mention module wctype. * doc/posix-functions/towupper.texi: Likewise. * lib/wctype.in.h (towlower, towupper): New functions. * tests/test-wctype.c: Include stdio.h, stdlib.h. (ASSERT): New macro. (e): New variable. (main): Test also towlower, towupper. Test WEOF argument. Reported by Alan Hourihane <al...@fairlite.co.uk>. --- lib/wctype.in.h.orig 2009-09-05 18:04:07.000000000 +0200 +++ lib/wctype.in.h 2009-09-05 17:56:15.000000000 +0200 @@ -84,6 +84,8 @@ # undef iswspace # undef iswupper # undef iswxdigit +# undef towlower +# undef towupper /* Linux libc5 has <wctype.h> and the functions but they are broken. */ # if @REPLACE_ISWCNTRL@ @@ -99,6 +101,8 @@ # define iswspace rpl_iswspace # define iswupper rpl_iswupper # define iswxdigit rpl_iswxdigit +# define towlower rpl_towlower +# define towupper rpl_towupper # endif static inline int @@ -178,6 +182,18 @@ || ((wc & ~0x20) >= 'A' && (wc & ~0x20) <= 'F')); } +static inline wint_t +towlower (wint_t wc) +{ + return (wc >= 'A' && wc <= 'Z' ? wc - 'A' + 'a' : wc); +} + +static inline wint_t +towupper (wint_t wc) +{ + return (wc >= 'a' && wc <= 'z' ? wc - 'a' + 'A' : wc); +} + # endif /* ! HAVE_ISWCNTRL */ #endif /* _GL_WCTYPE_H */ --- tests/test-wctype.c.orig 2009-09-05 18:04:07.000000000 +0200 +++ tests/test-wctype.c 2009-09-05 18:02:49.000000000 +0200 @@ -1,5 +1,5 @@ /* Test of <wctype.h> substitute. - Copyright (C) 2007-2008 Free Software Foundation, Inc. + Copyright (C) 2007-2009 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 @@ -20,8 +20,25 @@ #include <wctype.h> +#include <stdio.h> +#include <stdlib.h> + +#define ASSERT(expr) \ + do \ + { \ + if (!(expr)) \ + { \ + fprintf (stderr, "%s:%d: assertion failed\n", __FILE__, __LINE__); \ + fflush (stderr); \ + abort (); \ + } \ + } \ + while (0) + /* Check that the type wint_t is defined. */ wint_t a = 'x'; +/* Check that WEOF is defined. */ +wint_t e = WEOF; int main () @@ -42,5 +59,29 @@ (void) iswupper (0); (void) iswxdigit (0); + /* Check that the isw* functions map WEOF to 0. */ + ASSERT (!iswalnum (e)); + ASSERT (!iswalpha (e)); +#if 0 /* not portable: missing on mingw */ + ASSERT (!iswblank (e)); +#endif + ASSERT (!iswcntrl (e)); + ASSERT (!iswdigit (e)); + ASSERT (!iswgraph (e)); + ASSERT (!iswlower (e)); + ASSERT (!iswprint (e)); + ASSERT (!iswpunct (e)); + ASSERT (!iswspace (e)); + ASSERT (!iswupper (e)); + ASSERT (!iswxdigit (e)); + + /* Check that the tow* functions exist as functions or as macros. */ + (void) towlower (0); + (void) towupper (0); + + /* Check that the tow* functions map WEOF to WEOF. */ + ASSERT (towlower (e) == e); + ASSERT (towupper (e) == e); + return 0; } --- doc/posix-functions/towlower.texi.orig 2009-09-05 18:04:07.000000000 +0200 +++ doc/posix-functions/towlower.texi 2009-09-05 17:54:46.000000000 +0200 @@ -4,18 +4,18 @@ POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/towlower.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. @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 --- doc/posix-functions/towupper.texi.orig 2009-09-05 18:04:07.000000000 +0200 +++ doc/posix-functions/towupper.texi 2009-09-05 17:54:47.000000000 +0200 @@ -4,18 +4,18 @@ POSIX specification: @url{http://www.opengroup.org/onlinepubs/9699919799/functions/towupper.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. @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