view lib/wctrans-impl.h @ 14321:3b388f38755d

New module 'wctrans'. * modules/wctrans: New file. * lib/wctype.in.h (wctrans): New declaration. * lib/wctrans.c: New file. * lib/wctrans-impl.h: New file. * m4/wctrans.m4: New file. * m4/wctype_h.m4 (gl_WCTYPE_H): Test whether wctrans is declared. (gl_WCTYPE_H_DEFAULTS): Initialize GNULIB_WCTRANS. * modules/wctype-h (Makefile.am): Substitute GNULIB_WCTRANS. * tests/test-wctype-h-c++.cc: Test the declaration of wctrans. * doc/posix-functions/wctrans.texi: Mention the new module.
author Bruno Haible <bruno@clisp.org>
date Mon, 07 Feb 2011 00:16:49 +0100
parents
children 8250f2777afc
line wrap: on
line source

/* Get descriptor for a wide character case conversion.
   Copyright (C) 2011 Free Software Foundation, Inc.
   Written by Bruno Haible <bruno@clisp.org>, 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 <http://www.gnu.org/licenses/>.  */

wctrans_t
wctrans (const char *name)
{
  if (name[0] == 't'
      && name[1] == 'o')
    switch (name[2])
      {
      case 'l':
        if (strcmp (name + 3, "ower") == 0)
          return (wctrans_t) towlower;
        break;
      case 'u':
        if (strcmp (name + 3, "pper") == 0)
          return (wctrans_t) towupper;
        break;
      default:
        break;
      }
  return NULL;
}