Back to index

glibc  2.9
gconv_charset.h
Go to the documentation of this file.
00001 /* Charset name normalization.
00002    Copyright (C) 2001,2002,2003,2004,2005,2007 Free Software Foundation, Inc.
00003    This file is part of the GNU C Library.
00004    Contributed by Ulrich Drepper <drepper@cygnus.com>, 2001.
00005 
00006    The GNU C Library is free software; you can redistribute it and/or
00007    modify it under the terms of the GNU Lesser General Public
00008    License as published by the Free Software Foundation; either
00009    version 2.1 of the License, or (at your option) any later version.
00010 
00011    The GNU C Library is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014    Lesser General Public License for more details.
00015 
00016    You should have received a copy of the GNU Lesser General Public
00017    License along with the GNU C Library; if not, write to the Free
00018    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00019    02111-1307 USA.  */
00020 
00021 #include <ctype.h>
00022 #include <locale.h>
00023 
00024 
00025 static void
00026 strip (char *wp, const char *s)
00027 {
00028   int slash_count = 0;
00029 
00030   while (*s != '\0')
00031     {
00032       if (__isalnum_l (*s, _nl_C_locobj_ptr)
00033          || *s == '_' || *s == '-' || *s == '.' || *s == ',' || *s == ':')
00034        *wp++ = __toupper_l (*s, _nl_C_locobj_ptr);
00035       else if (*s == '/')
00036        {
00037          if (++slash_count == 3)
00038            break;
00039          *wp++ = '/';
00040        }
00041       ++s;
00042     }
00043 
00044   while (slash_count++ < 2)
00045     *wp++ = '/';
00046 
00047   *wp = '\0';
00048 }
00049 
00050 
00051 static inline char * __attribute__ ((unused, always_inline))
00052 upstr (char *dst, const char *str)
00053 {
00054   char *cp = dst;
00055   while ((*cp++ = __toupper_l (*str++, _nl_C_locobj_ptr)) != '\0')
00056     /* nothing */;
00057   return dst;
00058 }