2002-09-20 Jeff Johnston <jjohnstn@redhat.com>

* libc/ctype/Makefile.am: Add new files.
        * libc/ctype/Makefile.in: Regenerated.
        * libc/ctype/ctype.tex: Add new iswxxxx, towxxxx, wctype,
        and wctrans functions to documentation index.
        * libc/ctype/iswalnum.c: New file.
        * libc/ctype/iswalpha.c: Ditto.
        * libc/ctype/iswblank.c: Ditto.
        * libc/ctype/iswcntrl.c: Ditto.
        * libc/ctype/iswctype.c: Ditto.
        * libc/ctype/iswdigit.c: Ditto.
        * libc/ctype/iswgraph.c: Ditto.
        * libc/ctype/iswlower.c: Ditto.
        * libc/ctype/iswprint.c: Ditto.
        * libc/ctype/iswpunct.c: Ditto.
        * libc/ctype/iswspace.c: Ditto.
        * libc/ctype/iswupper.c: Ditto.
        * libc/ctype/iswxdigit.c: Ditto.
        * libc/ctype/jp2uc.c: Ditto.
        * libc/ctype/jp2uc.h: Ditto.
        * libc/ctype/local.h: Ditto.
        * libc/ctype/towctrans.c: Ditto.
        * libc/ctype/towlower.c: Ditto.
        * libc/ctype/towupper.c: Ditto.
        * libc/ctype/utf8alpha.h: Ditto.
        * libc/ctype/utf8print.h: Ditto.
        * libc/ctype/utf8punct.h: Ditto.
        * libc/ctype/wctrans.c: Ditto.
        * libc/ctype/wctype.c: Ditto.
        * libc/locale/locale.c (__lc_ctype): New external array to
        replace static lc_ctype array.
        * libc/stdlib/mbtowc_r.c: Use __lc_ctype to check current lc_ctype
        rather than reentrancy structure's _current_locale field.
        * libc/stdlib/wctomb_r.c: Ditto.
This commit is contained in:
Jeff Johnston 2002-09-20 20:13:11 +00:00
parent da25e61f59
commit 1525d127da
31 changed files with 10945 additions and 21 deletions

View File

@ -1,3 +1,39 @@
2002-09-20 Jeff Johnston <jjohnstn@redhat.com>
* libc/ctype/Makefile.am: Add new files.
* libc/ctype/Makefile.in: Regenerated.
* libc/ctype/ctype.tex: Add new iswxxxx, towxxxx, wctype,
and wctrans functions to documentation index.
* libc/ctype/iswalnum.c: New file.
* libc/ctype/iswalpha.c: Ditto.
* libc/ctype/iswblank.c: Ditto.
* libc/ctype/iswcntrl.c: Ditto.
* libc/ctype/iswctype.c: Ditto.
* libc/ctype/iswdigit.c: Ditto.
* libc/ctype/iswgraph.c: Ditto.
* libc/ctype/iswlower.c: Ditto.
* libc/ctype/iswprint.c: Ditto.
* libc/ctype/iswpunct.c: Ditto.
* libc/ctype/iswspace.c: Ditto.
* libc/ctype/iswupper.c: Ditto.
* libc/ctype/iswxdigit.c: Ditto.
* libc/ctype/jp2uc.c: Ditto.
* libc/ctype/jp2uc.h: Ditto.
* libc/ctype/local.h: Ditto.
* libc/ctype/towctrans.c: Ditto.
* libc/ctype/towlower.c: Ditto.
* libc/ctype/towupper.c: Ditto.
* libc/ctype/utf8alpha.h: Ditto.
* libc/ctype/utf8print.h: Ditto.
* libc/ctype/utf8punct.h: Ditto.
* libc/ctype/wctrans.c: Ditto.
* libc/ctype/wctype.c: Ditto.
* libc/locale/locale.c (__lc_ctype): New external array to
replace static lc_ctype array.
* libc/stdlib/mbtowc_r.c: Use __lc_ctype to check current lc_ctype
rather than reentrancy structure's _current_locale field.
* libc/stdlib/wctomb_r.c: Ditto.
2002-09-20 Jeff Johnston <jjohnstn@redhat.com>
* configure.host: Minor comment and formatting changes.

View File

@ -26,9 +26,28 @@ else
LIB_OBJS = \
isascii.$(oext) \
isblank.$(oext) \
iswalnum.$(oext) \
iswalpha.$(oext) \
iswblank.$(oext) \
iswcntrl.$(oext) \
iswctype.$(oext) \
iswdigit.$(oext) \
iswgraph.$(oext) \
iswlower.$(oext) \
iswprint.$(oext) \
iswpunct.$(oext) \
iswspace.$(oext) \
iswupper.$(oext) \
iswxdigit.$(oext) \
jp2uc.$(oext) \
toascii.$(oext) \
_tolower.$(oext) \
_toupper.$(oext)
_toupper.$(oext) \
towctrans.$(oext) \
towlower.$(oext) \
towupper.$(oext) \
wctrans.$(oext) \
wctype.$(oext)
endif
libctype_la_LDFLAGS = -Xcompiler -nostdlib
@ -60,10 +79,28 @@ CHEWOUT_FILES= \
ispunct.def \
isspace.def \
isupper.def \
iswalnum.def \
iswalpha.def \
iswblank.def \
iswcntrl.def \
iswctype.def \
iswdigit.def \
iswgraph.def \
iswlower.def \
iswprint.def \
iswpunct.def \
iswspace.def \
iswupper.def \
iswxdigit.def \
isxdigit.def \
toascii.def \
tolower.def \
toupper.def
toupper.def \
towctrans.def \
towlower.def \
towupper.def \
wctrans.def \
wctype.def
SUFFIXES = .def

View File

@ -129,9 +129,28 @@ GENERAL_SOURCES = \
@ELIX_LEVEL_1_FALSE@LIB_OBJS = @ELIX_LEVEL_1_FALSE@\
@ELIX_LEVEL_1_FALSE@ isascii.$(oext) \
@ELIX_LEVEL_1_FALSE@ isblank.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswalnum.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswalpha.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswblank.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswcntrl.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswctype.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswdigit.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswgraph.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswlower.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswprint.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswpunct.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswspace.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswupper.$(oext) \
@ELIX_LEVEL_1_FALSE@ iswxdigit.$(oext) \
@ELIX_LEVEL_1_FALSE@ jp2uc.$(oext) \
@ELIX_LEVEL_1_FALSE@ toascii.$(oext) \
@ELIX_LEVEL_1_FALSE@ _tolower.$(oext) \
@ELIX_LEVEL_1_FALSE@ _toupper.$(oext)
@ELIX_LEVEL_1_FALSE@ _toupper.$(oext) \
@ELIX_LEVEL_1_FALSE@ towctrans.$(oext) \
@ELIX_LEVEL_1_FALSE@ towlower.$(oext) \
@ELIX_LEVEL_1_FALSE@ towupper.$(oext) \
@ELIX_LEVEL_1_FALSE@ wctrans.$(oext) \
@ELIX_LEVEL_1_FALSE@ wctype.$(oext)
libctype_la_LDFLAGS = -Xcompiler -nostdlib
@ -157,10 +176,28 @@ CHEWOUT_FILES = \
ispunct.def \
isspace.def \
isupper.def \
iswalnum.def \
iswalpha.def \
iswblank.def \
iswcntrl.def \
iswctype.def \
iswdigit.def \
iswgraph.def \
iswlower.def \
iswprint.def \
iswpunct.def \
iswspace.def \
iswupper.def \
iswxdigit.def \
isxdigit.def \
toascii.def \
tolower.def \
toupper.def
toupper.def \
towctrans.def \
towlower.def \
towupper.def \
wctrans.def \
wctype.def
SUFFIXES = .def

View File

@ -21,6 +21,23 @@ The header file @file{ctype.h} defines the macros.
* toascii:: Force integers to ASCII range
* tolower:: Translate characters to lower case
* toupper:: Translate characters to upper case
* iswalnum:: Alphanumeric wide-character predicate
* iswalpha:: Alphabetic wide-character predicate
* iswcntrl:: Control wide-character predicate
* iswdigit:: Decimal digit wide-character predicate
* iswgraph:: Graphic wide-character predicate
* iswlower:: Lower-case wide-character predicate
* iswprint:: Printable wide-character predicate
* iswpunct:: Punctuation wide-character predicate
* iswspace:: Whitespace wide-character predicate
* iswupper:: Uppercase wide-character predicate
* iswxdigit:: Hexadecimal digit wide-character predicate
* iswctype:: Extensible wide-character test
* wctype:: Compute wide-character test type
* towlower:: Translate wide-characters to lower case
* towupper:: Translate wide-characters to upper case
* towctrans:: Extensible wide-character case mapping
* wctrans:: Compute wide-character translation type
@end menu
@page
@ -65,4 +82,55 @@ The header file @file{ctype.h} defines the macros.
@page
@include ctype/toupper.def
@page
@include ctype/iswalnum.def
@page
@include ctype/iswalpha.def
@page
@include ctype/iswcntrl.def
@page
@include ctype/iswdigit.def
@page
@include ctype/iswgraph.def
@page
@include ctype/iswlower.def
@page
@include ctype/iswprint.def
@page
@include ctype/iswpunct.def
@page
@include ctype/iswspace.def
@page
@include ctype/iswupper.def
@page
@include ctype/iswxdigit.def
@page
@include ctype/iswctype.def
@page
@include ctype/wctype.def
@page
@include ctype/towlower.def
@page
@include ctype/towupper.def
@page
@include ctype/towctrans.def
@page
@include ctype/wctrans.def

View File

@ -0,0 +1,37 @@
/*
FUNCTION
<<iswalnum>>---alpha-numeric wide-character test
INDEX
iswalnum
ANSI_SYNOPSIS
#include <wctype.h>
int iswalnum(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswalnum(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswalnum>> is a function which classifies wide-character values that
are alpha-numeric.
RETURNS
<<iswalnum>> returns non-zero if <[c]> is a alpha-numeric wide-character.
PORTABILITY
<<iswalnum>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
int
_DEFUN(iswalnum,(c),wint_t c)
{
return (iswalpha (c) || iswdigit (c));
}

View File

@ -0,0 +1,342 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<iswalpha>>---alphabetic wide-character test
INDEX
iswalpha
ANSI_SYNOPSIS
#include <wctype.h>
int iswalpha(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswalpha(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswalpha>> is a function which classifies wide-character values that
are alphabetic.
RETURNS
<<iswalpha>> returns non-zero if <[c]> is an alphabetic wide-character.
PORTABILITY
<<iswalpha>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
#include <string.h>
#include <ctype.h>
#include "local.h"
#ifdef MB_CAPABLE
#include "utf8alpha.h"
#endif /* MB_CAPABLE */
int
_DEFUN(iswalpha,(c), wint_t c)
{
int unicode = 0;
if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
{
unicode = 0;
/* fall-through */
}
#ifdef MB_CAPABLE
else if (!strcmp (__lc_ctype, "C-JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
unicode = 1;
}
if (unicode)
{
unsigned const char *table;
unsigned char *ptr;
unsigned char ctmp;
int size;
wint_t x = (c >> 8);
/* for some large sections, all characters are alphabetic so handle them here */
if ((x >= 0x34 && x <= 0x4c) ||
(x >= 0x4e && x <= 0x9e) ||
(x >= 0xac && x <= 0xd6) ||
(x >= 0x200 && x <= 0x2a5))
return 1;
switch (x)
{
case 0x00:
table = u0;
size = sizeof(u0);
break;
case 0x01:
case 0x15:
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
case 0xf9:
case 0xfc:
case 0x2f8:
case 0x2f9:
return 1;
case 0x02:
table = u2;
size = sizeof(u2);
break;
case 0x03:
table = u3;
size = sizeof(u3);
break;
case 0x04:
table = u4;
size = sizeof(u4);
break;
case 0x05:
table = u5;
size = sizeof(u5);
break;
case 0x06:
table = u6;
size = sizeof(u6);
break;
case 0x07:
table = u7;
size = sizeof(u7);
break;
case 0x09:
table = u9;
size = sizeof(u9);
break;
case 0x0a:
table = ua;
size = sizeof(ua);
break;
case 0x0b:
table = ub;
size = sizeof(ub);
break;
case 0x0c:
table = uc;
size = sizeof(uc);
break;
case 0x0d:
table = ud;
size = sizeof(ud);
break;
case 0x0e:
table = ue;
size = sizeof(ue);
break;
case 0x0f:
table = uf;
size = sizeof(uf);
break;
case 0x10:
table = u10;
size = sizeof(u10);
break;
case 0x11:
table = u11;
size = sizeof(u11);
break;
case 0x12:
table = u12;
size = sizeof(u12);
break;
case 0x13:
table = u13;
size = sizeof(u13);
break;
case 0x14:
table = u14;
size = sizeof(u14);
break;
case 0x16:
table = u16;
size = sizeof(u16);
break;
case 0x17:
table = u17;
size = sizeof(u17);
break;
case 0x18:
table = u18;
size = sizeof(u18);
break;
case 0x1e:
table = u1e;
size = sizeof(u1e);
break;
case 0x1f:
table = u1f;
size = sizeof(u1f);
break;
case 0x20:
table = u20;
size = sizeof(u20);
break;
case 0x21:
table = u21;
size = sizeof(u21);
break;
case 0x24:
table = u24;
size = sizeof(u24);
break;
case 0x30:
table = u30;
size = sizeof(u30);
break;
case 0x31:
table = u31;
size = sizeof(u31);
break;
case 0x4d:
table = u4d;
size = sizeof(u4d);
break;
case 0x9f:
table = u9f;
size = sizeof(u9f);
break;
case 0xa4:
table = ua4;
size = sizeof(ua4);
break;
case 0xd7:
table = ud7;
size = sizeof(ud7);
break;
case 0xfa:
table = ufa;
size = sizeof(ufa);
break;
case 0xfb:
table = ufb;
size = sizeof(ufb);
break;
case 0xfd:
table = ufd;
size = sizeof(ufd);
break;
case 0xfe:
table = ufe;
size = sizeof(ufe);
break;
case 0xff:
table = uff;
size = sizeof(uff);
break;
case 0x103:
table = u103;
size = sizeof(u103);
break;
case 0x104:
table = u104;
size = sizeof(u104);
break;
case 0x1d4:
table = u1d4;
size = sizeof(u1d4);
break;
case 0x1d5:
table = u1d5;
size = sizeof(u1d5);
break;
case 0x1d6:
table = u1d6;
size = sizeof(u1d6);
break;
case 0x1d7:
table = u1d7;
size = sizeof(u1d7);
break;
case 0x2a6:
table = u2a6;
size = sizeof(u2a6);
break;
case 0x2fa:
table = u2fa;
size = sizeof(u2fa);
break;
default:
return 0;
}
/* we have narrowed down to a section of 256 characters to check */
/* now check if c matches the alphabetic wide-chars within that section */
ptr = (unsigned char *)table;
ctmp = (unsigned char)c;
while (ptr < table + size)
{
if (ctmp == *ptr)
return 1;
if (ctmp < *ptr)
return 0;
/* otherwise c > *ptr */
/* look for 0x0 as next element which indicates a range */
++ptr;
if (*ptr == 0x0)
{
/* we have a range..see if c falls within range */
++ptr;
if (ctmp <= *ptr)
return 1;
++ptr;
}
}
/* not in table */
return 0;
}
#endif /* MB_CAPABLE */
return (c < (wint_t)0x100 ? isalpha (c) : 0);
}

View File

@ -0,0 +1,105 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<iswblank>>---wide-character blank test
INDEX
iswblank
ANSI_SYNOPSIS
#include <wctype.h>
int iswblank(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswblank(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswblank>> is a function which classifies wide-character values that
are categorized as blank.
RETURNS
<<iswblank>> returns non-zero if <[c]> is a blank wide-character.
PORTABILITY
<<iswblank>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
#include <ctype.h>
#include <string.h>
#include "local.h"
int
_DEFUN(iswblank,(c), wint_t c)
{
int unicode = 0;
if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
{
unicode = 0;
/* fall-through */
}
#ifdef MB_CAPABLE
else if (!strcmp (__lc_ctype, "C-JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
unicode = 1;
}
if (unicode)
{
return (c == 0x0009 || c == 0x0020 || c == 0x1680 ||
(c >= 0x2000 && c <= 0x2006) ||
(c >= 0x2008 && c <= 0x200b) ||
c == 0x205f || c == 0x3000);
}
#endif /* MB_CAPABLE */
return (c < 0x100 ? isblank (c) : 0);
}

View File

@ -0,0 +1,104 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<iswcntrl>>---wide-character cntrl test
INDEX
iswcntrl
ANSI_SYNOPSIS
#include <wctype.h>
int iswcntrl(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswcntrl(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswcntrl>> is a function which classifies wide-character values that
are categorized as a control character.
RETURNS
<<iswcntrl>> returns non-zero if <[c]> is a control wide-character.
PORTABILITY
<<iswcntrl>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
#include <ctype.h>
#include <string.h>
#include "local.h"
int
_DEFUN(iswcntrl,(c), wint_t c)
{
int unicode = 0;
if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
{
unicode = 0;
/* fall-through */
}
#ifdef MB_CAPABLE
else if (!strcmp (__lc_ctype, "C-JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
unicode = 1;
}
if (unicode)
{
return ((c >= 0x0000 && c <= 0x001f) ||
(c >= 0x007f && c <= 0x009f) ||
c == 0x2028 || c == 0x2029);
}
#endif /* MB_CAPABLE */
return (c < 0x100 ? iscntrl (c) : 0);
}

View File

@ -0,0 +1,70 @@
/*
FUNCTION
<<iswctype>>---extensible wide-character test
INDEX
iswctype
ANSI_SYNOPSIS
#include <wctype.h>
int iswctype(wint_t <[c]>, wctype_t <[desc]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswctype(<[c]>, <[desc]>)
wint_t <[c]>;
wctype_t <[desc]>;
DESCRIPTION
<<iswctype>> is a function which classifies wide-character values using the
wide-character test specified by <[desc]>.
RETURNS
<<iswctype>> returns non-zero if and only if <[c]> matches the test specified by <[desc]>.
If <[desc]> is unknown, zero is returned.
PORTABILITY
<<iswctype>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
#include "local.h"
int
_DEFUN(iswctype,(c, desc), wint_t c _AND wctype_t desc)
{
switch (desc)
{
case WC_ALNUM:
return iswalnum (c);
case WC_ALPHA:
return iswalpha (c);
case WC_BLANK:
return iswblank (c);
case WC_CNTRL:
return iswcntrl (c);
case WC_DIGIT:
return iswdigit (c);
case WC_GRAPH:
return iswgraph (c);
case WC_LOWER:
return iswlower (c);
case WC_PRINT:
return iswprint (c);
case WC_PUNCT:
return iswpunct (c);
case WC_SPACE:
return iswspace (c);
case WC_UPPER:
return iswupper (c);
case WC_XDIGIT:
return iswxdigit (c);
default:
}
/* otherwise unknown */
return 0;
}

View File

@ -0,0 +1,37 @@
/*
FUNCTION
<<iswdigit>>---decimal digit wide-character test
INDEX
iswdigit
ANSI_SYNOPSIS
#include <wctype.h>
int iswdigit(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswdigit(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswdigit>> is a function which classifies wide-character values that
are decimal digits.
RETURNS
<<iswdigit>> returns non-zero if <[c]> is a decimal digit wide-character.
PORTABILITY
<<iswdigit>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
int
_DEFUN(iswdigit,(c), wint_t c)
{
return (c >= (wint_t)'0' && c <= (wint_t)'9');
}

View File

@ -0,0 +1,66 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<iswgraph>>---graphic wide-character test
INDEX
iswgraph
ANSI_SYNOPSIS
#include <wctype.h>
int iswgraph(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswgraph(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswgraph>> is a function which classifies wide-character values that
are graphic.
RETURNS
<<iswgraph>> returns non-zero if <[c]> is a graphic wide-character.
PORTABILITY
<<iswgraph>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
int
_DEFUN(iswgraph,(c),wint_t c)
{
return (iswprint (c) && !iswspace (c));
}

View File

@ -0,0 +1,38 @@
/*
FUNCTION
<<iswlower>>---lower-case wide-character test
INDEX
iswlower
ANSI_SYNOPSIS
#include <wctype.h>
int iswlower(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswlower(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswlower>> is a function which classifies wide-character values that
have an upper-case translation.
RETURNS
<<iswlower>> returns non-zero if <[c]> is a lower-case wide-character.
PORTABILITY
<<iswlower>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
int
_DEFUN(iswlower,(c),wint_t c)
{
return (towupper (c) != c);
}

View File

@ -0,0 +1,397 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<iswprint>>---printable wide-character test
INDEX
iswprint
ANSI_SYNOPSIS
#include <wctype.h>
int iswprint(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswprint(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswprint>> is a function which classifies wide-character values that
are printable.
RETURNS
<<iswprint>> returns non-zero if <[c]> is a printable wide-character.
PORTABILITY
<<iswprint>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
#include <string.h>
#include <ctype.h>
#include "local.h"
#ifdef MB_CAPABLE
#include "utf8print.h"
#endif /* MB_CAPABLE */
int
_DEFUN(iswprint,(c), wint_t c)
{
int unicode = 0;
if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
{
unicode = 0;
/* fall-through */
}
#ifdef MB_CAPABLE
else if (!strcmp (__lc_ctype, "C-JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
unicode = 1;
}
if (unicode)
{
unsigned const char *table;
unsigned char *ptr;
unsigned char ctmp;
int size;
wint_t x = (c >> 8);
/* for some large sections, all characters are printuation so handle them here */
if ((x >= 0x34 && x <= 0x4c) ||
(x >= 0x4e && x <= 0x9e) ||
(x >= 0xac && x <= 0xd6) ||
(x >= 0xe0 && x <= 0xf9) ||
(x >= 0x200 && x <= 0x2a5) ||
(x >= 0xf00 && x <= 0xffe) ||
(x >= 0x1000 && x <= 0x10fe))
return 1;
switch (x)
{
case 0x01:
case 0x15:
case 0x22:
case 0x25:
case 0x28:
case 0x29:
case 0x2a:
case 0xa0:
case 0xa1:
case 0xa2:
case 0xa3:
case 0xfc:
case 0x2f8:
case 0x2f9:
return 1;
case 0x00:
table = u0;
size = sizeof(u0);
break;
case 0x02:
table = u2;
size = sizeof(u2);
break;
case 0x03:
table = u3;
size = sizeof(u3);
break;
case 0x04:
table = u4;
size = sizeof(u4);
break;
case 0x05:
table = u5;
size = sizeof(u5);
break;
case 0x06:
table = u6;
size = sizeof(u6);
break;
case 0x07:
table = u7;
size = sizeof(u7);
break;
case 0x09:
table = u9;
size = sizeof(u9);
break;
case 0x0a:
table = ua;
size = sizeof(ua);
break;
case 0x0b:
table = ub;
size = sizeof(ub);
break;
case 0x0c:
table = uc;
size = sizeof(uc);
break;
case 0x0d:
table = ud;
size = sizeof(ud);
break;
case 0x0e:
table = ue;
size = sizeof(ue);
break;
case 0x0f:
table = uf;
size = sizeof(uf);
break;
case 0x10:
table = u10;
size = sizeof(u10);
break;
case 0x11:
table = u11;
size = sizeof(u11);
break;
case 0x12:
table = u12;
size = sizeof(u12);
break;
case 0x13:
table = u13;
size = sizeof(u13);
break;
case 0x14:
table = u14;
size = sizeof(u14);
break;
case 0x16:
table = u16;
size = sizeof(u16);
break;
case 0x17:
table = u17;
size = sizeof(u17);
break;
case 0x18:
table = u18;
size = sizeof(u18);
break;
case 0x1e:
table = u1e;
size = sizeof(u1e);
break;
case 0x1f:
table = u1f;
size = sizeof(u1f);
break;
case 0x20:
table = u20;
size = sizeof(u20);
break;
case 0x21:
table = u21;
size = sizeof(u21);
break;
case 0x23:
table = u23;
size = sizeof(u23);
break;
case 0x24:
table = u24;
size = sizeof(u24);
break;
case 0x26:
table = u26;
size = sizeof(u26);
break;
case 0x27:
table = u27;
size = sizeof(u27);
break;
case 0x2e:
table = u2e;
size = sizeof(u2e);
break;
case 0x2f:
table = u2f;
size = sizeof(u2f);
break;
case 0x30:
table = u30;
size = sizeof(u30);
break;
case 0x31:
table = u31;
size = sizeof(u31);
break;
case 0x32:
table = u32;
size = sizeof(u32);
break;
case 0x33:
table = u33;
size = sizeof(u33);
break;
case 0x4d:
table = u4d;
size = sizeof(u4d);
break;
case 0x9f:
table = u9f;
size = sizeof(u9f);
break;
case 0xa4:
table = ua4;
size = sizeof(ua4);
break;
case 0xd7:
table = ud7;
size = sizeof(ud7);
break;
case 0xfa:
table = ufa;
size = sizeof(ufa);
break;
case 0xfb:
table = ufb;
size = sizeof(ufb);
break;
case 0xfd:
table = ufd;
size = sizeof(ufd);
break;
case 0xfe:
table = ufe;
size = sizeof(ufe);
break;
case 0xff:
table = uff;
size = sizeof(uff);
break;
case 0x103:
table = u103;
size = sizeof(u103);
break;
case 0x104:
table = u104;
size = sizeof(u104);
break;
case 0x1d0:
table = u1d0;
size = sizeof(u1d0);
break;
case 0x1d1:
table = u1d1;
size = sizeof(u1d1);
break;
case 0x1d4:
table = u1d4;
size = sizeof(u1d4);
break;
case 0x1d5:
table = u1d5;
size = sizeof(u1d5);
break;
case 0x1d6:
table = u1d6;
size = sizeof(u1d6);
break;
case 0x1d7:
table = u1d7;
size = sizeof(u1d7);
break;
case 0x2a6:
table = u2a6;
size = sizeof(u2a6);
break;
case 0x2fa:
table = u2fa;
size = sizeof(u2fa);
break;
case 0xe00:
table = ue00;
size = sizeof(ue00);
break;
case 0xfff:
table = ufff;
size = sizeof(ufff);
break;
case 0x10ff:
table = u10ff;
size = sizeof(u10ff);
break;
default:
return 0;
}
/* we have narrowed down to a section of 256 characters to check */
/* now check if c matches the printuation wide-chars within that section */
ptr = (unsigned char *)table;
ctmp = (unsigned char)c;
while (ptr < table + size)
{
if (ctmp == *ptr)
return 1;
if (ctmp < *ptr)
return 0;
/* otherwise c > *ptr */
/* look for 0x0 as next element which indicates a range */
++ptr;
if (*ptr == 0x0)
{
/* we have a range..see if c falls within range */
++ptr;
if (ctmp <= *ptr)
return 1;
++ptr;
}
}
/* not in table */
return 0;
}
#endif /* MB_CAPABLE */
return (c < (wint_t)0x100 ? isprint (c) : 0);
}

View File

@ -0,0 +1,332 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<iswpunct>>---punctuation wide-character test
INDEX
iswpunct
ANSI_SYNOPSIS
#include <wctype.h>
int iswpunct(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswpunct(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswpunct>> is a function which classifies wide-character values that
are punctuation.
RETURNS
<<iswpunct>> returns non-zero if <[c]> is a punctuation wide-character.
PORTABILITY
<<iswpunct>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
#include <string.h>
#include <ctype.h>
#include "local.h"
#ifdef MB_CAPABLE
#include "utf8punct.h"
#endif /* MB_CAPABLE */
int
_DEFUN(iswpunct,(c), wint_t c)
{
int unicode = 0;
if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
{
unicode = 0;
/* fall-through */
}
#ifdef MB_CAPABLE
else if (!strcmp (__lc_ctype, "C-JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
unicode = 1;
}
if (unicode)
{
unsigned const char *table;
unsigned char *ptr;
unsigned char ctmp;
int size;
wint_t x = (c >> 8);
/* for some large sections, all characters are punctuation so handle them here */
if ((x >= 0xe0 && x <= 0xf8) ||
(x >= 0xf00 && x <= 0xffe) ||
(x >= 0x1000 && x <= 0x10fe))
return 1;
switch (x)
{
case 0x22:
case 0x25:
case 0x28:
case 0x29:
case 0x2a:
return 1;
case 0x00:
table = u0;
size = sizeof(u0);
break;
case 0x02:
table = u2;
size = sizeof(u2);
break;
case 0x03:
table = u3;
size = sizeof(u3);
break;
case 0x04:
table = u4;
size = sizeof(u4);
break;
case 0x05:
table = u5;
size = sizeof(u5);
break;
case 0x06:
table = u6;
size = sizeof(u6);
break;
case 0x07:
table = u7;
size = sizeof(u7);
break;
case 0x09:
table = u9;
size = sizeof(u9);
break;
case 0x0a:
table = ua;
size = sizeof(ua);
break;
case 0x0b:
table = ub;
size = sizeof(ub);
break;
case 0x0c:
table = uc;
size = sizeof(uc);
break;
case 0x0d:
table = ud;
size = sizeof(ud);
break;
case 0x0e:
table = ue;
size = sizeof(ue);
break;
case 0x0f:
table = uf;
size = sizeof(uf);
break;
case 0x10:
table = u10;
size = sizeof(u10);
break;
case 0x13:
table = u13;
size = sizeof(u13);
break;
case 0x16:
table = u16;
size = sizeof(u16);
break;
case 0x17:
table = u17;
size = sizeof(u17);
break;
case 0x18:
table = u18;
size = sizeof(u18);
break;
case 0x1f:
table = u1f;
size = sizeof(u1f);
break;
case 0x20:
table = u20;
size = sizeof(u20);
break;
case 0x21:
table = u21;
size = sizeof(u21);
break;
case 0x23:
table = u23;
size = sizeof(u23);
break;
case 0x24:
table = u24;
size = sizeof(u24);
break;
case 0x26:
table = u26;
size = sizeof(u26);
break;
case 0x27:
table = u27;
size = sizeof(u27);
break;
case 0x2e:
table = u2e;
size = sizeof(u2e);
break;
case 0x2f:
table = u2f;
size = sizeof(u2f);
break;
case 0x30:
table = u30;
size = sizeof(u30);
break;
case 0x31:
table = u31;
size = sizeof(u31);
break;
case 0x32:
table = u32;
size = sizeof(u32);
break;
case 0x33:
table = u33;
size = sizeof(u33);
break;
case 0xa4:
table = ua4;
size = sizeof(ua4);
break;
case 0xfb:
table = ufb;
size = sizeof(ufb);
break;
case 0xfd:
table = ufd;
size = sizeof(ufd);
break;
case 0xfe:
table = ufe;
size = sizeof(ufe);
break;
case 0xff:
table = uff;
size = sizeof(uff);
break;
case 0x103:
table = u103;
size = sizeof(u103);
break;
case 0x1d0:
table = u1d0;
size = sizeof(u1d0);
break;
case 0x1d1:
table = u1d1;
size = sizeof(u1d1);
break;
case 0x1d6:
table = u1d6;
size = sizeof(u1d6);
break;
case 0x1d7:
table = u1d7;
size = sizeof(u1d7);
break;
case 0xe00:
table = ue00;
size = sizeof(ue00);
break;
case 0xfff:
table = ufff;
size = sizeof(ufff);
break;
case 0x10ff:
table = u10ff;
size = sizeof(u10ff);
break;
default:
return 0;
}
/* we have narrowed down to a section of 256 characters to check */
/* now check if c matches the punctuation wide-chars within that section */
ptr = (unsigned char *)table;
ctmp = (unsigned char)c;
while (ptr < table + size)
{
if (ctmp == *ptr)
return 1;
if (ctmp < *ptr)
return 0;
/* otherwise c > *ptr */
/* look for 0x0 as next element which indicates a range */
++ptr;
if (*ptr == 0x0)
{
/* we have a range..see if c falls within range */
++ptr;
if (ctmp <= *ptr)
return 1;
++ptr;
}
}
/* not in table */
return 0;
}
#endif /* MB_CAPABLE */
return (c < (wint_t)0x100 ? ispunct (c) : 0);
}

View File

@ -0,0 +1,106 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<iswspace>>---wide-character space test
INDEX
iswspace
ANSI_SYNOPSIS
#include <wctype.h>
int iswspace(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswspace(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswspace>> is a function which classifies wide-character values that
are categorized as white-space.
RETURNS
<<iswspace>> returns non-zero if <[c]> is a white-space wide-character.
PORTABILITY
<<iswspace>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
#include <ctype.h>
#include <string.h>
#include "local.h"
int
_DEFUN(iswspace,(c), wint_t c)
{
int unicode = 0;
if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
{
unicode = 0;
/* fall-through */
}
#ifdef MB_CAPABLE
else if (!strcmp (__lc_ctype, "C-JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
unicode = 1;
}
if (unicode)
{
return ((c >= 0x0009 && c <= 0x000d) || c == 0x0020 || c == 0x1680 ||
(c >= 0x2000 && c <= 0x2006) ||
(c >= 0x2008 && c <= 0x200b) ||
c == 0x2028 || c == 0x2029 ||
c == 0x205f || c == 0x3000);
}
#endif /* MB_CAPABLE */
return (c < 0x100 ? isspace (c) : 0);
}

View File

@ -0,0 +1,38 @@
/*
FUNCTION
<<iswupper>>---upper-case wide-character test
INDEX
iswupper
ANSI_SYNOPSIS
#include <wctype.h>
int iswupper(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswupper(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswupper>> is a function which classifies wide-character values that
have an upper-case translation.
RETURNS
<<iswupper>> returns non-zero if <[c]> is a upper-case wide-character.
PORTABILITY
<<iswupper>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
int
_DEFUN(iswupper,(c),wint_t c)
{
return (towlower (c) != c);
}

View File

@ -0,0 +1,39 @@
/*
FUNCTION
<<iswxdigit>>---hexadecimal digit wide-character test
INDEX
iswxdigit
ANSI_SYNOPSIS
#include <wctype.h>
int iswxdigit(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
int iswxdigit(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<iswxdigit>> is a function which classifies wide-character values that
are hexadecimal digits.
RETURNS
<<iswxdigit>> returns non-zero if <[c]> is a hexadecimal digit wide-character.
PORTABILITY
<<iswxdigit>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <wctype.h>
int
_DEFUN(iswxdigit,(c), wint_t c)
{
return ((c >= (wint_t)'0' && c <= (wint_t)'9') ||
(c >= (wint_t)'a' && c <= (wint_t)'f') ||
(c >= (wint_t)'A' && c <= (wint_t)'F'));
}

86
newlib/libc/ctype/jp2uc.c Normal file
View File

@ -0,0 +1,86 @@
/* Routine to translate from Japanese characters to Unicode */
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef MB_CAPABLE
#include <_ansi.h>
#include <wctype.h>
#include "local.h"
#include "jp2uc.h"
wint_t
_DEFUN (__jp2uc, (c, type), wint_t c _AND int type)
{
int index, adj;
unsigned char byte1, byte2, adj_byte1, adj_byte2;
/* we actually use a table of JIS to Unicode. For SJIS, we simply
note that SJIS is essentially JIS with the top bits on in each
byte. For EUCJP, we essentially do a translation to JIS before
accessing the table. */
switch (type)
{
case JP_JIS:
index = ((c >> 8) - 0x21) * 0xfe + ((c & 0xff) - 0x21);
break;
case JP_SJIS:
index = ((c >> 8) - 0xa1) * 0xfe + ((c & 0xff) - 0xa1);
break;
case JP_EUCJP:
byte1 = c >> 8;
byte2 = c & 0xff;
if (byte2 <= 0x7e || (byte2 & 0x1))
{
adj = -0x22;
adj_byte2 = (byte2 & 0xfe) - 31;
}
else
{
adj = -0x21;
adj_byte2 = byte2 - (0x7e + 0x21);
}
if (byte1 <= 0x9f)
adj_byte1 = ((byte1 - 112) >> 1) + adj;
else
adj_byte1 = ((byte1 - 112) >> 1) + adj;
index = adj_byte1 * 0xfe + adj_byte2;
break;
default:
return WEOF;
}
if (index < 0 || index > (sizeof(jp2uc) / sizeof(unsigned short)))
return WEOF;
return (wint_t)jp2uc[index];
}
#endif /* MB_CAPABLE */

6883
newlib/libc/ctype/jp2uc.h Normal file

File diff suppressed because it is too large Load Diff

32
newlib/libc/ctype/local.h Normal file
View File

@ -0,0 +1,32 @@
/* wctrans constants */
#include <_ansi.h>
/* valid values for wctrans_t */
#define WCT_TOLOWER 1
#define WCT_TOUPPER 2
/* valid values for wctype_t */
#define WC_ALNUM 1
#define WC_ALPHA 2
#define WC_BLANK 3
#define WC_CNTRL 4
#define WC_DIGIT 5
#define WC_GRAPH 6
#define WC_LOWER 7
#define WC_PRINT 8
#define WC_PUNCT 9
#define WC_SPACE 10
#define WC_UPPER 11
#define WC_XDIGIT 12
extern char __lc_ctype[12];
/* Japanese encoding types supported */
#define JP_JIS 1
#define JP_SJIS 2
#define JP_EUCJP 3
/* internal function to translate JP to Unicode */
wint_t _EXFUN (__jp2uc, (wint_t, int));

View File

@ -0,0 +1,97 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<towctrans>>---extensible wide-character case mapping
INDEX
towctrans
ANSI_SYNOPSIS
#include <wctype.h>
wint_t towctrans(wint_t <[c]>, wctrans_t <[w]>);
TRAD_SYNOPSIS
#include <wctype.h>
wint_t towctrans(<[c]>, <[w]>)
wint_t <[c]>;
wctrans_t <[w]>;
DESCRIPTION
<<towctrans>> is a function which converts wide-characters based on
a specified translation type <[w]>. If the translation type is
invalid or cannot be applied to the current character, no change
to the character is made.
RETURNS
<<towctrans>> returns the translated equivalent of <[c]> when it is a
valid for the given translation, otherwise, it returns the input character.
When the translation type is invalid, <<errno>> is set <<EINVAL>>.
PORTABILITY
<<towctrans>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <string.h>
#include <reent.h>
#include <wctype.h>
#include <errno.h>
#include "local.h"
wint_t
_DEFUN (_towctrans_r, (r, c, w),
struct _reent *r _AND
wint_t c _AND
wctrans_t w)
{
if (w == WCT_TOLOWER)
return towlower (c);
else if (w == WCT_TOUPPER)
return towupper (c);
else
{
r->_errno = EINVAL;
return c;
}
}
#ifndef _REENT_ONLY
wint_t
_DEFUN (towctrans, (c, w),
wint_t c _AND
wctrans_t w)
{
return _towctrans_r (_REENT, c, w);
}
#endif /* !_REENT_ONLY */

View File

@ -0,0 +1,478 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<towlower>>---translate wide-characters to lower case
INDEX
towlower
ANSI_SYNOPSIS
#include <wctype.h>
wint_t towlower(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
wint_t towlower(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<towlower>> is a function which converts upper-case wide-characters to lower
case, leaving all other characters unchanged.
RETURNS
<<towlower>> returns the lower-case equivalent of <[c]> when it is a
upper-case wide-character, otherwise, it returns the input character.
PORTABILITY
<<towlower>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <string.h>
#include <reent.h>
#include <ctype.h>
#include <wctype.h>
#include "local.h"
wint_t
_DEFUN(towlower,(c), wint_t c)
{
int unicode = 0;
if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
{
unicode = 0;
/* fall-through */
}
#ifdef MB_CAPABLE
else if (!strcmp (__lc_ctype, "C-JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
unicode = 1;
}
if (unicode)
{
if (c < 0x100)
{
if ((c >= 0x0041 && c <= 0x005a) ||
(c >= 0x00c0 && c <= 0x00de))
return (c + 0x20);
if (c == 0x00b5)
return 0x03bc;
return c;
}
else if (c < 0x300)
{
if ((c >= 0x0100 && c <= 0x012e) ||
(c >= 0x0132 && c <= 0x0136) ||
(c >= 0x014a && c <= 0x0176) ||
(c >= 0x01de && c <= 0x01ee) ||
(c >= 0x01f8 && c <= 0x021e) ||
(c >= 0x0222 && c <= 0x0232))
{
if (!(c & 0x01))
return (c + 1);
return c;
}
if ((c >= 0x0139 && c <= 0x0147) ||
(c >= 0x01cd && c <= 0x91db))
{
if (c & 0x01)
return (c + 1);
return c;
}
if (c >= 0x178 && c <= 0x01f7)
{
wint_t k;
switch (c)
{
case 0x0178:
k = 0x00ff;
break;
case 0x0179:
case 0x017b:
case 0x017d:
case 0x0182:
case 0x0184:
case 0x0187:
case 0x018b:
case 0x0191:
case 0x0198:
case 0x01a0:
case 0x01a2:
case 0x01a4:
case 0x01a7:
case 0x01ac:
case 0x01af:
case 0x01b3:
case 0x01b5:
case 0x01b8:
case 0x01bc:
case 0x01c5:
case 0x01c8:
case 0x01cb:
case 0x01cd:
case 0x01cf:
case 0x01d1:
case 0x01d3:
case 0x01d5:
case 0x01d7:
case 0x01d9:
case 0x01db:
case 0x01f2:
case 0x01f4:
k = c + 1;
break;
case 0x017f:
k = 0x0073;
break;
case 0x0181:
k = 0x0253;
break;
case 0x0186:
k = 0x0254;
break;
case 0x0189:
k = 0x0256;
break;
case 0x018a:
k = 0x0257;
break;
case 0x018e:
k = 0x01dd;
break;
case 0x018f:
k = 0x0259;
break;
case 0x0190:
k = 0x025b;
break;
case 0x0193:
k = 0x0260;
break;
case 0x0194:
k = 0x0263;
break;
case 0x0196:
k = 0x0269;
break;
case 0x0197:
k = 0x0268;
break;
case 0x019c:
k = 0x026f;
break;
case 0x019d:
k = 0x0272;
break;
case 0x019f:
k = 0x0275;
break;
case 0x01a6:
k = 0x0280;
break;
case 0x01a9:
k = 0x0283;
break;
case 0x01ae:
k = 0x0288;
break;
case 0x01b1:
k = 0x028a;
break;
case 0x01b2:
k = 0x028b;
break;
case 0x01b7:
k = 0x0292;
break;
case 0x01c4:
case 0x01c7:
case 0x01ca:
case 0x01f1:
k = c + 2;
break;
case 0x01f6:
k = 0x0195;
break;
case 0x01f7:
k = 0x01bf;
break;
default:
k = 0;
}
if (k != 0)
return k;
}
if (c == 0x0220)
return 0x019e;
}
else if (c < 0x0400)
{
if (c >= 0x0391 && c <= 0x03ab && c != 0x03a2)
return (c + 0x20);
if (c >= 0x03d8 && c <= 0x03ee && !(c & 0x01))
return (c + 1);
if (c >= 0x0386 && c <= 0x03f5)
{
wint_t k;
switch (c)
{
case 0x0386:
k = 0x03ac;
break;
case 0x0388:
k = 0x03ad;
break;
case 0x0389:
k = 0x03ae;
break;
case 0x038a:
k = 0x03af;
break;
case 0x038c:
k = 0x03cc;
break;
case 0x038e:
k = 0x03cd;
break;
case 0x038f:
k = 0x038f;
break;
case 0x03c2:
k = 0x03c3;
break;
case 0x03d0:
k = 0x03b2;
break;
case 0x03d1:
k = 0x03b8;
break;
case 0x03d5:
k = 0x03c6;
break;
case 0x03d6:
k = 0x03c0;
break;
case 0x03f0:
k = 0x03ba;
break;
case 0x03f1:
k = 0x03c1;
break;
case 0x03f2:
k = 0x03c3;
break;
case 0x03f4:
k = 0x03b8;
break;
case 0x03f5:
k = 0x03b5;
break;
default:
k = 0;
}
if (k != 0)
return k;
}
if (c == 0x0345)
return 0x03b9;
}
else if (c < 0x500)
{
if (c >= 0x0400 && c <= 0x040f)
return (c + 0x50);
if (c >= 0x0410 && c <= 0x042f)
return (c + 0x20);
if ((c >= 0x0460 && c <= 0x0480) ||
(c >= 0x048a && c <= 0x04be) ||
(c >= 0x04d0 && c <= 0x04f4) ||
(c == 0x04f8))
{
if (!(c & 0x01))
return (c + 1);
return c;
}
if (c >= 0x04c1 && c <= 0x04cd)
{
if (c & 0x01)
return (c + 1);
return c;
}
}
else if (c < 0x1f00)
{
if ((c >= 0x0500 && c <= 0x050e) ||
(c >= 0x1e00 && c <= 0x1e94) ||
(c >= 0x1ea0 && c <= 0x1ef8))
{
if (!(c & 0x01))
return (c + 1);
return c;
}
if (c >= 0x0531 && c <= 0x0556)
return (c + 0x30);
if (c == 0x1e9b)
return 0x1e61;
}
else if (c < 0x2000)
{
if ((c >= 0x1f08 && c <= 0x1f0f) ||
(c >= 0x1f18 && c <= 0x1f1d) ||
(c >= 0x1f28 && c <= 0x1f2f) ||
(c >= 0x1f38 && c <= 0x1f3f) ||
(c >= 0x1f48 && c <= 0x1f4d) ||
(c >= 0x1f68 && c <= 0x1f6f) ||
(c >= 0x1f88 && c <= 0x1f8f) ||
(c >= 0x1f98 && c <= 0x1f9f) ||
(c >= 0x1fa8 && c <= 0x1faf))
return (c - 0x08);
if (c >= 0x1f59 && c <= 0x1f5f)
{
if (c & 0x01)
return (c - 0x08);
return c;
}
if (c >= 0x1fb8 && c <= 0x1ffc)
{
wint_t k;
switch (c)
{
case 0x1fb8:
case 0x1fb9:
case 0x1fd8:
case 0x1fd9:
case 0x1fe8:
case 0x1fe9:
k = c - 0x08;
break;
case 0x1fba:
case 0x1fbb:
k = c - 0x4a;
break;
case 0x1fbc:
k = 0x1fb3;
break;
case 0x1fbe:
k = 0x03b9;
break;
case 0x1fc8:
case 0x1fc9:
case 0x1fca:
case 0x1fcb:
k = c - 0x56;
break;
case 0x1fcc:
k = 0x1fc3;
break;
case 0x1fda:
case 0x1fdb:
k = c - 0x64;
break;
case 0x1fea:
case 0x1feb:
k = c - 0x70;
break;
case 0x1fec:
k = 0x1fe5;
break;
case 0x1ffa:
case 0x1ffb:
k = c - 0x7e;
break;
case 0x1ffc:
k = 0x1ff3;
break;
default:
k = 0;
}
if (k != 0)
return k;
}
}
else
{
if (c >= 0x2160 && c <= 0x216f)
return (c + 0x10);
if (c >= 0x24b6 && c <= 0x24cf)
return (c + 0x1a);
if (c >= 0xff21 && c <= 0xff3a)
return (c + 0x20);
if (c >= 0x10400 && c <= 0x10425)
return (c + 0x28);
if (c == 0x2126)
return 0x03c9;
if (c == 0x212a)
return 0x006b;
if (c == 0x212b)
return 0x00e5;
}
}
#endif /* MB_CAPABLE */
return (c < 0x00ff ? (wint_t)(tolower ((int)c)) : c);
}

View File

@ -0,0 +1,505 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<towupper>>---translate wide-characters to upper case
INDEX
towupper
ANSI_SYNOPSIS
#include <wctype.h>
wint_t towupper(wint_t <[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
wint_t towupper(<[c]>)
wint_t <[c]>;
DESCRIPTION
<<towupper>> is a function which converts lower-case wide-characters to upper
case, leaving all other characters unchanged.
RETURNS
<<towupper>> returns the upper-case equivalent of <[c]> when it is a
lower-case wide-character, otherwise, it returns the input character.
PORTABILITY
<<towupper>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <string.h>
#include <reent.h>
#include <ctype.h>
#include <wctype.h>
#include "local.h"
wint_t
_DEFUN(towupper,(c), wint_t c)
{
int unicode = 0;
if (__lc_ctype[0] == 'C' && __lc_ctype[1] == '\0')
{
unicode = 0;
/* fall-through */
}
#ifdef MB_CAPABLE
else if (!strcmp (__lc_ctype, "C-JIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
c = __jp2uc (c, JP_JIS);
unicode = 1;
}
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
unicode = 1;
}
if (unicode)
{
if (c < 0x100)
{
if (c == 0x00b5)
return 0x039c;
if ((c >= 0x00e0 && c <= 0x00fe) ||
(c >= 0x0061 && c <= 0x007a))
return (c - 0x20);
if (c == 0xff)
return 0x0178;
return c;
}
else if (c < 0x300)
{
if ((c >= 0x0101 && c <= 0x012f) ||
(c >= 0x0133 && c <= 0x0137) ||
(c >= 0x014b && c <= 0x0177) ||
(c >= 0x01df && c <= 0x01ef) ||
(c >= 0x01f9 && c <= 0x021f) ||
(c >= 0x0223 && c <= 0x0233))
{
if (c & 0x01)
return (c - 1);
return c;
}
if ((c >= 0x013a && c <= 0x0148) ||
(c >= 0x01ce && c <= 0x1dc))
{
if (!(c & 0x01))
return (c - 1);
return c;
}
if (c == 0x0131)
return 0x0049;
if (c == 0x017a || c == 0x017c || c == 0x017e)
return (c - 1);
if (c >= 0x017f && c <= 0x0292)
{
wint_t k;
switch (c)
{
case 0x017f:
k = 0x0053;
break;
case 0x0183:
k = 0x0182;
break;
case 0x0185:
k = 0x0184;
break;
case 0x0188:
k = 0x0187;
break;
case 0x018c:
k = 0x018b;
break;
case 0x0192:
k = 0x0191;
break;
case 0x0195:
k = 0x01f6;
break;
case 0x0199:
k = 0x0198;
break;
case 0x019e:
k = 0x0220;
break;
case 0x01a1:
case 0x01a3:
case 0x01a5:
case 0x01a8:
case 0x01ad:
case 0x01b0:
case 0x01b4:
case 0x01b6:
case 0x01b9:
case 0x01bd:
case 0x01c5:
case 0x01c8:
case 0x01cb:
case 0x01f2:
case 0x01f5:
k = c - 1;
break;
case 0x01bf:
k = 0x01f7;
break;
case 0x01c6:
case 0x01c9:
case 0x01cc:
k = c - 2;
break;
case 0x01dd:
k = 0x018e;
break;
case 0x01f3:
k = 0x01f1;
break;
case 0x0253:
k = 0x0181;
break;
case 0x0254:
k = 0x0186;
break;
case 0x0256:
k = 0x0189;
break;
case 0x0257:
k = 0x018a;
break;
case 0x0259:
k = 0x018f;
break;
case 0x025b:
k = 0x0190;
break;
case 0x0260:
k = 0x0193;
break;
case 0x0263:
k = 0x0194;
break;
case 0x0268:
k = 0x0197;
break;
case 0x0269:
k = 0x0196;
break;
case 0x026f:
k = 0x019c;
break;
case 0x0272:
k = 0x019d;
break;
case 0x0275:
k = 0x019f;
break;
case 0x0280:
k = 0x01a6;
break;
case 0x0283:
k = 0x01a9;
break;
case 0x0288:
k = 0x01ae;
break;
case 0x028a:
k = 0x01b1;
break;
case 0x028b:
k = 0x01b2;
break;
case 0x0292:
k = 0x01b7;
break;
default:
k = 0;
}
if (k != 0)
return k;
}
}
else if (c < 0x0400)
{
if (c == 0x03ac)
return 0x0386;
if ((c & 0xfff0) == 0x03a0 && c >= 0x03ad)
return (c - 0x15);
if (c >= 0x03b1 && c <= 0x03cb && c != 0x03c2)
return (c - 0x20);
if (c == 0x03c2)
return 0x03a3;
if (c >= 0x03cc && c <= 0x03f5)
{
wint_t k;
switch (c)
{
case 0x03cc:
k = 0x038c;
break;
case 0x03cd:
case 0x03ce:
k = c - 0x3f;
break;
case 0x03d0:
k = 0x0392;
break;
case 0x03d1:
k = 0x0398;
break;
case 0x03d5:
k = 0x03a6;
break;
case 0x03d6:
k = 0x03a0;
break;
case 0x03d9:
case 0x03db:
case 0x03dd:
case 0x03df:
case 0x03e1:
case 0x03e3:
case 0x03e5:
case 0x03e7:
case 0x03e9:
case 0x03eb:
case 0x03ed:
case 0x03ef:
k = c - 1;
break;
case 0x03f0:
k = 0x039a;
break;
case 0x03f1:
k = 0x03a1;
break;
case 0x03f2:
k = 0x03a3;
break;
case 0x03f5:
k = 0x0395;
break;
default:
k = 0;
}
if (k != 0)
return k;
}
}
else if (c < 0x500)
{
if (c >= 0x0450 && c <= 0x045f)
return (c - 0x50);
if (c >= 0x0430 && c <= 0x044f)
return (c - 0x20);
if ((c >= 0x0461 && c <= 0x0481) ||
(c >= 0x048b && c <= 0x04bf) ||
(c >= 0x04d1 && c <= 0x04f5))
{
if (c & 0x01)
return (c - 1);
return c;
}
if (c >= 0x04c2 && c <= 0x04ce)
{
if (!(c & 0x01))
return (c - 1);
return c;
}
if (c == 0x04f9)
return 0x04f8;
}
else if (c < 0x1f00)
{
if ((c >= 0x0501 && c <= 0x050f) ||
(c >= 0x1e01 && c <= 0x1e95) ||
(c >= 0x1ea1 && c <= 0x1ef9))
{
if (c & 0x01)
return (c - 1);
return c;
}
if (c >= 0x0561 && c <= 0x0586)
return (c - 0x30);
if (c == 0x1e9b)
return 0x1e60;
}
else if (c < 0x2000)
{
if ((c >= 0x1f00 && c <= 0x1f07) ||
(c >= 0x1f10 && c <= 0x1f15) ||
(c >= 0x1f20 && c <= 0x1f27) ||
(c >= 0x1f30 && c <= 0x1f37) ||
(c >= 0x1f40 && c <= 0x1f45) ||
(c >= 0x1f60 && c <= 0x1f67) ||
(c >= 0x1f80 && c <= 0x1f87) ||
(c >= 0x1f90 && c <= 0x1f97) ||
(c >= 0x1fa0 && c <= 0x1fa7))
return (c + 0x08);
if (c >= 0x1f51 && c <= 0x1f57 && (c & 0x01))
return (c + 0x08);
if (c >= 0x1f70 && c <= 0x1ff3)
{
wint_t k;
switch (c)
{
case 0x1fb0:
k = 0x1fb8;
break;
case 0x1fb1:
k = 0x1fb9;
break;
case 0x1f70:
k = 0x1fba;
break;
case 0x1f71:
k = 0x1fbb;
break;
case 0x1fb3:
k = 0x1fbc;
break;
case 0x1fbe:
k = 0x0399;
break;
case 0x1f72:
k = 0x1fc8;
break;
case 0x1f73:
k = 0x1fc9;
break;
case 0x1f74:
k = 0x1fca;
break;
case 0x1f75:
k = 0x1fcb;
break;
case 0x1fd0:
k = 0x1fd8;
break;
case 0x1fd1:
k = 0x1fd9;
break;
case 0x1f76:
k = 0x1fda;
break;
case 0x1f77:
k = 0x1fdb;
break;
case 0x1fe0:
k = 0x1fe8;
break;
case 0x1fe1:
k = 0x1fe9;
break;
case 0x1f7a:
k = 0x1fea;
break;
case 0x1f7b:
k = 0x1feb;
break;
case 0x1fe5:
k = 0x1fec;
break;
case 0x1f78:
k = 0x1ff8;
break;
case 0x1f79:
k = 0x1ff9;
break;
case 0x1f7c:
k = 0x1ffa;
break;
case 0x1f7d:
k = 0x1ffb;
break;
case 0x1ff3:
k = 0x1ffc;
break;
default:
k = 0;
}
if (k != 0)
return k;
}
}
else
{
if (c >= 0x2170 && c <= 0x217f)
return (c - 0x10);
if (c >= 0x24d0 && c <= 0x24e9)
return (c - 0x1a);
if (c >= 0xff41 && c <= 0xff5a)
return (c - 0x20);
if (c >= 0x10428 && c <= 0x1044d)
return (c - 0x28);
}
}
#endif /* MB_CAPABLE */
return (c < 0x00ff ? (wint_t)(toupper ((int)c)) : c);
}

View File

@ -0,0 +1,235 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Generated using unicode.txt 3.2 */
static const unsigned char u0[] = {
0x41, 0x0, 0x5a, 0x61, 0x0, 0x7a, 0xaa, 0xb5,
0xba, 0xc0, 0x0, 0xd6, 0xd8, 0x0, 0xf6, 0xf8,
0x0, 0xff };
/* u1 all alphabetic */
static const unsigned char u2[] = {
0x00, 0x0, 0x20, 0x22, 0x0, 0x33, 0x50, 0x0, 0xad,
0xb0, 0x0, 0xb8, 0xbb, 0x0, 0xc1, 0xd0, 0x0,
0xd1, 0xe0, 0x0, 0xe4, 0xee };
static const unsigned char u3[] = {
0x45, 0x7a, 0x86,
0x88, 0x0, 0x8a, 0x8c, 0x8e, 0x0, 0xa1, 0xa3,
0x0, 0xce, 0xd0, 0x0, 0xf5 };
static const unsigned char u4[] = {
0x00, 0x0, 0x81,
0x8a, 0x0, 0xce, 0xd0, 0x0, 0xf5, 0xf8, 0x0,
0xf9 };
static const unsigned char u5[] = {
0x00, 0x0, 0x0f, 0x31, 0x0, 0x56, 0x59,
0x61, 0x0, 0x87, 0xd0, 0x0, 0xea, 0xf0, 0x0,
0xf2 };
static const unsigned char u6[] = {
0x21, 0x0, 0x3a,
0x40, 0x0, 0x4a, 0x60,
0x0, 0x69, 0x6e, 0x0, 0x6f, 0x71, 0x0, 0xd3,
0xd5, 0xe5, 0x0, 0xe6, 0xf0, 0x0, 0xfc };
static const unsigned char u7[] = {
0x10,
0x12, 0x0, 0x2c, 0x80, 0x0, 0xa5, 0xb1 };
static const unsigned char u9[] = {
0x05,
0x0, 0x39, 0x3d, 0x50, 0x58, 0x0, 0x61, 0x66,
0x0, 0x6f, 0x85, 0x0, 0x8c, 0x8f, 0x0, 0x90,
0x93, 0x0, 0xa8, 0xaa, 0x0, 0xb0, 0xb2, 0xb6,
0x0, 0xb9, 0xdc, 0x0, 0xdd, 0xdf, 0x0, 0xe1,
0xe6, 0x0, 0xf1 };
static const unsigned char ua[] = {
0x05, 0x0, 0x0a, 0x0f, 0x0,
0x10, 0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, 0x32,
0x0, 0x33, 0x35, 0x0, 0x36, 0x38, 0x0, 0x39,
0x59, 0x0, 0x5c, 0x5e, 0x66, 0x0, 0x6f, 0x72,
0x0, 0x74, 0x85, 0x0, 0x8b, 0x8d, 0x8f, 0x0,
0x91, 0x93, 0x0, 0xa8, 0xaa, 0x0, 0xb0, 0xb2,
0x0, 0xb3, 0xb5, 0x0, 0xb9, 0xbd, 0xd0, 0xe0,
0xe6, 0x0, 0xef };
static const unsigned char ub[] = {
0x05, 0x0, 0x0c, 0x0f, 0x0,
0x10, 0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, 0x32,
0x0, 0x33, 0x36, 0x0, 0x39, 0x3d, 0x5c, 0x0,
0x5d, 0x5f, 0x0, 0x61, 0x66, 0x0, 0x6f, 0x83,
0x85, 0x0, 0x8a, 0x8e, 0x0, 0x90, 0x92, 0x0,
0x95, 0x99, 0x0, 0x9a, 0x9c, 0x9e, 0x0, 0x9f,
0xa3, 0x0, 0xa4, 0xa8, 0x0, 0xaa, 0xae, 0x0,
0xb5, 0xb7, 0x0, 0xb9, 0xe7, 0x0, 0xef };
static const unsigned char uc[] = {
0x05,
0x0, 0x0c, 0x0e, 0x0, 0x10, 0x12, 0x0, 0x28,
0x2a, 0x0, 0x33, 0x35, 0x0, 0x39, 0x60, 0x0,
0x61, 0x66, 0x0, 0x6f, 0x85, 0x0, 0x8c, 0x8e,
0x0, 0x90, 0x92, 0x0, 0xa8, 0xaa, 0x0, 0xb3,
0xb5, 0x0, 0xb9, 0xde, 0xe0, 0x0, 0xe1, 0xe6,
0x0, 0xef };
static const unsigned char ud[] = {
0x05, 0x0, 0x0c, 0x0e, 0x0, 0x10,
0x12, 0x0, 0x28, 0x2a, 0x0, 0x39, 0x60, 0x0,
0x61, 0x66, 0x0, 0x6f, 0x85, 0x0, 0x96, 0x9a,
0x0, 0xb1, 0xb3, 0x0, 0xbb, 0xbd, 0xc0, 0x0,
0xc6 };
static const unsigned char ue[] = {
0x01, 0x0, 0x2e, 0x30, 0x0, 0x3a, 0x40,
0x0, 0x45, 0x47, 0x0, 0x4e, 0x50, 0x0, 0x59,
0x81, 0x0, 0x82, 0x84, 0x87, 0x0, 0x88, 0x8a,
0x8d, 0x94, 0x0, 0x97, 0x99, 0x0, 0x9f, 0xa1,
0x0, 0xa3, 0xa5, 0xa7, 0xaa, 0x0, 0xab, 0xad,
0x0, 0xb0, 0xb2, 0x0, 0xb3, 0xbd, 0xc0, 0x0,
0xc4, 0xc6, 0xd0, 0x0, 0xd9, 0xdc, 0x0, 0xdd };
static const unsigned char uf[] = {
0x00, 0x20, 0x0, 0x29, 0x40, 0x0, 0x47, 0x49,
0x0, 0x6a, 0x88, 0x0, 0x8b };
static const unsigned char u10[] = {
0x00, 0x0, 0x21,
0x23, 0x0, 0x27, 0x29, 0x0, 0x2a, 0x40, 0x0,
0x49, 0x50, 0x0, 0x55, 0xa0, 0x0, 0xc5, 0xd0,
0x0, 0xf8 };
static const unsigned char u11[] = {
0x00, 0x0, 0x59, 0x5f, 0x0, 0xa2,
0xa8, 0x0, 0xf9 };
static const unsigned char u12[] = {
0x00, 0x0, 0x06, 0x08, 0x0,
0x46, 0x48, 0x4a, 0x0, 0x4d, 0x50, 0x0, 0x56,
0x58, 0x5a, 0x0, 0x5d, 0x60, 0x0, 0x86, 0x88,
0x8a, 0x0, 0x8d, 0x90, 0x0, 0xae, 0xb0, 0xb2,
0x0, 0xb5, 0xb8, 0x0, 0xbe, 0xc0, 0xc2, 0x0,
0xc5, 0xc8, 0x0, 0xce, 0xd0, 0x0, 0xd6, 0xd8,
0x0, 0xee, 0xf0, 0x0, 0xff };
static const unsigned char u13[] = {
0x00, 0x0, 0x0e, 0x10, 0x12, 0x0,
0x15, 0x18, 0x0, 0x1e, 0x20, 0x0, 0x46, 0x48,
0x0, 0x5a, 0x69, 0x0, 0x71, 0xa0, 0x0, 0xf4 };
static const unsigned char u14[] = {
0x01, 0x0, 0xff };
/* u15 all alphabetic */
static const unsigned char u16[] = {
0x00, 0x0, 0x6c, 0x6f, 0x0, 0x76,
0x81, 0x0, 0x9a, 0xa0, 0x0, 0xea, 0xee, 0x0, 0xf0 };
static const unsigned char u17[] = {
0x00,
0x0, 0x0c, 0x0e, 0x0, 0x11, 0x20, 0x0, 0x31,
0x40, 0x0, 0x51, 0x60, 0x0, 0x6c, 0x6e, 0x0,
0x70, 0x80, 0x0, 0xb3, 0xd7, 0xdc, 0xe0, 0x0,
0xe9 };
static const unsigned char u18[] = {
0x10, 0x0, 0x19, 0x20, 0x0, 0x77, 0x80,
0x0, 0xa8 };
static const unsigned char u1e[] = {
0x00, 0x0, 0x9b, 0xa0, 0x0, 0xf9 };
static const unsigned char u1f[] = {
0x00, 0x0, 0x15, 0x18, 0x0, 0x1d,
0x20, 0x0, 0x45, 0x48, 0x0, 0x4d, 0x50, 0x0, 0x57, 0x59,
0x5b, 0x5d, 0x5f, 0x0, 0x7d, 0x80, 0x0, 0xb4,
0xb6, 0x0, 0xbc, 0xbe, 0xc2, 0x0, 0xc4, 0xc6,
0x0, 0xcc, 0xd0, 0x0, 0xd3, 0xd6, 0x0, 0xdb,
0xe0, 0x0, 0xec, 0xf2, 0x0, 0xf4, 0xf6, 0x0,
0xfc };
static const unsigned char u20[] = {
0x71, 0x7f };
static const unsigned char u21[] = {
0x02, 0x07, 0x0a, 0x0, 0x13,
0x15, 0x19, 0x0, 0x1d, 0x24, 0x26, 0x28, 0x0,
0x2d, 0x2f, 0x0, 0x31, 0x33, 0x0, 0x39, 0x3d,
0x0, 0x3f, 0x45, 0x0, 0x49, 0x60, 0x0, 0x83 };
static const unsigned char u24[] = {
0x9c, 0x0, 0xe9 };
static const unsigned char u30[] = {
0x05, 0x0, 0x07, 0x21, 0x0,
0x29, 0x31, 0x0, 0x35, 0x38, 0x0, 0x3c, 0x41,
0x0, 0x96, 0x9d, 0x0, 0x9f, 0xa1, 0x0, 0xfa,
0xfc, 0x0, 0xff };
static const unsigned char u31[] = {
0x05, 0x0, 0x2c, 0x31, 0x0,
0x8e, 0xa0, 0x0, 0xb7, 0xf0, 0x0, 0xff };
/* u34 to u4c all alphabetic */
static const unsigned char u4d[] = {
0x00, 0x0, 0xb5 };
/* u4e to u9e all alphabetic */
static const unsigned char u9f[] = {
0x00, 0x0, 0xa5 };
/* ua0 to ua3 all alphabetic */
static const unsigned char ua4[] = {
0x00, 0x0, 0x8c };
/* uac to ud6 all alphabetic */
static const unsigned char ud7[] = {
0xa3 };
/* uf9 all alphabetic */
static const unsigned char ufa[] = {
0x00, 0x0, 0x2d, 0x30, 0x0, 0x6a };
static const unsigned char ufb[] = {
0x00, 0x0, 0x06, 0x13, 0x0, 0x17, 0x1d,
0x1f, 0x0, 0x28, 0x2a, 0x0, 0x36, 0x38, 0x0,
0x3c, 0x3e, 0x40, 0x0, 0x41, 0x43, 0x0, 0x44,
0x46, 0x0, 0xb1, 0xd3, 0x0, 0xff };
/* ufc all alphabetic */
static const unsigned char ufd[] = {
0x00, 0x0, 0x3d, 0x50, 0x0,
0x8f, 0x92, 0x0, 0xc7, 0xf0, 0x0, 0xfb };
static const unsigned char ufe[] = {
0x70,
0x0, 0x74, 0x76, 0x0, 0xfc };
static const unsigned char uff[] = {
0x10, 0x0, 0x19,
0x21, 0x0, 0x3a, 0x41, 0x0, 0x5a, 0x66, 0x0,
0xbe, 0xc2, 0x0, 0xc7, 0xca, 0x0, 0xcf, 0xd2,
0x0, 0xd7, 0xda, 0x0, 0xdc };
static const unsigned char u103[] = {
0x00, 0x0, 0x1e,
0x30, 0x0, 0x4a };
static const unsigned char u104[] = {
0x00, 0x0, 0x25, 0x28, 0x0,
0x4d };
static const unsigned char u1d4[] = {
0x00, 0x0, 0x54, 0x56, 0x0, 0x9c, 0x9e,
0x0, 0x9f, 0xa2, 0xa5, 0x0, 0xa6, 0xa9, 0x0,
0xac, 0xae, 0x0, 0xb9, 0xbb, 0xbd, 0x0, 0xc0,
0xc2, 0x0, 0xc3, 0xc5, 0x0, 0xff };
static const unsigned char u1d5[] = {
0x00, 0x0, 0x05, 0x07, 0x0,
0x0a, 0x0d, 0x0, 0x14, 0x16, 0x0, 0x1c, 0x1e,
0x0, 0x39, 0x3b, 0x0, 0x3e, 0x40, 0x0, 0x44,
0x46, 0x4a, 0x0, 0x50, 0x52, 0x0, 0xff };
static const unsigned char u1d6[] = {
0x00, 0x0, 0xa3, 0xa8,
0x0, 0xc0, 0xc2, 0x0, 0xda, 0xdc, 0x0, 0xfa,
0xfc, 0x0, 0xff };
static const unsigned char u1d7[] = {
0x00, 0x0, 0x14, 0x16, 0x0,
0x34, 0x36, 0x0, 0x4e, 0x50, 0x0, 0x6e,
0x70, 0x0, 0x88, 0x8a, 0x0, 0xa8, 0xaa, 0x0, 0xc2,
0xc4, 0x0, 0xc9, 0xce, 0x0, 0xff };
/* u200 to u2a5 all alphabetic */
static const unsigned char u2a6[] = {
0x00, 0x0, 0xd6 };
/* u2f8 to u2f9 all alphabetic */
static const unsigned char u2fa[] = {
0x00, 0x0, 0x1d };

View File

@ -0,0 +1,282 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Generated using unicode.txt 3.2 */
static const unsigned char u0[] = {
0x20, 0x0, 0x7e, 0xa0, 0x0, 0xff };
/* u1 is all-print */
static const unsigned char u2[] = {
0x00, 0x0, 0x20, 0x22, 0x0,
0x33, 0x50, 0x0, 0xad, 0xb0, 0x0, 0xee };
static const unsigned char u3[] = {
0x00, 0x0, 0x4f, 0x60, 0x0, 0x6f, 0x74, 0x0, 0x75,
0x7a, 0x7e, 0x84, 0x0, 0x8a, 0x8c, 0x8e, 0x0,
0xa1, 0xa3, 0x0, 0xce, 0xd0, 0x0, 0xf6 };
static const unsigned char u4[] = {
0x00, 0x0, 0x86, 0x88, 0x0, 0xce, 0xd0, 0x0, 0xf5,
0xf8, 0x0, 0xf9 };
static const unsigned char u5[] = {
0x00, 0x0, 0x0f, 0x31, 0x0,
0x56, 0x59, 0x0, 0x5f, 0x61, 0x0, 0x87, 0x89,
0x0, 0x8a, 0x91, 0x0, 0xa1, 0xa3, 0x0, 0xb9,
0xbb, 0x0, 0xc4, 0xd0, 0x0, 0xea, 0xf0, 0x0,
0xf4 };
static const unsigned char u6[] = {
0x0c, 0x1b, 0x1f, 0x21, 0x0, 0x3a, 0x40,
0x0, 0x55, 0x60, 0x0, 0xed, 0xf0, 0x0, 0xfe };
static const unsigned char u7[] = {
0x00, 0x0, 0x0d, 0x0f, 0x0, 0x2c, 0x30, 0x0,
0x4a, 0x80, 0x0, 0xb1 };
static const unsigned char u9[] = {
0x01, 0x0, 0x03, 0x05,
0x0, 0x39, 0x3c, 0x0, 0x4d, 0x50, 0x0, 0x54,
0x58, 0x0, 0x70, 0x81, 0x0, 0x83, 0x85, 0x0,
0x8c, 0x8f, 0x0, 0x90, 0x93, 0x0, 0xa8, 0xaa,
0x0, 0xb0, 0xb2, 0xb6, 0x0, 0xb9, 0xbc, 0xbe,
0x0, 0xc4, 0xc7, 0x0, 0xc8, 0xcb, 0x0, 0xcd,
0xd7, 0xdc, 0x0, 0xdd, 0xdf, 0x0, 0xe3, 0xe6,
0x0, 0xfa };
static const unsigned char ua[] = {
0x02, 0x05, 0x0, 0x0a, 0x0f, 0x0,
0x10, 0x13, 0x0, 0x28, 0x2a, 0x0, 0x30, 0x32,
0x0, 0x33, 0x35, 0x0, 0x36, 0x38, 0x0, 0x39,
0x3c, 0x3e, 0x0, 0x42, 0x47, 0x0, 0x48, 0x4b,
0x0, 0x4d, 0x59, 0x0, 0x5c, 0x5e, 0x66, 0x0,
0x74, 0x81, 0x0, 0x83, 0x85, 0x0, 0x8b, 0x8d,
0x8f, 0x0, 0x91, 0x93, 0x0, 0xa8, 0xaa, 0x0,
0xb0, 0xb2, 0x0, 0xb3, 0xb5, 0x0, 0xb9, 0xbc,
0x0, 0xc5, 0xc7, 0x0, 0xc9, 0xcb, 0x0, 0xcd,
0xd0, 0xe0, 0xe6, 0x0, 0xef };
static const unsigned char ub[] = {
0x01, 0x0, 0x03,
0x05, 0x0, 0x0c, 0x0f, 0x0, 0x10, 0x13, 0x0,
0x28, 0x2a, 0x0, 0x30, 0x32, 0x0, 0x33, 0x36,
0x0, 0x39, 0x3c, 0x0, 0x43, 0x47, 0x0, 0x48,
0x4b, 0x0, 0x4d, 0x56, 0x0, 0x57, 0x5c, 0x0,
0x5d, 0x5f, 0x0, 0x61, 0x66, 0x0, 0x70, 0x82,
0x0, 0x83, 0x85, 0x0, 0x8a, 0x8e, 0x0, 0x90,
0x92, 0x0, 0x95, 0x99, 0x0, 0x9a, 0x9c, 0x9e,
0x0, 0x9f, 0xa3, 0x0, 0xa4, 0xa8, 0x0, 0xaa,
0xae, 0x0, 0xb5, 0xb7, 0x0, 0xb9, 0xbe, 0x0,
0xc2, 0xc6, 0x0, 0xc8, 0xca, 0x0, 0xcd, 0xd7,
0xe7, 0x0, 0xf2 };
static const unsigned char uc[] = {
0x01, 0x0, 0x03, 0x05, 0x0,
0x0c, 0x0e, 0x0, 0x10, 0x12, 0x0, 0x28, 0x2a,
0x0, 0x33, 0x35, 0x0, 0x39, 0x3e, 0x0, 0x44,
0x46, 0x0, 0x48, 0x4a, 0x0, 0x4d, 0x55, 0x0,
0x56, 0x60, 0x0, 0x61, 0x66, 0x0, 0x6f, 0x82,
0x0, 0x83, 0x85, 0x0, 0x8c, 0x8e, 0x0, 0x90,
0x92, 0x0, 0xa8, 0xaa, 0x0, 0xb3, 0xb5, 0x0,
0xb9, 0xbe, 0x0, 0xc4, 0xc6, 0x0, 0xc8, 0xca,
0x0, 0xcd, 0xd5, 0x0, 0xd6, 0xde, 0xe0, 0x0,
0xe1, 0xe6, 0x0, 0xef };
static const unsigned char ud[] = {
0x02, 0x0, 0x03, 0x05,
0x0, 0x0c, 0x0e, 0x0, 0x10, 0x12, 0x0, 0x28,
0x2a, 0x0, 0x39, 0x3e, 0x0, 0x43, 0x46, 0x0,
0x48, 0x4a, 0x0, 0x4d, 0x57, 0x60, 0x0, 0x61,
0x66, 0x0, 0x6f, 0x82, 0x0, 0x83, 0x85, 0x0,
0x96, 0x9a, 0x0, 0xb1, 0xb3, 0x0, 0xbb, 0xbd,
0xc0, 0x0, 0xc6, 0xca, 0xcf, 0x0, 0xd4, 0xd6,
0xd8, 0x0, 0xdf, 0xf2, 0x0, 0xf4 };
static const unsigned char ue[] = {
0x01, 0x0,
0x3a, 0x3f, 0x0, 0x5b, 0x81, 0x0, 0x82, 0x84,
0x87, 0x0, 0x88, 0x8a, 0x8d, 0x94, 0x0, 0x97,
0x99, 0x0, 0x9f, 0xa1, 0x0, 0xa3, 0xa5, 0xa7,
0xaa, 0x0, 0xab, 0xad, 0x0, 0xb9, 0xbb, 0x0,
0xbd, 0xc0, 0x0, 0xc4, 0xc6, 0xc8, 0x0, 0xcd,
0xd0, 0x0, 0xd9, 0xdc, 0x0, 0xdd };
static const unsigned char uf[] = {
0x00, 0x0,
0x47, 0x49, 0x0, 0x6a, 0x71, 0x0, 0x8b, 0x90,
0x0, 0x97, 0x99, 0x0, 0xbc, 0xbe, 0x0, 0xcc,
0xcf };
static const unsigned char u10[] = {
0x00, 0x0, 0x21, 0x23, 0x0, 0x27, 0x29,
0x0, 0x2a, 0x2c, 0x0, 0x32, 0x36, 0x0, 0x39,
0x40, 0x0, 0x59, 0xa0, 0x0, 0xc5, 0xd0, 0x0,
0xf8, 0xfb };
static const unsigned char u11[] = {
0x00, 0x0, 0x59, 0x5f, 0x0, 0xa2,
0xa8, 0x0, 0xf9 };
static const unsigned char u12[] = {
0x00, 0x0, 0x06, 0x08, 0x0,
0x46, 0x48, 0x4a, 0x0, 0x4d, 0x50, 0x0, 0x56,
0x58, 0x5a, 0x0, 0x5d, 0x60, 0x0, 0x86, 0x88,
0x8a, 0x0, 0x8d, 0x90, 0x0, 0xae, 0xb0, 0xb2,
0x0, 0xb5, 0xb8, 0x0, 0xbe, 0xc0, 0xc2, 0x0,
0xc5, 0xc8, 0x0, 0xce, 0xd0, 0x0, 0xd6, 0xd8,
0x0, 0xee, 0xf0, 0x0, 0xff };
static const unsigned char u13[] = {
0x00, 0x0, 0x0e, 0x10, 0x12, 0x0,
0x15, 0x18, 0x0, 0x1e, 0x20, 0x0, 0x46, 0x48,
0x0, 0x5a, 0x61, 0x0, 0x7c, 0xa0, 0x0, 0xf4 };
static const unsigned char u14[] = {
0x01, 0x0, 0xff };
/* u15 is all-print */
static const unsigned char u16[] = {
0x00, 0x0, 0x76, 0x80, 0x0, 0x9c, 0xa0, 0x0,
0xf0 };
static const unsigned char u17[] = {
0x00, 0x0, 0x0c, 0x0e, 0x0, 0x14, 0x20,
0x0, 0x36, 0x40, 0x0, 0x53, 0x60, 0x0, 0x6c,
0x6e, 0x0, 0x70, 0x72, 0x0, 0x73, 0x80, 0x0,
0xdc, 0xe0, 0x0, 0xe9 };
static const unsigned char u18[] = {
0x00, 0x0, 0x0e, 0x10,
0x0, 0x19, 0x20, 0x0, 0x77, 0x80, 0x0, 0xa9 };
static const unsigned char u1e[] = {
0x00, 0x0, 0x9b, 0xa0, 0x0, 0xf9 };
static const unsigned char u1f[] = {
0x00, 0x0,
0x15, 0x18, 0x0, 0x1d, 0x20, 0x0, 0x45, 0x48,
0x0, 0x4d, 0x50, 0x0, 0x57, 0x59, 0x5b, 0x5d,
0x5f, 0x0, 0x7d, 0x80, 0x0, 0xb4, 0xb6, 0x0,
0xc4, 0xc6, 0x0, 0xd3, 0xd6, 0x0, 0xdb, 0xdd,
0x0, 0xef, 0xf2, 0x0, 0xf4, 0xf6, 0x0, 0xfe };
static const unsigned char u20[] = {
0x00, 0x0, 0x27, 0x2a, 0x0, 0x52, 0x57, 0x5f,
0x0, 0x63, 0x6a, 0x0, 0x71, 0x74, 0x0, 0x8e,
0xa0, 0x0, 0xb1, 0xd0, 0x0, 0xea };
static const unsigned char u21[] = {
0x00, 0x0,
0x3a, 0x3d, 0x0, 0x4b, 0x53, 0x0, 0x83, 0x90,
0x0, 0xff };
/* u22 is all-print */
static const unsigned char u23[] = {
0x00, 0x0, 0xce };
static const unsigned char u24[] = {
0x00, 0x0, 0x26, 0x40, 0x0, 0x4a,
0x60, 0x0, 0xfe };
/* u25 is all-print */
static const unsigned char u26[] = {
0x00, 0x0, 0x13, 0x16, 0x0,
0x17, 0x19, 0x0, 0x7d, 0x80, 0x0, 0x89 };
static const unsigned char u27[] = {
0x01,
0x0, 0x04, 0x06, 0x0, 0x09, 0x0c, 0x0, 0x27,
0x29, 0x0, 0x4b, 0x4d, 0x4f, 0x0, 0x52, 0x56,
0x58, 0x0, 0x5e, 0x61, 0x0, 0x94, 0x98, 0x0,
0xaf, 0xb1, 0x0, 0xbe, 0xd0, 0x0, 0xeb, 0xf0,
0x0, 0xff };
/* u28 to u2a are all-print */
static const unsigned char u2e[] = {
0x80, 0x0, 0x99, 0x9b, 0x0, 0xf3 };
static const unsigned char u2f[] = {
0x00, 0x0, 0xd5, 0xf0, 0x0, 0xfb };
static const unsigned char u30[] = {
0x00, 0x0,
0x3f, 0x41, 0x0, 0x96, 0x99, 0x0, 0xff };
static const unsigned char u31[] = {
0x05,
0x0, 0x2c, 0x31, 0x0, 0x8e, 0x90, 0x0, 0xb7,
0xf0, 0x0, 0xff };
static const unsigned char u32[] = {
0x00, 0x0, 0x1c, 0x20, 0x0, 0x43, 0x51, 0x0,
0x7b, 0x7f, 0x0, 0xcb, 0xd0, 0x0, 0xfe };
static const unsigned char u33[] = {
0x00,
0x0, 0x76, 0x7b, 0x0, 0xdd, 0xe0, 0x0, 0xfe };
/* u34 to u4c is all-print */
static const unsigned char u4d[] = {
0x00, 0x0, 0xb5 };
/* u4e to u9e is all-print */
static const unsigned char u9f[] = {
0x00, 0x0, 0xa5 };
/* ua0 to ua3 is all-print */
static const unsigned char ua4[] = {
0x00, 0x0,
0x8c, 0x90, 0x0, 0xc6 };
/* uac to ud6 is all-print */
static const unsigned char ud7[] = {
0x00, 0x0, 0xa3 };
/* ue0 to uf9 is all-print */
static const unsigned char ufa[] = {
0x00, 0x0, 0x2d, 0x30, 0x0, 0x6a };
static const unsigned char ufb[] = {
0x00, 0x0, 0x06,
0x13, 0x0, 0x17, 0x1d, 0x0, 0x36, 0x38, 0x0,
0x3c, 0x3e, 0x40, 0x0, 0x41, 0x43, 0x0, 0x44,
0x46, 0x0, 0xb1, 0xd3, 0x0, 0xff };
/* ufc is all-print */
static const unsigned char ufd[] = {
0x00, 0x0, 0x3f, 0x50, 0x0,
0x8f, 0x92, 0x0, 0xc7, 0xf0, 0x0, 0xfc };
static const unsigned char ufe[] = {
0x00,
0x0, 0x0f, 0x20, 0x0, 0x23, 0x30, 0x0, 0x46,
0x49, 0x0, 0x52, 0x54, 0x0, 0x66, 0x68, 0x0,
0x6b, 0x70, 0x0, 0x74, 0x76, 0x0, 0xfc, 0xff };
static const unsigned char uff[] = {
0x01, 0x0, 0xbe, 0xc2, 0x0, 0xc7, 0xca, 0x0,
0xcf, 0xd2, 0x0, 0xd7, 0xda, 0x0, 0xdc, 0xe0,
0x0, 0xe6, 0xe8, 0x0, 0xee, 0xf9, 0x0, 0xfd };
static const unsigned char u103[] = {
0x00, 0x0, 0x1e, 0x20, 0x0, 0x23, 0x30, 0x0,
0x4a };
static const unsigned char u104[] = {
0x00, 0x0, 0x25, 0x28, 0x0, 0x4d };
static const unsigned char u1d0[] = {
0x00,
0x0, 0xf5 };
static const unsigned char u1d1[] = {
0x00, 0x0, 0x26, 0x2a, 0x0, 0xdd };
static const unsigned char u1d4[] = {
0x00, 0x0, 0x54, 0x56, 0x0, 0x9c, 0x9e, 0x0,
0x9f, 0xa2, 0xa5, 0x0, 0xa6, 0xa9, 0x0, 0xac,
0xae, 0x0, 0xb9, 0xbb, 0xbd, 0x0, 0xc0, 0xc2,
0x0, 0xc3, 0xc5, 0x0, 0xff };
static const unsigned char u1d5[] = {
0x00, 0x0, 0x05, 0x07, 0x0, 0x0a,
0x0d, 0x0, 0x14, 0x16, 0x0, 0x1c, 0x1e, 0x0,
0x39, 0x3b, 0x0, 0x3e, 0x40, 0x0, 0x44, 0x46,
0x4a, 0x0, 0x50, 0x52, 0x0, 0xff };
static const unsigned char u1d6[] = {
0x00, 0x0, 0xa3, 0xa8, 0x0, 0xff };
static const unsigned char u1d7[] = {
0x00, 0x0, 0xc9, 0xce, 0x0, 0xff };
/* u200 to u2a5 is all-print */
static const unsigned char u2a6[] = {
0x00, 0x0, 0xd6 };
/* u2f8 to u2f9 is all-print */
static const unsigned char u2fa[] = {
0x00,
0x0, 0x1d };
static const unsigned char ue00[] = {
0x01, 0x20, 0x0, 0x7f };
/* uf00 to uffe is all-print */
static const unsigned char ufff[] = {
0x00, 0x0,
0xfd };
/* u1000 to u10fe is all-print */
static const unsigned char u10ff[] = {
0x00, 0x0, 0xfd };

View File

@ -0,0 +1,201 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/* Generated using unicode.txt 3.2 */
static const unsigned char u0[] = {
0x21, 0x0, 0x2f, 0x3a, 0x0, 0x40, 0x5b, 0x0,
0x60, 0x7b, 0x0, 0x7e, 0xa0, 0x0, 0xa9, 0xab,
0x0, 0xb4, 0xb6, 0x0, 0xb9, 0xbb, 0x0, 0xbf,
0xd7, 0xf7 };
static const unsigned char u2[] = {
0xb9, 0x0, 0xba, 0xc2, 0x0, 0xcf,
0xd2, 0x0, 0xdf, 0xe5, 0x0, 0xed };
static const unsigned char u3[] = {
0x00, 0x0,
0x44, 0x46, 0x0, 0x4f, 0x60, 0x0, 0x6f, 0x74,
0x0, 0x75, 0x7e, 0x84, 0x0, 0x85, 0x87, 0xf6 };
static const unsigned char u4[] = {
0x82, 0x0, 0x86, 0x88, 0x0, 0x89 };
static const unsigned char u5[] = {
0x5a, 0x0,
0x5f, 0x89, 0x0, 0x8a, 0x91, 0x0, 0xa1, 0xa3,
0x0, 0xb9, 0xbb, 0x0, 0xc4, 0xf3, 0x0, 0xf4 };
static const unsigned char u6[] = {
0x0c, 0x1b, 0x1f, 0x4b, 0x0, 0x55, 0x6a, 0x0,
0x6d, 0x70, 0xd4, 0xd6, 0x0, 0xe4, 0xe7, 0x0,
0xed, 0xfd, 0x0, 0xfe };
static const unsigned char u7[] = {
0x00, 0x0, 0x0d, 0x0f,
0x11, 0x30, 0x0, 0x4a, 0xa6, 0x0, 0xb0 };
static const unsigned char u9[] = {
0x01,
0x0, 0x03, 0x3c, 0x3e, 0x0, 0x4d, 0x51, 0x0,
0x54, 0x62, 0x0, 0x65, 0x70, 0x81, 0x0, 0x83,
0xbc, 0xbe, 0x0, 0xc4, 0xc7, 0x0, 0xc8, 0xcb,
0x0, 0xcd, 0xd7, 0xe2, 0x0, 0xe3, 0xf2, 0x0,
0xfa };
static const unsigned char ua[] = {
0x02, 0x3c, 0x3e, 0x0, 0x42, 0x47, 0x0,
0x48, 0x4b, 0x0, 0x4d, 0x70, 0x0, 0x71, 0x81,
0x0, 0x83, 0xbc, 0xbe, 0x0, 0xc5, 0xc7, 0x0,
0xc9, 0xcb, 0x0, 0xcd };
static const unsigned char ub[] = {
0x01, 0x0, 0x03, 0x3c,
0x3e, 0x0, 0x43, 0x47, 0x0, 0x48, 0x4b, 0x0,
0x4d, 0x56, 0x0, 0x57, 0x70, 0x82, 0xbe, 0x0,
0xc2, 0xc6, 0x0, 0xc8, 0xca, 0x0, 0xcd, 0xd7,
0xf0, 0x0, 0xf2 };
static const unsigned char uc[] = {
0x01, 0x0, 0x03, 0x3e, 0x0,
0x44, 0x46, 0x0, 0x48, 0x4a, 0x0, 0x4d, 0x55,
0x0, 0x56, 0x82, 0x0, 0x83, 0xbe, 0x0, 0xc4,
0xc6, 0x0, 0xc8, 0xca, 0x0, 0xcd, 0xd5, 0x0,
0xd6 };
static const unsigned char ud[] = {
0x02, 0x0, 0x03,
0x3e, 0x0, 0x43, 0x46,
0x0, 0x48, 0x4a, 0x0, 0x4d, 0x57, 0x82, 0x0,
0x83, 0xca, 0xcf, 0x0, 0xd4, 0xd6, 0xd8, 0x0,
0xdf, 0xf2, 0x0, 0xf4 };
static const unsigned char ue[] = {
0x2f, 0x3f, 0x46, 0x4f,
0x5a, 0x0, 0x5b, 0xb1, 0xb4, 0x0, 0xb9, 0xbb,
0x0, 0xbc, 0xc8, 0x0, 0xcd };
static const unsigned char uf[] = {
0x01, 0x0, 0x1f,
0x2a, 0x0, 0x3f, 0x71, 0x0, 0x87, 0x90, 0x0,
0x97, 0x99, 0x0, 0xbc, 0xbe, 0x0, 0xcc, 0xcf };
static const unsigned char u10[] = {
0x2c, 0x0, 0x32, 0x36, 0x0, 0x39, 0x4a, 0x0,
0x4f, 0x56, 0x0, 0x59, 0xfb };
static const unsigned char u13[] = {
0x61, 0x0, 0x68,
0x72, 0x0, 0x7c };
static const unsigned char u16[] = {
0x6d, 0x0, 0x6e, 0x9b, 0x0,
0x9c, 0xeb, 0x0, 0xed };
static const unsigned char u17[] = {
0x12, 0x0, 0x14, 0x32,
0x0, 0x36, 0x52, 0x0, 0x53, 0x72, 0x0, 0x73,
0xb4, 0x0, 0xd6, 0xd8, 0x0, 0xdb };
static const unsigned char u18[] = {
0x00, 0x0,
0x0e, 0xa9 };
static const unsigned char u1f[] = {
0xbd, 0xbf, 0x0, 0xc1,
0xcd, 0x0, 0xcf, 0xdd, 0x0, 0xdf, 0xed, 0x0, 0xef, 0xfd,
0x0, 0xfe };
static const unsigned char u20[] = {
0x07, 0x0c, 0x0, 0x27, 0x2a, 0x0,
0x52, 0x57, 0x60, 0x0, 0x63, 0x6a, 0x0, 0x70,
0x74, 0x0, 0x7e, 0x80, 0x0, 0x8e, 0xa0, 0x0,
0xb1, 0xd0, 0x0, 0xea };
static const unsigned char u21[] = {
0x00, 0x0, 0x01, 0x03,
0x0, 0x06, 0x08, 0x0, 0x09, 0x14, 0x16, 0x0,
0x18, 0x1e, 0x0, 0x23, 0x25, 0x27, 0x2e, 0x32,
0x3a, 0x40, 0x0, 0x44, 0x4a, 0x0, 0x4b, 0x53,
0x0, 0x5f, 0x90, 0x0, 0xff };
/* u22 is all-punctuation */
static const unsigned char u23[] = {
0x00, 0x0, 0xce };
static const unsigned char u24[] = {
0x00, 0x0, 0x26,
0x40, 0x0, 0x4a, 0x60, 0x0, 0x9b, 0xea, 0x0,
0xfe };
/* u25 is all-punctuation */
static const unsigned char u26[] = {
0x00, 0x0, 0x13,
0x16, 0x0, 0x17, 0x19,
0x0, 0x7d, 0x80, 0x0, 0x89 };
static const unsigned char u27[] = {
0x01, 0x0, 0x04,
0x06, 0x0, 0x09, 0x0c, 0x0, 0x27, 0x29, 0x0,
0x4b, 0x4d, 0x4f, 0x0, 0x52, 0x56, 0x58, 0x0,
0x5e, 0x61, 0x0, 0x94, 0x98, 0x0, 0xaf, 0xb1,
0x0, 0xbe, 0xd0, 0x0, 0xeb, 0xf0, 0x0, 0xff };
/* u28 to u2a is all-punctuation */
static const unsigned char u2e[] = {
0x80, 0x0, 0x99,
0x9b, 0x0, 0xf3 };
static const unsigned char u2f[] = {
0x00, 0x0,
0xd5, 0xf0, 0x0, 0xfb };
static const unsigned char u30[] = {
0x01, 0x0, 0x04, 0x08,
0x0, 0x20, 0x2a, 0x0, 0x30, 0x36, 0x0, 0x37,
0x3d, 0x0, 0x3f, 0x99, 0x0, 0x9c, 0xa0, 0xfb };
static const unsigned char u31[] = {
0x90, 0x0, 0x9f };
static const unsigned char u32[] = {
0x00, 0x0, 0x1c, 0x20, 0x0,
0x43, 0x51, 0x0, 0x7b, 0x7f, 0x0, 0xcb, 0xd0,
0x0, 0xfe };
static const unsigned char u33[] = {
0x00, 0x0, 0x76, 0x7b, 0x0, 0xdd,
0xe0, 0x0, 0xfe };
static const unsigned char ua4[] = {
0x90, 0x0, 0xc6 };
/* ue0 to uf8 are all-punctuation */
static const unsigned char ufb[] = {
0x1e, 0x29 };
static const unsigned char ufd[] = {
0x3e, 0x0, 0x3f, 0xfc };
static const unsigned char ufe[] = {
0x00,
0x0, 0x0f, 0x20, 0x0, 0x23, 0x30, 0x0, 0x46,
0x49, 0x0, 0x52, 0x54, 0x0, 0x66, 0x68, 0x0,
0x6b, 0xff };
static const unsigned char uff[] = {
0x01, 0x0, 0x0f, 0x1a, 0x0, 0x20,
0x3b, 0x0, 0x40, 0x5b, 0x0, 0x65, 0xe0, 0x0,
0xe6, 0xe8, 0x0, 0xee, 0xf9, 0x0, 0xfd };
static const unsigned char u103[] = {
0x20,
0x0, 0x23 };
static const unsigned char u1d0[] = {
0x00, 0x0, 0xf5 };
static const unsigned char u1d1[] = {
0x00, 0x0, 0x26,
0x2a, 0x0, 0xdd };
static const unsigned char u1d6[] = {
0xc1, 0xdb, 0xfb };
static const unsigned char u1d7[] = {
0x15, 0x35,
0x4f, 0x6f, 0x89, 0xa9, 0xc3 };
static const unsigned char ue00[] = {
0x01, 0x20, 0x0,
0x7f };
/* uf00 to uffe are all punctuation */
static const unsigned char ufff[] = {
0x00, 0x0, 0xfd };
/* u1000 to u10fe are all punctuation */
static const unsigned char u10ff[] = {
0x00, 0x0, 0xfd };

View File

@ -0,0 +1,94 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<wctrans>>---get wide-character translation type
INDEX
wctrans
ANSI_SYNOPSIS
#include <wctype.h>
wctrans_t wctrans(const char *<[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
wctrans_t wctrans(<[c]>)
const char * <[c]>;
DESCRIPTION
<<wctrans>> is a function which takes a string <[c]> and gives back
the appropriate wctrans_t type value associated with the string,
if one exists. The following values are guaranteed to be recognized:
"tolower" and "toupper".
RETURNS
<<wctrans>> returns 0 and sets <<errno>> to <<EINVAL>> if the
given name is invalid. Otherwise, it returns a valid non-zero wctrans_t
value.
PORTABILITY
<<wctrans>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <string.h>
#include <reent.h>
#include <wctype.h>
#include <errno.h>
#include "local.h"
wctrans_t
_DEFUN (_wctrans_r, (r, c),
struct _reent *r _AND
const char *c)
{
if (!strcmp (c, "tolower"))
return WCT_TOLOWER;
else if (!strcmp (c, "toupper"))
return WCT_TOUPPER;
else
{
r->_errno = EINVAL;
return 0;
}
}
#ifndef _REENT_ONLY
wctrans_t
_DEFUN (wctrans, (c),
const char *c)
{
return _wctrans_r (_REENT, c);
}
#endif /* !_REENT_ONLY */

138
newlib/libc/ctype/wctype.c Normal file
View File

@ -0,0 +1,138 @@
/* Copyright (c) 2002 Red Hat Incorporated.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
The name of Red Hat Incorporated may not be used to endorse
or promote products derived from this software without specific
prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL RED HAT INCORPORATED BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
/*
FUNCTION
<<wctype>>---get wide-character classification type
INDEX
wctype
ANSI_SYNOPSIS
#include <wctype.h>
wctype_t wctype(const char *<[c]>);
TRAD_SYNOPSIS
#include <wctype.h>
wctype_t wctype(<[c]>)
const char * <[c]>;
DESCRIPTION
<<wctype>> is a function which takes a string <[c]> and gives back
the appropriate wctype_t type value associated with the string,
if one exists. The following values are guaranteed to be recognized:
"alnum", "alpha", "blank", "cntrl", "digit", "graph", "lower", "print",
"punct", "space", "upper", and "xdigit".
RETURNS
<<wctype>> returns 0 and sets <<errno>> to <<EINVAL>> if the
given name is invalid. Otherwise, it returns a valid non-zero wctype_t
value.
PORTABILITY
<<wctype>> is C99.
No supporting OS subroutines are required.
*/
#include <_ansi.h>
#include <string.h>
#include <reent.h>
#include <wctype.h>
#include <errno.h>
#include "local.h"
wctype_t
_DEFUN (_wctype_r, (r, c),
struct _reent *r _AND
const char *c)
{
switch (*c)
{
case 'a':
if (!strcmp (c, "alnum"))
return WC_ALNUM;
else if (!strcmp (c, "alpha"))
return WC_ALPHA;
break;
case 'b':
if (!strcmp (c, "blank"))
return WC_BLANK;
break;
case 'c':
if (!strcmp (c, "cntrl"))
return WC_CNTRL;
break;
case 'd':
if (!strcmp (c, "digit"))
return WC_DIGIT;
break;
case 'g':
if (!strcmp (c, "graph"))
return WC_GRAPH;
break;
case 'l':
if (!strcmp (c, "lower"))
return WC_LOWER;
break;
case 'p':
if (!strcmp (c, "print"))
return WC_PRINT;
else if (!strcmp (c, "punct"))
return WC_PUNCT;
break;
case 's':
if (!strcmp (c, "space"))
return WC_SPACE;
break;
case 'u':
if (!strcmp (c, "upper"))
return WC_UPPER;
break;
case 'x':
if (!strcmp (c, "xdigit"))
return WC_XDIGIT;
break;
default:
}
/* otherwise invalid */
r->_errno = EINVAL;
return 0;
}
#ifndef _REENT_ONLY
wctype_t
_DEFUN (wctype, (c),
const char *c)
{
return _wctype_r (_REENT, c);
}
#endif /* !_REENT_ONLY */

View File

@ -112,6 +112,7 @@ static _CONST struct lconv lconv =
char * _EXFUN(__locale_charset,(_VOID));
static char *charset = "ISO-8859-1";
char __lc_ctype[12] = "C";
char *
_DEFUN(_setlocale_r, (p, category, locale),
@ -129,7 +130,6 @@ _DEFUN(_setlocale_r, (p, category, locale),
}
return "C";
#else
static char lc_ctype[12] = "C";
static char last_lc_ctype[12] = "C";
static char lc_messages[12] = "C";
static char last_lc_messages[12] = "C";
@ -143,8 +143,8 @@ _DEFUN(_setlocale_r, (p, category, locale),
return 0;
if (category == LC_ALL)
{
strcpy (last_lc_ctype, lc_ctype);
strcpy (lc_ctype, "C");
strcpy (last_lc_ctype, __lc_ctype);
strcpy (__lc_ctype, "C");
strcpy (last_lc_messages, lc_messages);
strcpy (lc_messages, "C");
__mb_cur_max = 1;
@ -189,8 +189,8 @@ _DEFUN(_setlocale_r, (p, category, locale),
if (category == LC_CTYPE)
{
strcpy (last_lc_ctype, lc_ctype);
strcpy (lc_ctype, locale_name);
strcpy (last_lc_ctype, __lc_ctype);
strcpy (__lc_ctype, locale_name);
__mb_cur_max = 1;
if (locale[1] == '-')
@ -257,7 +257,7 @@ _DEFUN(_setlocale_r, (p, category, locale),
else
{
if (category == LC_CTYPE)
return lc_ctype;
return __lc_ctype;
else if (category == LC_MESSAGES)
return lc_messages;
}

View File

@ -44,6 +44,8 @@ static JIS_ACTION JIS_action_table[JIS_S_NUM][JIS_C_NUM] = {
/* we override the mbstate_t __count field for more complex encodings and use it store a state value */
#define __state __count
extern char __lc_ctype[12];
int
_DEFUN (_mbtowc_r, (r, pwc, s, n, state),
struct _reent *r _AND
@ -62,10 +64,10 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return -2;
#ifdef MB_CAPABLE
if (r->_current_locale == NULL ||
(strlen (r->_current_locale) <= 1))
if (__lc_ctype == NULL ||
(strlen (__lc_ctype) <= 1))
{ /* fall-through */ }
else if (!strcmp (r->_current_locale, "C-UTF-8"))
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
int ch;
int i = 0;
@ -307,7 +309,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
else
return -1;
}
else if (!strcmp (r->_current_locale, "C-SJIS"))
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
int ch;
int i = 0;
@ -337,7 +339,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return -1;
}
}
else if (!strcmp (r->_current_locale, "C-EUCJP"))
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
int ch;
int i = 0;
@ -367,7 +369,7 @@ _DEFUN (_mbtowc_r, (r, pwc, s, n, state),
return -1;
}
}
else if (!strcmp (r->_current_locale, "C-JIS"))
else if (!strcmp (__lc_ctype, "C-JIS"))
{
JIS_STATE curr_state;
JIS_ACTION action;

View File

@ -7,6 +7,8 @@
/* for some conversions, we use the __count field as a place to store a state value */
#define __state __count
extern char __lc_ctype[12];
int
_DEFUN (_wctomb_r, (r, s, wchar, state),
struct _reent *r _AND
@ -14,9 +16,9 @@ _DEFUN (_wctomb_r, (r, s, wchar, state),
wchar_t wchar _AND
mbstate_t *state)
{
if (strlen (r->_current_locale) <= 1)
if (strlen (__lc_ctype) <= 1)
{ /* fall-through */ }
else if (!strcmp (r->_current_locale, "C-UTF-8"))
else if (!strcmp (__lc_ctype, "C-UTF-8"))
{
if (s == NULL)
return 0; /* UTF-8 encoding is not state-dependent */
@ -73,7 +75,7 @@ _DEFUN (_wctomb_r, (r, s, wchar, state),
else
return -1;
}
else if (!strcmp (r->_current_locale, "C-SJIS"))
else if (!strcmp (__lc_ctype, "C-SJIS"))
{
unsigned char char2 = (unsigned char)wchar;
unsigned char char1 = (unsigned char)(wchar >> 8);
@ -94,7 +96,7 @@ _DEFUN (_wctomb_r, (r, s, wchar, state),
return -1;
}
}
else if (!strcmp (r->_current_locale, "C-EUCJP"))
else if (!strcmp (__lc_ctype, "C-EUCJP"))
{
unsigned char char2 = (unsigned char)wchar;
unsigned char char1 = (unsigned char)(wchar >> 8);
@ -115,7 +117,7 @@ _DEFUN (_wctomb_r, (r, s, wchar, state),
return -1;
}
}
else if (!strcmp (r->_current_locale, "C-JIS"))
else if (!strcmp (__lc_ctype, "C-JIS"))
{
int cnt = 0;
unsigned char char2 = (unsigned char)wchar;