support multibytes in isw*/tow*.
This commit is contained in:
parent
408f4697a6
commit
b7a136db6b
|
@ -1,5 +1,5 @@
|
|||
# from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91
|
||||
# $NetBSD: Makefile.inc,v 1.22 2000/12/21 11:29:47 itojun Exp $
|
||||
# $NetBSD: Makefile.inc,v 1.23 2000/12/21 12:13:28 itojun Exp $
|
||||
|
||||
# locale sources
|
||||
.PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
|
||||
|
@ -13,7 +13,8 @@ SRCS+= _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
|
|||
MAN+= nl_langinfo.3 setlocale.3
|
||||
|
||||
# citrus multibyte locale support
|
||||
SRCS+= multibyte.c rune.c runeglue.c runenone.c runetable.c setrunelocale.c
|
||||
SRCS+= ___runetype_mb.c ___tolower_mb.c ___toupper_mb.c \
|
||||
multibyte.c rune.c runeglue.c runenone.c runetable.c setrunelocale.c
|
||||
#SRCS+= big5.c euc.c euctw.c iso2022.c mskanji.c utf2.c utf8.c
|
||||
|
||||
MLINKS+=setlocale.3 localeconv.3
|
||||
|
|
|
@ -0,0 +1,64 @@
|
|||
/* $NetBSD: ___runetype_mb.c,v 1.1 2000/12/21 12:13:28 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Paul Borman at Krystal Technologies.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include <wctype.h>
|
||||
#include "rune.h"
|
||||
|
||||
unsigned long
|
||||
___runetype_mb(c)
|
||||
wint_t c;
|
||||
{
|
||||
int x;
|
||||
_RuneRange *rr = &_CurrentRuneLocale->__runetype_ext;
|
||||
_RuneEntry *re = rr->__rune_ranges;
|
||||
|
||||
if (c < 0 || c == EOF)
|
||||
return(0L);
|
||||
|
||||
for (x = 0; x < rr->__nranges; ++x, ++re) {
|
||||
if (c < re->__min)
|
||||
return(0L);
|
||||
if (c <= re->__max) {
|
||||
if (re->__rune_types)
|
||||
return(re->__rune_types[c - re->__min]);
|
||||
else
|
||||
return(re->__map);
|
||||
}
|
||||
}
|
||||
return(0L);
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* $NetBSD: ___tolower_mb.c,v 1.1 2000/12/21 12:13:28 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Paul Borman at Krystal Technologies.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include <wctype.h>
|
||||
#include "rune.h"
|
||||
|
||||
wint_t
|
||||
___tolower_mb(c)
|
||||
wint_t c;
|
||||
{
|
||||
int x;
|
||||
_RuneRange *rr = &_CurrentRuneLocale->__maplower_ext;
|
||||
_RuneEntry *re = rr->__rune_ranges;
|
||||
|
||||
if (c < 0 || c == EOF)
|
||||
return(c);
|
||||
|
||||
for (x = 0; x < rr->__nranges; ++x, ++re) {
|
||||
if (c < re->__min)
|
||||
return(c);
|
||||
if (c <= re->__max)
|
||||
return(re->__map + c - re->__min);
|
||||
}
|
||||
return(c);
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
/* $NetBSD: ___toupper_mb.c,v 1.1 2000/12/21 12:13:28 itojun Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1993
|
||||
* The Regents of the University of California. All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to Berkeley by
|
||||
* Paul Borman at Krystal Technologies.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. 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.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the University of
|
||||
* California, Berkeley and its contributors.
|
||||
* 4. Neither the name of the University nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 THE REGENTS OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
#include <wctype.h>
|
||||
#include "rune.h"
|
||||
|
||||
wint_t
|
||||
___toupper_mb(c)
|
||||
wint_t c;
|
||||
{
|
||||
int x;
|
||||
_RuneRange *rr = &_CurrentRuneLocale->__mapupper_ext;
|
||||
_RuneEntry *re = rr->__rune_ranges;
|
||||
|
||||
if (c < 0 || c == EOF)
|
||||
return(c);
|
||||
|
||||
for (x = 0; x < rr->__nranges; ++x, ++re) {
|
||||
if (c < re->__min)
|
||||
return(c);
|
||||
if (c <= re->__max)
|
||||
return(re->__map + c - re->__min);
|
||||
}
|
||||
return(c);
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: iswctype.c,v 1.4 2000/12/21 08:30:53 itojun Exp $ */
|
||||
/* $NetBSD: iswctype.c,v 1.5 2000/12/21 12:13:28 itojun Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1989 The Regents of the University of California.
|
||||
|
@ -40,19 +40,55 @@
|
|||
|
||||
#include <sys/cdefs.h>
|
||||
#if defined(LIBC_SCCS) && !defined(lint)
|
||||
__RCSID("$NetBSD: iswctype.c,v 1.4 2000/12/21 08:30:53 itojun Exp $");
|
||||
__RCSID("$NetBSD: iswctype.c,v 1.5 2000/12/21 12:13:28 itojun Exp $");
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
#include <wchar.h>
|
||||
#include <wctype.h>
|
||||
#include <ctype.h>
|
||||
#include "runetype.h"
|
||||
|
||||
#ifdef lint
|
||||
#define __inline
|
||||
#endif
|
||||
|
||||
static __inline int __maskrune_w __P((wint_t, unsigned long));
|
||||
static __inline wint_t __toupper_w __P((wint_t));
|
||||
static __inline wint_t __tolower_w __P((wint_t));
|
||||
|
||||
#define __isctype_w(c,f) (!!__maskrune_w((c),(f)))
|
||||
|
||||
static __inline int
|
||||
__maskrune_w(c, f)
|
||||
wint_t c;
|
||||
unsigned long f;
|
||||
{
|
||||
return ((c < 0 || c >= _CACHED_RUNES) ? ___runetype_mb(c) :
|
||||
_CurrentRuneLocale->__runetype[c]) & f;
|
||||
}
|
||||
|
||||
static __inline wint_t
|
||||
__toupper_w(c)
|
||||
wint_t c;
|
||||
{
|
||||
return (c < 0 || c >= _CACHED_RUNES) ? ___toupper_mb(c) :
|
||||
_CurrentRuneLocale->__mapupper[c];
|
||||
}
|
||||
|
||||
static __inline wint_t
|
||||
__tolower_w(c)
|
||||
wint_t c;
|
||||
{
|
||||
return (c < 0 || c >= _CACHED_RUNES) ? ___tolower_mb(c) :
|
||||
_CurrentRuneLocale->__maplower[c];
|
||||
}
|
||||
|
||||
#undef iswalnum
|
||||
int
|
||||
iswalnum(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isalnum((int)c);
|
||||
return (__isctype_w((c), _CTYPE_A)|__isctype_w((c), _CTYPE_D));
|
||||
}
|
||||
|
||||
#undef iswalpha
|
||||
|
@ -60,7 +96,7 @@ int
|
|||
iswalpha(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isalpha((int)c);
|
||||
return (__isctype_w((c), _CTYPE_A));
|
||||
}
|
||||
|
||||
#undef iswblank
|
||||
|
@ -68,7 +104,7 @@ int
|
|||
iswblank(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isblank((int)c);
|
||||
return (__isctype_w((c), _CTYPE_B));
|
||||
}
|
||||
|
||||
#undef iswcntrl
|
||||
|
@ -76,7 +112,7 @@ int
|
|||
iswcntrl(c)
|
||||
wint_t c;
|
||||
{
|
||||
return iscntrl((int)c);
|
||||
return (__isctype_w((c), _CTYPE_C));
|
||||
}
|
||||
|
||||
#undef iswdigit
|
||||
|
@ -84,7 +120,7 @@ int
|
|||
iswdigit(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isdigit((int)c);
|
||||
return (__isctype_w((c), _CTYPE_D));
|
||||
}
|
||||
|
||||
#undef iswgraph
|
||||
|
@ -92,7 +128,7 @@ int
|
|||
iswgraph(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isgraph((int)c);
|
||||
return (__isctype_w((c), _CTYPE_G));
|
||||
}
|
||||
|
||||
#undef iswlower
|
||||
|
@ -100,7 +136,7 @@ int
|
|||
iswlower(c)
|
||||
wint_t c;
|
||||
{
|
||||
return islower((int)c);
|
||||
return (__isctype_w((c), _CTYPE_L));
|
||||
}
|
||||
|
||||
#undef iswprint
|
||||
|
@ -108,7 +144,7 @@ int
|
|||
iswprint(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isprint((int)c);
|
||||
return (__isctype_w((c), _CTYPE_R));
|
||||
}
|
||||
|
||||
#undef iswpunct
|
||||
|
@ -116,7 +152,7 @@ int
|
|||
iswpunct(c)
|
||||
wint_t c;
|
||||
{
|
||||
return ispunct((int)c);
|
||||
return (__isctype_w((c), _CTYPE_P));
|
||||
}
|
||||
|
||||
#undef iswspace
|
||||
|
@ -124,7 +160,7 @@ int
|
|||
iswspace(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isspace((int)c);
|
||||
return (__isctype_w((c), _CTYPE_S));
|
||||
}
|
||||
|
||||
#undef iswupper
|
||||
|
@ -132,7 +168,7 @@ int
|
|||
iswupper(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isupper((int)c);
|
||||
return (__isctype_w((c), _CTYPE_U));
|
||||
}
|
||||
|
||||
#undef iswxdigit
|
||||
|
@ -140,7 +176,7 @@ int
|
|||
iswxdigit(c)
|
||||
wint_t c;
|
||||
{
|
||||
return isxdigit((int)c);
|
||||
return (__isctype_w((c), _CTYPE_X));
|
||||
}
|
||||
|
||||
#undef towupper
|
||||
|
@ -148,7 +184,7 @@ wint_t
|
|||
towupper(c)
|
||||
wint_t c;
|
||||
{
|
||||
return toupper((int)c);
|
||||
return (__toupper_w(c));
|
||||
}
|
||||
|
||||
#undef towlower
|
||||
|
@ -156,14 +192,14 @@ wint_t
|
|||
towlower(c)
|
||||
wint_t c;
|
||||
{
|
||||
return tolower((int)c);
|
||||
return (__tolower_w(c));
|
||||
}
|
||||
|
||||
#undef wcwidth
|
||||
/*ARGSUSED*/
|
||||
int
|
||||
wcwidth(c)
|
||||
wint_t c;
|
||||
{
|
||||
return 1;
|
||||
return ((unsigned)__maskrune_w((c), _CTYPE_SWM) >> _CTYPE_SWS);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue