(linenum→info "unix/slp.c:2238")

glibc/2.7/localedata/tst-wctype.c

    1: /* Test program for iswctype() function in ja_JP locale.
    2:    Copyright (C) 2000 Free Software Foundation, Inc.
    3:    This file is part of the GNU C Library.
    4:    Contributed by Ulrich Drepper <drepper@cygnus.com>.
    5: 
    6:    The GNU C Library is free software; you can redistribute it and/or
    7:    modify it under the terms of the GNU Lesser General Public
    8:    License as published by the Free Software Foundation; either
    9:    version 2.1 of the License, or (at your option) any later version.
   10: 
   11:    The GNU C Library is distributed in the hope that it will be useful,
   12:    but WITHOUT ANY WARRANTY; without even the implied warranty of
   13:    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   14:    Lesser General Public License for more details.
   15: 
   16:    You should have received a copy of the GNU Lesser General Public
   17:    License along with the GNU C Library; if not, write to the Free
   18:    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
   19:    02111-1307 USA.  */
   20: 
   21: #include <error.h>
   22: #include <locale.h>
   23: #include <stdio.h>
   24: #include <stdlib.h>
   25: #include <wchar.h>
   26: #include <wctype.h>
   27: 
   28: int
   29: main (void)
   30: {
   31:   wctype_t wct;
   32:   wchar_t buf[1000];
   33:   int result = 1;
   34: 
   35:   setlocale (LC_ALL, "");
   36:   wprintf (L"locale = %s\n", setlocale (LC_CTYPE, NULL));
   37: 
   38:   wct = wctype ("jhira");
   39:   if (wct == 0)
   40:     error (EXIT_FAILURE, 0, "jhira: no such character class");
   41: 
   42:   if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
   43:     {
   44:       int n;
   45: 
   46:       wprintf (L"buf[] = \"%ls\"\n", buf);
   47: 
   48:       result = 0;
   49: 
   50:       for (n = 0; buf[n] != L'\0'; ++n)
   51:         {
   52:           wprintf (L"jhira(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
   53:                    iswctype (buf[n], wct));
   54:           result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
   55:                      || (buf[n] > 0xff && !iswctype (buf[n], wct)));
   56:         }
   57:     }
   58: 
   59:   wct = wctype ("jkata");
   60:   if (wct == 0)
   61:     error (EXIT_FAILURE, 0, "jkata: no such character class");
   62: 
   63:   if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
   64:     {
   65:       int n;
   66: 
   67:       wprintf (L"buf[] = \"%ls\"\n", buf);
   68: 
   69:       result = 0;
   70: 
   71:       for (n = 0; buf[n] != L'\0'; ++n)
   72:         {
   73:           wprintf (L"jkata(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
   74:                    iswctype (buf[n], wct));
   75:           result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
   76:                      || (buf[n] > 0xff && !iswctype (buf[n], wct)));
   77:         }
   78:     }
   79: 
   80:   wct = wctype ("jdigit");
   81:   if (wct == 0)
   82:     error (EXIT_FAILURE, 0, "jdigit: no such character class");
   83: 
   84:   if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
   85:     {
   86:       int n;
   87: 
   88:       wprintf (L"buf[] = \"%ls\"\n", buf);
   89: 
   90:       result = 0;
   91: 
   92:       for (n = 0; buf[n] != L'\0'; ++n)
   93:         {
   94:           wprintf (L"jdigit(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
   95:                    iswctype (buf[n], wct));
   96:           result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
   97:                      || (buf[n] > 0xff && !iswctype (buf[n], wct)));
   98:         }
   99:     }
  100: 
  101:   wct = wctype ("jspace");
  102:   if (wct == 0)
  103:     error (EXIT_FAILURE, 0, "jspace: no such character class");
  104: 
  105:   if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
  106:     {
  107:       int n;
  108: 
  109:       wprintf (L"buf[] = \"%ls\"\n", buf);
  110: 
  111:       result = 0;
  112: 
  113:       for (n = 0; buf[n] != L'\0'; ++n)
  114:         {
  115:           wprintf (L"jspace(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
  116:                    iswctype (buf[n], wct));
  117:           result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
  118:                      || (buf[n] > 0xff && !iswctype (buf[n], wct)));
  119:         }
  120:     }
  121: 
  122:   wct = wctype ("jkanji");
  123:   if (wct == 0)
  124:     error (EXIT_FAILURE, 0, "jkanji: no such character class");
  125: 
  126:   if (fgetws (buf, sizeof (buf) / sizeof (buf[0]), stdin) != NULL)
  127:     {
  128:       int n;
  129: 
  130:       wprintf (L"buf[] = \"%ls\"\n", buf);
  131: 
  132:       result = 0;
  133: 
  134:       for (n = 0; buf[n] != L'\0'; ++n)
  135:         {
  136:           wprintf (L"jkanji(U%04lx = %lc) = %d\n", (long) buf[n], buf[n],
  137:                    iswctype (buf[n], wct));
  138:           result |= ((buf[n] < 0xff && iswctype (buf[n], wct))
  139:                      || (buf[n] > 0xff && !iswctype (buf[n], wct)));
  140:         }
  141:     }
  142: 
  143:   return result;
  144: }
Syntax (Markdown)