Remove code for CITRUS!=yes.

This commit is contained in:
joerg 2012-01-20 16:31:29 +00:00
parent 6df52306d4
commit 0f5f511fae
24 changed files with 21 additions and 1617 deletions

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.148 2011/08/17 09:53:53 christos Exp $
# $NetBSD: Makefile,v 1.149 2012/01/20 16:31:29 joerg Exp $
# @(#)Makefile 8.2 (Berkeley) 2/3/94
#
# All library objects contain sccsid strings by default; they may be
@ -57,9 +57,7 @@ COMPATDIR=${.CURDIR}/compat
.include "${.CURDIR}/atomic/Makefile.inc"
.include "${.CURDIR}/cdb/Makefile.inc"
.include "${.CURDIR}/db/Makefile.inc"
.if (${CITRUS} == "yes")
.include "${.CURDIR}/citrus/Makefile.inc"
.endif
.include "${.CURDIR}/compat-43/Makefile.inc"
.include "${.CURDIR}/dlfcn/Makefile.inc"
.include "${.CURDIR}/gdtoa/Makefile.inc"
@ -138,9 +136,7 @@ FILESDIR= /var/db
# workaround for I18N stuffs: build singlebyte setlocale() for libc.a,
# multibyte for libc.so. the quirk should be removed when we support
# dlopen() from within statically linked binaries.
.if (${CITRUS} == "yes")
CSHLIBFLAGS+= -D_I18N_DYNAMIC
.endif
.include <bsd.lib.mk>

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.7 2011/11/10 00:36:54 joerg Exp $
# $NetBSD: Makefile.inc,v 1.8 2012/01/20 16:31:29 joerg Exp $
# @(#)Makefile 8.2 (Berkeley) 2/3/94
#
# All library objects contain sccsid strings by default; they may be
@ -21,8 +21,6 @@ USE_FORT?= yes
USE_SHLIBDIR= yes
CITRUS?= yes
.include <bsd.own.mk>
WARNS=4

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.4 2009/01/11 02:46:28 christos Exp $
# $NetBSD: Makefile.inc,v 1.5 2012/01/20 16:31:29 joerg Exp $
.PATH: ${ARCHDIR}/iconv ${.CURDIR}/iconv
@ -6,8 +6,4 @@ SRCS+= iconv.c
MAN+= iconv.3
MLINKS+=iconv.3 iconv_open.3 iconv.3 iconv_close.3
.if ${CITRUS} == "yes"
CPPFLAGS.iconv.c+= -DHAVE_CITRUS -I${LIBCDIR}/citrus
.else
CPPFLAGS.iconv.c+= -UHAVE_CITRUS
.endif
CPPFLAGS.iconv.c+= -I${LIBCDIR}/citrus

View File

@ -1,4 +1,4 @@
/* $NetBSD: iconv.c,v 1.12 2009/08/05 15:17:02 joerg Exp $ */
/* $NetBSD: iconv.c,v 1.13 2012/01/20 16:31:29 joerg Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: iconv.c,v 1.12 2009/08/05 15:17:02 joerg Exp $");
__RCSID("$NetBSD: iconv.c,v 1.13 2012/01/20 16:31:29 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@ -45,7 +45,6 @@ __weak_alias(iconv_open, _iconv_open)
__weak_alias(iconv_close, _iconv_close)
#endif
#ifdef HAVE_CITRUS
#include <sys/types.h>
#include "citrus_types.h"
#include "citrus_module.h"
@ -150,39 +149,3 @@ __iconv_free_list(char **list, size_t sz)
{
_citrus_esdb_free_list(list, sz);
}
#else
iconv_t
/*ARGSUSED*/
iconv_open(const char *in, const char *out)
{
errno = EINVAL;
return ((iconv_t)-1);
}
int
/*ARGSUSED*/
iconv_close(iconv_t handle)
{
errno = EBADF;
return (-1);
}
size_t
/*ARGSUSED*/
iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout)
{
errno = EBADF;
return ((size_t)-1);
}
int
/*ARGSUSED*/
__iconv_get_list(char ***rlist, size_t *rsz)
{
errno = EINVAL;
return -1;
}
void
/*ARGSUSED*/
__iconv_free_list(char **list, size_t sz)
{
}
#endif

View File

@ -1,5 +1,5 @@
# from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91
# $NetBSD: Makefile.inc,v 1.59 2011/08/14 09:07:37 christos Exp $
# $NetBSD: Makefile.inc,v 1.60 2012/01/20 16:31:29 joerg Exp $
# locale sources
.PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
@ -12,7 +12,6 @@ SRCS+= _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
wcstol.c wcstoll.c wcstoimax.c wcstoul.c wcstoull.c wcstoumax.c \
wcstod.c wcstof.c wcstold.c wcscoll.c wcsxfrm.c wcsftime.c
.if (${CITRUS} == "yes")
# citrus multibyte locale support
# we have quirk for libc.a - see the last part of lib/libc/Makefile
CPPFLAGS+= -DWITH_RUNE -I${.CURDIR}
@ -22,14 +21,6 @@ CPPFLAGS.rune.c+= -I${LIBCDIR}/citrus
CPPFLAGS.runetable.c+= -I${LIBCDIR}/citrus
CPPFLAGS.multibyte_c90.c+= -I${LIBCDIR}/citrus
CPPFLAGS.multibyte_amd1.c+= -I${LIBCDIR}/citrus
.else
# singlebyte locale - dummy
CPPFLAGS+= -UWITH_RUNE
SRCS+= aliasname.c bsdctype.c localeio.c \
multibyte_sb.c iswctype_sb.c \
localeio_lc_ctype.c localeio_lc_monetary.c \
localeio_lc_numeric.c localeio_lc_time.c localeio_lc_messages.c
.endif
MAN+= setlocale.3 nl_langinfo.3

View File

@ -1,129 +0,0 @@
/* $NetBSD: aliasname.c,v 1.4 2009/01/11 02:46:28 christos Exp $ */
/*-
* Copyright (c)2002 YAMAMOTO Takashi,
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: aliasname.c,v 1.4 2009/01/11 02:46:28 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include "aliasname_local.h"
__inline int __is_ws(char);
__inline int __is_ws(char ch)
{
return (ch == ' ' || ch == '\t');
}
const char *
__unaliasname(const char *dbname, const char *alias, void *buf, size_t bufsize)
{
FILE *fp = NULL;
const char *result = NULL;
size_t resultlen;
size_t aliaslen;
const char *p;
size_t len;
_DIAGASSERT(dbname != NULL);
_DIAGASSERT(alias != NULL);
_DIAGASSERT(buf != NULL);
fp = fopen(dbname, "r");
if (fp == NULL)
goto quit;
aliaslen = strlen(alias);
while (/*CONSTCOND*/ 1) {
p = fgetln(fp, &len);
if (p == NULL)
goto quit; /* eof or error */
_DIAGASSERT(len != 0);
/* ignore terminating NL */
if (p[len - 1] == '\n')
len--;
/* ignore null line and comment */
if (len == 0 || p[0] == '#')
continue;
if (aliaslen > len)
continue;
if (memcmp(alias, p, aliaslen))
continue;
p += aliaslen;
len -= aliaslen;
if (len == 0 || !__is_ws(*p))
continue;
/* entry was found here */
break;
/* NOTREACHED */
}
/* skip white spaces */
do {
p++;
len--;
} while (len != 0 && __is_ws(*p));
if (len == 0)
goto quit;
/* count length of result */
resultlen = 0;
while (resultlen < len && !__is_ws(*p))
resultlen++;
/* check if space is enough */
if (bufsize < resultlen + 1)
goto quit;
memcpy(buf, p, resultlen);
((char *)buf)[resultlen] = 0;
result = buf;
quit:
if (fp)
fclose(fp);
return result;
}

View File

@ -1,146 +0,0 @@
/* $NetBSD: bsdctype.c,v 1.10 2011/03/25 00:45:24 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: bsdctype.c,v 1.10 2011/03/25 00:45:24 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/endian.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "bsdctype_local.h"
#include "runetype_misc.h"
const _BSDCTypeLocale _DefaultBSDCTypeLocale = {
_C_ctype_,
_C_tolower_,
_C_toupper_
};
const _BSDCTypeLocale *_CurrentBSDCTypeLocale = &_DefaultBSDCTypeLocale;
typedef struct {
_BSDCTypeLocale bl;
unsigned char blp_ctype_tab [_CTYPE_NUM_CHARS + 1];
short blp_tolower_tab[_CTYPE_NUM_CHARS + 1];
short blp_toupper_tab[_CTYPE_NUM_CHARS + 1];
} _BSDCTypeLocalePriv;
static __inline void
_bsdctype_init_priv(_BSDCTypeLocalePriv *blp)
{
#if _CTYPE_CACHE_SIZE != _CTYPE_NUM_CHARS
int i;
for (i = _CTYPE_CACHE_SIZE; i < _CTYPE_NUM_CHARS; ++i) {
blp->blp_ctype_tab [i + 1] = 0;
blp->blp_tolower_tab[i + 1] = i;
blp->blp_toupper_tab[i + 1] = i;
}
#endif
blp->blp_ctype_tab [0] = 0;
blp->blp_tolower_tab[0] = EOF;
blp->blp_toupper_tab[0] = EOF;
blp->bl.bl_ctype_tab = &blp->blp_ctype_tab [0];
blp->bl.bl_tolower_tab = &blp->blp_tolower_tab[0];
blp->bl.bl_toupper_tab = &blp->blp_toupper_tab[0];
}
static __inline int
_bsdctype_read_runetype(const char * __restrict var, size_t lenvar,
_BSDCTypeLocalePriv * __restrict blp)
{
const _FileRuneLocale *frl;
int i;
_DIAGASSERT(blp != NULL);
if (lenvar < sizeof(*frl))
return EFTYPE;
lenvar -= sizeof(*frl);
frl = (const _FileRuneLocale *)(const void *)var;
if (memcmp(_RUNECT10_MAGIC, &frl->frl_magic[0], sizeof(frl->frl_magic)))
return EFTYPE;
if (frl->frl_encoding[0] != 'N' || frl->frl_encoding[1] != 'O' ||
frl->frl_encoding[2] != 'N' || frl->frl_encoding[3] != 'E' ||
frl->frl_encoding[4] != '\0') /* XXX */
return EFTYPE;
if (be32toh(frl->frl_runetype_ext.frr_nranges) != 0 ||
be32toh(frl->frl_maplower_ext.frr_nranges) != 0 ||
be32toh(frl->frl_mapupper_ext.frr_nranges) != 0)
return EFTYPE;
if (lenvar < be32toh((uint32_t)frl->frl_variable_len))
return EFTYPE;
for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) {
blp->blp_ctype_tab [i + 1] = (unsigned char)
_runetype_to_ctype((_RuneType)
be32toh(frl->frl_runetype[i]));
blp->blp_tolower_tab[i + 1] = (short)
be32toh((uint32_t)frl->frl_maplower[i]);
blp->blp_toupper_tab[i + 1] = (short)
be32toh((uint32_t)frl->frl_mapupper[i]);
}
return 0;
}
int
_bsdctype_load(const char * __restrict var, size_t lenvar,
_BSDCTypeLocale ** __restrict pbl)
{
int ret;
_BSDCTypeLocalePriv *blp;
_DIAGASSERT(var != NULL || lenvar < 1);
_DIAGASSERT(pbl != NULL);
if (lenvar < 1)
return EFTYPE;
blp = malloc(sizeof(*blp));
if (blp == NULL)
return errno;
_bsdctype_init_priv(blp);
switch (*var) {
case 'R':
_bsdctype_read_runetype(var, lenvar, blp);
break;
default:
ret = EFTYPE;
}
if (ret)
free(blp);
else
*pbl = &blp->bl;
return ret;
}

View File

@ -1,45 +0,0 @@
/* $NetBSD: bsdctype_file.h,v 1.2 2011/03/25 00:45:24 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#ifndef _BSDCTYPE_FILE_H_
#define _BSDCTYPE_FILE_H_
#include "ctype_local.h"
typedef struct {
char fbl_id[8];
uint32_t fbl_rev;
uint32_t fbl_num_chars;
uint8_t fbl_ctype_tab [_CTYPE_CACHE_SIZE];
int16_t fbl_tolower_tab[_CTYPE_CACHE_SIZE];
int16_t fbl_toupper_tab[_CTYPE_CACHE_SIZE];
} __packed _FileBSDCTypeLocale;
#define _CTYPE_REV 2
#endif /*_BSDCTYPE_FILE_H_*/

View File

@ -1,48 +0,0 @@
/* $NetBSD: bsdctype_local.h,v 1.2 2010/06/19 13:26:52 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
*/
#ifndef _BSDCTYPE_LOCAL_H_
#define _BSDCTYPE_LOCAL_H_
#include "bsdctype_file.h"
typedef struct {
const unsigned char *bl_ctype_tab;
const short *bl_tolower_tab;
const short *bl_toupper_tab;
} _BSDCTypeLocale;
extern const _BSDCTypeLocale _DefaultBSDCTypeLocale;
extern const _BSDCTypeLocale *_CurrentBSDCTypeLocale;
__BEGIN_DECLS
int _bsdctype_load(const char * __restrict, size_t,
_BSDCTypeLocale ** __restrict);
__END_DECLS
#endif /*_BSDCTYPE_LOCAL_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: global_locale.c,v 1.11 2010/06/19 13:26:52 tnozaki Exp $ */
/* $NetBSD: global_locale.c,v 1.12 2012/01/20 16:31:29 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: global_locale.c,v 1.11 2010/06/19 13:26:52 tnozaki Exp $");
__RCSID("$NetBSD: global_locale.c,v 1.12 2012/01/20 16:31:29 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -39,12 +39,8 @@ __RCSID("$NetBSD: global_locale.c,v 1.11 2010/06/19 13:26:52 tnozaki Exp $");
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include <stdlib.h>
#ifdef WITH_RUNE
#include "runetype_local.h"
#else
#include "bsdctype_local.h"
#endif
#include "runetype_local.h"
#include "setlocale_local.h"
static struct lconv _global_ldata = {
@ -159,11 +155,7 @@ struct _locale_impl_t _global_locale = {
[(size_t)LC_ALL ] = (_locale_part_t)NULL,
[(size_t)LC_COLLATE ] = (_locale_part_t)NULL,
[(size_t)LC_CTYPE ] = (_locale_part_t)
#ifdef WITH_RUNE
__UNCONST(&_DefaultRuneLocale),
#else
__UNCONST(&_DefaultBSDCTypeLocale),
#endif
[(size_t)LC_MONETARY] = (_locale_part_t)
__UNCONST(&_DefaultMonetaryLocale),
[(size_t)LC_NUMERIC ] = (_locale_part_t)

View File

@ -1,199 +0,0 @@
/* $NetBSD: iswctype_sb.c,v 1.11 2010/06/01 18:00:28 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: iswctype_sb.c,v 1.11 2010/06/01 18:00:28 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <assert.h>
#define _CTYPE_NOINLINE
#include <ctype.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <wchar.h>
#include <wctype.h>
#define _ISWCTYPE_FUNC(name) \
int \
isw##name(wint_t wc) \
{ \
int c; \
\
c = (wc == WEOF) ? EOF : (unsigned char)wc; \
return is##name(c); \
}
_ISWCTYPE_FUNC(alnum)
_ISWCTYPE_FUNC(alpha)
_ISWCTYPE_FUNC(blank)
_ISWCTYPE_FUNC(cntrl)
_ISWCTYPE_FUNC(digit)
_ISWCTYPE_FUNC(graph)
_ISWCTYPE_FUNC(lower)
_ISWCTYPE_FUNC(print)
_ISWCTYPE_FUNC(punct)
_ISWCTYPE_FUNC(space)
_ISWCTYPE_FUNC(upper)
_ISWCTYPE_FUNC(xdigit)
#define _TOWCTRANS_FUNC(name) \
wint_t \
tow##name(wint_t wc) \
{ \
int c; \
c = (wc == WEOF) ? EOF : (unsigned char)wc; \
return to##name(c); \
}
_TOWCTRANS_FUNC(upper)
_TOWCTRANS_FUNC(lower)
struct _wctype_priv_t {
const char *name;
int (*iswctype)(wint_t);
};
static const struct _wctype_priv_t _wctype_decl[] = {
{ "alnum", &iswalnum },
{ "alpha", &iswalpha },
{ "blank", &iswblank },
{ "cntrl", &iswcntrl },
{ "digit", &iswdigit },
{ "graph", &iswgraph },
{ "lower", &iswlower },
{ "print", &iswprint },
{ "punct", &iswpunct },
{ "space", &iswspace },
{ "upper", &iswupper },
{ "xdigit", &iswxdigit },
};
static const size_t _wctype_decl_size =
sizeof(_wctype_decl) / sizeof(struct _wctype_priv_t);
wctype_t
wctype(const char *charclass)
{
size_t i;
for (i = 0; i < _wctype_decl_size; ++i) {
if (!strcmp(charclass, _wctype_decl[i].name))
return (wctype_t)__UNCONST(&_wctype_decl[i]);
}
return (wctype_t)NULL;
}
struct _wctrans_priv_t {
const char *name;
wint_t (*towctrans)(wint_t);
};
static const struct _wctrans_priv_t _wctrans_decl[] = {
{ "upper", &towupper },
{ "lower", &towlower },
};
static const size_t _wctrans_decl_size =
sizeof(_wctrans_decl) / sizeof(struct _wctrans_priv_t);
wctrans_t
/*ARGSUSED*/
wctrans(const char *charmap)
{
size_t i;
for (i = 0; i < _wctrans_decl_size; ++i) {
if (!strcmp(charmap, _wctrans_decl[i].name))
return (wctrans_t)__UNCONST(&_wctrans_decl[i]);
}
return (wctrans_t)NULL;
}
int
/*ARGSUSED*/
iswctype(wint_t wc, wctype_t charclass)
{
const struct _wctype_priv_t *p;
p = (const struct _wctype_priv_t *)(void *)charclass;
if (p < &_wctype_decl[0] || p > &_wctype_decl[_wctype_decl_size - 1]) {
errno = EINVAL;
return 0;
}
return (*p->iswctype)(wc);
}
wint_t
/*ARGSUSED*/
towctrans(wint_t wc, wctrans_t charmap)
{
const struct _wctrans_priv_t *p;
p = (const struct _wctrans_priv_t *)(void *)charmap;
if (p < &_wctrans_decl[0] || p > &_wctrans_decl[_wctrans_decl_size - 1]) {
errno = EINVAL;
return wc;
}
return (*p->towctrans)(wc);
}
__weak_alias(wcwidth,_wcwidth)
int
wcwidth(wchar_t wc)
{
int c;
switch (wc) {
case L'\0':
return 0;
case WEOF:
c = EOF;
break;
default:
c = (unsigned char)wc;
}
if (isprint(c))
return 1;
return -1;
}
int
wcswidth(const wchar_t * __restrict ws, size_t wn)
{
const wchar_t *pws;
int c;
pws = ws;
while (wn > 0 && *ws != L'\0') {
c = (*ws == WEOF) ? EOF : (unsigned char)*ws;
if (!isprint(c))
return -1;
++ws, --wn;
}
return (int)(ws - pws);
}

View File

@ -1,177 +0,0 @@
/* $NetBSD: localeio.c,v 1.6 2011/10/15 23:00:02 christos Exp $ */
/*
* Copyright (c) 2008, The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Brian Ginsbach.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: localeio.c,v 1.6 2011/10/15 23:00:02 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <locale.h>
#include <paths.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "localeio.h"
int
_localeio_map_file(const char * __restrict path,
void ** __restrict pvar, size_t * __restrict plenvar)
{
int fd, ret;
struct stat st;
void *var;
size_t lenvar;
_DIAGASSERT(path != NULL);
_DIAGASSERT(pvar != NULL);
_DIAGASSERT(plenvar != NULL);
fd = open(path, O_RDONLY | O_CLOEXEC);
if (fd == -1)
return errno;
if (fstat(fd, &st) == -1) {
ret = errno;
goto error;
}
if (!S_ISREG(st.st_mode)) {
ret = EBADF;
goto error;
}
lenvar = (size_t)st.st_size;
if (lenvar < 1) {
ret = EFTYPE;
goto error;
}
var = mmap(NULL, lenvar, PROT_READ,
MAP_FILE|MAP_PRIVATE, fd, (off_t)0);
if (var == MAP_FAILED) {
ret = errno;
goto error;
}
*pvar = var;
*plenvar = lenvar;
return 0;
error:
return ret;
}
void
_localeio_unmap_file(void *var, size_t lenvar)
{
munmap(var, lenvar);
}
int
__loadlocale(const char *name, size_t nstr, size_t nbytes,
size_t localesize, void *currentlocale)
{
int fd, ret;
unsigned char **ap, *buf, *bp, *cp, *cbp, *ebp;
unsigned char ***locale;
struct stat st;
size_t i, bufsize;
_DIAGASSERT(name != NULL);
_DIAGASSERT(localesize != 0);
_DIAGASSERT(currentlocale != NULL);
if ((fd = open(name, O_RDONLY)) == -1)
return ENOENT;
if ((fstat(fd, &st) == -1) || !S_ISREG(st.st_mode) ||
(st.st_size <= 0)) {
ret = EFTYPE;
goto error1;
}
bufsize = localesize + (size_t)st.st_size;
if ((buf = malloc(bufsize)) == NULL) {
ret = ENOMEM;
goto error1;
}
bp = buf + localesize;
if (read(fd, bp, (size_t)st.st_size) != st.st_size) {
ret = EFTYPE;
goto error2;
}
ap = (unsigned char **)(void *)buf;
for (i = (size_t)0, ebp = buf + bufsize; i < nstr; i++) {
ap[i] = bp;
while (bp != ebp && *bp != '\n')
bp++;
if (bp == ebp) {
ret = EFTYPE;
goto error2;
}
*bp++ = '\0';
}
cp = buf + (sizeof(unsigned char *) * nstr);
for (i = 0, cbp = bp; i < nbytes; i++) {
int n;
while (bp != ebp && *bp != '\n')
bp++;
if (bp == ebp) {
ret = EFTYPE;
goto error2;
}
/* ignore overflow/underflow and bad characters */
n = (unsigned char)strtol((char *)cbp, NULL, 0);
cp[i] = (unsigned char)(n & CHAR_MAX);
cbp = bp;
}
locale = currentlocale;
*locale = (unsigned char **)(void *)buf;
(void)close(fd);
return 0;
error2:
free(buf);
error1:
(void)close(fd);
return ret;
}

View File

@ -1,122 +0,0 @@
/* $NetBSD: localeio_lc_ctype.c,v 1.6 2010/06/19 13:26:52 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
* All rights reserved.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: localeio_lc_ctype.c,v 1.6 2010/06/19 13:26:52 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include <sys/types.h>
#include <sys/ctype_bits.h>
#include <sys/queue.h>
#include <assert.h>
#include <errno.h>
#include <langinfo.h>
#include <limits.h>
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "bsdctype_local.h"
#include "aliasname_local.h"
#include "localeio.h"
#include "setlocale_local.h"
/*
* macro required by all template headers
*/
#define _PREFIX(name) __CONCAT(_localeio_LC_CTYPE_, name)
/*
* macro required by nb_lc_template(_decl).h
*/
#define _CATEGORY_TYPE _BSDCTypeLocale
#include "nb_lc_template_decl.h"
static int
/*ARGSUSED*/
_localeio_LC_CTYPE_create_impl(const char * __restrict root,
const char * __restrict name, _BSDCTypeLocale ** __restrict pdata)
{
char path[PATH_MAX + 1];
void *var;
size_t lenvar;
int ret;
_DIAGASSERT(root != NULL);
_DIAGASSERT(name != NULL);
_DIAGASSERT(pdata != NULL);
snprintf(path, sizeof(path),
"%s/%s/LC_CTYPE", root, name);
ret = _localeio_map_file(path, &var, &lenvar);
if (!ret) {
ret = _bsdctype_load((const char *)var, lenvar, pdata);
_localeio_unmap_file(var, lenvar);
}
return ret;
}
static __inline void
_PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
_BSDCTypeLocale * __restrict data)
{
_DIAGASSERT(cache != NULL);
_DIAGASSERT(data != NULL);
cache->ctype_tab = data->bl_ctype_tab;
cache->tolower_tab = data->bl_tolower_tab;
cache->toupper_tab = data->bl_toupper_tab;
cache->mb_cur_max = (size_t)1;
}
static __inline void
_PREFIX(fixup)(_BSDCTypeLocale *data)
{
_DIAGASSERT(data != NULL);
_ctype_ = data->bl_ctype_tab;
_tolower_tab_ = data->bl_tolower_tab;
_toupper_tab_ = data->bl_toupper_tab;
}
/*
* macro required by nb_lc_template.h
*/
#define _CATEGORY_ID LC_CTYPE
#define _CATEGORY_NAME "LC_CTYPE"
#define _CATEGORY_DEFAULT _DefaultBSDCTypeLocale
#include "nb_lc_template.h"
#include "generic_lc_template.h"
_LOCALE_CATEGORY_ENTRY(_localeio_LC_CTYPE_);

View File

@ -1,83 +0,0 @@
/* $NetBSD: localeio_lc_messages.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/*
* Copyright (c) 2008, The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Brian Ginsbach.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: localeio_lc_messages.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include <sys/types.h>
#include <sys/localedef.h>
#include <sys/queue.h>
#include <assert.h>
#include <errno.h>
#include <langinfo.h>
#include <limits.h>
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "setlocale_local.h"
#include "aliasname_local.h"
#include "localeio.h"
/*
* macro required by all template headers
*/
#define _PREFIX(name) __CONCAT(_localeio_LC_MESSAGES_, name)
#include "nb_lc_messages_misc.h"
#include "nb_lc_template_decl.h"
#define NSTRINGS (sizeof(_MessagesLocale)/sizeof(const char **))
static int
_localeio_LC_MESSAGES_create_impl(const char * __restrict root,
const char * __restrict name, _MessagesLocale ** __restrict pdata)
{
char path[PATH_MAX + 1];
_DIAGASSERT(root != NULL);
_DIAGASSERT(name != NULL);
_DIAGASSERT(pdata != NULL);
snprintf(path, sizeof(path),
"%s/%s/LC_MESSAGES/SYS_LC_MESSAGES", root, name);
return __loadlocale(path, NSTRINGS, 0, sizeof(_MessagesLocale),
(void *)pdata);
}
#include "nb_lc_template.h"
_LOCALE_CATEGORY_ENTRY(_localeio_LC_MESSAGES_);

View File

@ -1,95 +0,0 @@
/* $NetBSD: localeio_lc_monetary.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/*
* Copyright (c) 2008, The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Brian Ginsbach.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: localeio_lc_monetary.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include <sys/types.h>
#include <sys/localedef.h>
#include <sys/queue.h>
#include <assert.h>
#include <errno.h>
#include <langinfo.h>
#include <limits.h>
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "setlocale_local.h"
#include "aliasname_local.h"
#include "fix_grouping.h"
#include "localeio.h"
/*
* macro required by all template headers
*/
#define _PREFIX(name) __CONCAT(_localeio_LC_MONETARY_, name)
#include "nb_lc_monetary_misc.h"
#include "nb_lc_template_decl.h"
#define NSTRINGS \
(offsetof(_MonetaryLocale, int_frac_digits)/sizeof(const char **))
#define NCHARS \
(offsetof(_MonetaryLocale, int_n_sign_posn) - \
offsetof(_MonetaryLocale, int_frac_digits) + 1)
static int
_localeio_LC_MONETARY_create_impl(const char * __restrict root,
const char * __restrict name, _MonetaryLocale ** __restrict pdata)
{
char path[PATH_MAX + 1];
int ret;
_DIAGASSERT(root != NULL);
_DIAGASSERT(name != NULL);
_DIAGASSERT(pdata != NULL);
snprintf(path, sizeof(path),
"%s/%s/LC_MONETARY", root, name);
ret = __loadlocale(path, NSTRINGS, NCHARS, sizeof(_MonetaryLocale),
(void *)pdata);
if (!ret) {
(*pdata)->mon_grouping =
__fix_locale_grouping_str((*pdata)->mon_grouping);
}
return ret;
}
#include "nb_lc_template.h"
_LOCALE_CATEGORY_ENTRY(_localeio_LC_MONETARY_);

View File

@ -1,90 +0,0 @@
/* $NetBSD: localeio_lc_numeric.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/*
* Copyright (c) 2008, The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Brian Ginsbach.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: localeio_lc_numeric.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include <sys/types.h>
#include <sys/localedef.h>
#include <sys/queue.h>
#include <assert.h>
#include <errno.h>
#include <langinfo.h>
#include <limits.h>
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "setlocale_local.h"
#include "aliasname_local.h"
#include "fix_grouping.h"
#include "localeio.h"
/*
* macro required by all template headers
*/
#define _PREFIX(name) __CONCAT(_localeio_LC_NUMERIC_, name)
#include "nb_lc_numeric_misc.h"
#include "nb_lc_template_decl.h"
#define NSTRINGS (sizeof(_NumericLocale)/sizeof(const char **))
static int
_localeio_LC_NUMERIC_create_impl(const char * __restrict root,
const char * __restrict name, _NumericLocale ** __restrict pdata)
{
char path[PATH_MAX + 1];
int ret;
_DIAGASSERT(root != NULL);
_DIAGASSERT(name != NULL);
_DIAGASSERT(pdata != NULL);
snprintf(path, sizeof(path),
"%s/%s/LC_NUMERIC", root, name);
ret = __loadlocale(path, NSTRINGS, 0, sizeof(_NumericLocale),
(void *)pdata);
if (!ret) {
(*pdata)->grouping =
__fix_locale_grouping_str((*pdata)->grouping);
}
return ret;
}
#include "nb_lc_template.h"
_LOCALE_CATEGORY_ENTRY(_localeio_LC_NUMERIC_);

View File

@ -1,84 +0,0 @@
/* $NetBSD: localeio_lc_time.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/*
* Copyright (c) 2008, The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Brian Ginsbach.
*
* 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.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: localeio_lc_time.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
#include <sys/types.h>
#include <sys/localedef.h>
#include <sys/queue.h>
#include <assert.h>
#include <errno.h>
#include <langinfo.h>
#include <limits.h>
#define __SETLOCALE_SOURCE__
#include <locale.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "setlocale_local.h"
#include "aliasname_local.h"
#include "fix_grouping.h"
#include "localeio.h"
/*
* macro required by all template headers
*/
#define _PREFIX(name) __CONCAT(_localeio_LC_TIME_, name)
#include "nb_lc_time_misc.h"
#include "nb_lc_template_decl.h"
#define NSTRINGS (sizeof(_TimeLocale)/sizeof(const char **))
static int
_localeio_LC_TIME_create_impl(const char * __restrict root,
const char * __restrict name, _TimeLocale ** __restrict pdata)
{
char path[PATH_MAX + 1];
_DIAGASSERT(root != NULL);
_DIAGASSERT(name != NULL);
_DIAGASSERT(pdata != NULL);
snprintf(path, sizeof(path),
"%s/%s/LC_TIME", root, name);
return __loadlocale(path, NSTRINGS, 0, sizeof(_TimeLocale),
(void *)pdata);
}
#include "nb_lc_template.h"
_LOCALE_CATEGORY_ENTRY(_localeio_LC_TIME_);

View File

@ -1,265 +0,0 @@
/* $NetBSD: multibyte_sb.c,v 1.5 2004/07/21 20:27:46 tshiozak Exp $ */
/*
* Copyright (c) 1991 The Regents of the University of California.
* All rights reserved.
*
* 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. 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 <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
#if 0
static char *sccsid = "from: @(#)multibyte.c 5.1 (Berkeley) 2/18/91";
#else
__RCSID("$NetBSD: multibyte_sb.c,v 1.5 2004/07/21 20:27:46 tshiozak Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <wchar.h>
/*
* Stub multibyte character functions.
* This cheezy implementation is fixed to the native single-byte
* character set.
*/
/*ARGSUSED*/
int
mbsinit(ps)
const mbstate_t *ps;
{
return 1;
}
/*ARGSUSED*/
size_t
mbrlen(s, n, ps)
const char *s;
size_t n;
mbstate_t *ps;
{
/* ps appears to be unused */
if (s == NULL || *s == '\0')
return 0;
if (n == 0)
return (size_t)-1;
return 1;
}
int
mblen(s, n)
const char *s;
size_t n;
{
/* s may be NULL */
return mbrlen(s, n, NULL);
}
/*ARGSUSED*/
size_t
mbrtowc(pwc, s, n, ps)
wchar_t *pwc;
const char *s;
size_t n;
mbstate_t *ps;
{
/* pwc may be NULL */
/* s may be NULL */
/* ps appears to be unused */
if (s == NULL)
return 0;
if (n == 0)
return (size_t)-1;
if (pwc)
*pwc = (wchar_t) *s;
return (*s != '\0');
}
int
mbtowc(pwc, s, n)
wchar_t *pwc;
const char *s;
size_t n;
{
/* pwc may be NULL */
/* s may be NULL */
return mbrtowc(pwc, s, n, NULL);
}
/*ARGSUSED*/
size_t
wcrtomb(s, wchar, ps)
char *s;
wchar_t wchar;
mbstate_t *ps;
{
/* s may be NULL */
/* ps appears to be unused */
if (s == NULL)
return 0;
*s = (char) wchar;
return 1;
}
int
wctomb(s, wchar)
char *s;
wchar_t wchar;
{
/* s may be NULL */
return wcrtomb(s, wchar, NULL);
}
/*ARGSUSED*/
size_t
mbsrtowcs(pwcs, s, n, ps)
wchar_t *pwcs;
const char **s;
size_t n;
mbstate_t *ps;
{
int count = 0;
/* pwcs may be NULL */
/* s may be NULL */
/* ps appears to be unused */
if (!s || !*s)
return 0;
if (n != 0) {
if (pwcs != NULL) {
do {
if ((*pwcs++ = (wchar_t) *(*s)++) == 0)
break;
count++;
} while (--n != 0);
} else {
do {
if (((wchar_t)*(*s)++) == 0)
break;
count++;
} while (--n != 0);
}
}
return count;
}
size_t
mbstowcs(pwcs, s, n)
wchar_t *pwcs;
const char *s;
size_t n;
{
/* pwcs may be NULL */
/* s may be NULL */
return mbsrtowcs(pwcs, &s, n, NULL);
}
/*ARGSUSED*/
size_t
wcsrtombs(s, pwcs, n, ps)
char *s;
const wchar_t **pwcs;
size_t n;
mbstate_t *ps;
{
int count = 0;
/* s may be NULL */
/* pwcs may be NULL */
/* ps appears to be unused */
if (pwcs == NULL || *pwcs == NULL)
return (0);
if (s == NULL) {
while (*(*pwcs)++ != 0)
count++;
return(count);
}
if (n != 0) {
do {
if ((*s++ = (char) *(*pwcs)++) == 0)
break;
count++;
} while (--n != 0);
}
return count;
}
size_t
wcstombs(s, pwcs, n)
char *s;
const wchar_t *pwcs;
size_t n;
{
/* s may be NULL */
/* pwcs may be NULL */
return wcsrtombs(s, &pwcs, n, NULL);
}
wint_t
btowc(c)
int c;
{
if (c == EOF || c & ~0xFF)
return WEOF;
return (wint_t)c;
}
int
wctob(c)
wint_t c;
{
if (c == WEOF || c & ~0xFF)
return EOF;
return (int)c;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: rune.c,v 1.42 2011/03/25 00:45:24 joerg Exp $ */
/* $NetBSD: rune.c,v 1.43 2012/01/20 16:31:30 joerg Exp $ */
/*-
* Copyright (c)2010 Citrus Project,
@ -47,7 +47,6 @@
#include "citrus_ctype.h"
#include "runetype_local.h"
#include "bsdctype_local.h"
#include "multibyte.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: setlocale.c,v 1.58 2010/06/07 13:52:30 tnozaki Exp $ */
/* $NetBSD: setlocale.c,v 1.59 2012/01/20 16:31:30 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: setlocale.c,v 1.58 2010/06/07 13:52:30 tnozaki Exp $");
__RCSID("$NetBSD: setlocale.c,v 1.59 2012/01/20 16:31:30 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -47,35 +47,19 @@ __link_set_decl(all_categories, _locale_category_t);
extern const _locale_category_t _generic_LC_ALL_desc;
extern const _locale_category_t _dummy_LC_COLLATE_desc;
#ifdef WITH_RUNE
extern const _locale_category_t _citrus_LC_CTYPE_desc;
extern const _locale_category_t _citrus_LC_MONETARY_desc;
extern const _locale_category_t _citrus_LC_NUMERIC_desc;
extern const _locale_category_t _citrus_LC_TIME_desc;
extern const _locale_category_t _citrus_LC_MESSAGES_desc;
#else
extern const _locale_category_t _localeio_LC_CTYPE_desc;
extern const _locale_category_t _localeio_LC_MONETARY_desc;
extern const _locale_category_t _localeio_LC_NUMERIC_desc;
extern const _locale_category_t _localeio_LC_TIME_desc;
extern const _locale_category_t _localeio_LC_MESSAGES_desc;
#endif
__link_set_add_data(all_categories, _generic_LC_ALL_desc);
__link_set_add_data(all_categories, _dummy_LC_COLLATE_desc);
#ifdef WITH_RUNE
__link_set_add_data(all_categories, _citrus_LC_CTYPE_desc);
__link_set_add_data(all_categories, _citrus_LC_MONETARY_desc);
__link_set_add_data(all_categories, _citrus_LC_NUMERIC_desc);
__link_set_add_data(all_categories, _citrus_LC_TIME_desc);
__link_set_add_data(all_categories, _citrus_LC_MESSAGES_desc);
#else
__link_set_add_data(all_categories, _localeio_LC_CTYPE_desc);
__link_set_add_data(all_categories, _localeio_LC_MONETARY_desc);
__link_set_add_data(all_categories, _localeio_LC_NUMERIC_desc);
__link_set_add_data(all_categories, _localeio_LC_TIME_desc);
__link_set_add_data(all_categories, _localeio_LC_MESSAGES_desc);
#endif
_locale_category_t *
_find_category(int category)

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile.inc,v 1.10 2009/01/11 02:46:29 christos Exp $
# $NetBSD: Makefile.inc,v 1.11 2012/01/20 16:31:30 joerg Exp $
.PATH: ${.CURDIR}/nls
@ -8,9 +8,5 @@ MAN+= catclose.3 catgets.3 catopen.3
# indirect reference stubs, to be removed soon.
SRCS+= _catclose.c _catgets.c _catopen.c
.if ${CITRUS} == "yes"
CPPFLAGS.catopen.c+= -DHAVE_CITRUS -I${LIBCDIR}/citrus
.else
CPPFLAGS.catopen.c+= -UHAVE_CITRUS -I${LIBCDIR}/locale
.endif
CPPFLAGS.catopen.c+= -I${LIBCDIR}/citrus

View File

@ -1,4 +1,4 @@
/* $NetBSD: catopen.c,v 1.28 2009/03/10 13:15:40 joerg Exp $ */
/* $NetBSD: catopen.c,v 1.29 2012/01/20 16:31:30 joerg Exp $ */
/*-
* Copyright (c) 1996 The NetBSD Foundation, Inc.
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: catopen.c,v 1.28 2009/03/10 13:15:40 joerg Exp $");
__RCSID("$NetBSD: catopen.c,v 1.29 2012/01/20 16:31:30 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#define _NLS_PRIVATE
@ -50,15 +50,11 @@ __RCSID("$NetBSD: catopen.c,v 1.28 2009/03/10 13:15:40 joerg Exp $");
#include <string.h>
#include <unistd.h>
#ifdef HAVE_CITRUS
#include "citrus_namespace.h"
#include "citrus_bcs.h"
#include "citrus_region.h"
#include "citrus_lookup.h"
#include "citrus_aliasname_local.h"
#else
#include "aliasname_local.h"
#endif
#define NLS_ALIAS_DB "/usr/share/nls/nls.alias"

View File

@ -1,4 +1,4 @@
# $NetBSD: Makefile,v 1.3 2009/04/14 22:15:22 lukem Exp $
# $NetBSD: Makefile,v 1.4 2012/01/20 16:31:30 joerg Exp $
# FreeBSD: src/usr.bin/locale/Makefile,v 1.4 2003/06/25 23:05:11 phantom Exp
WARNS?= 2 # XXX -Wcast-qual issues
@ -6,9 +6,6 @@ WARNS?= 2 # XXX -Wcast-qual issues
PROG = locale
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/locale
CITRUS?= yes
.if ${CITRUS} == "yes"
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/citrus -DCITRUS
.endif
CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/citrus
.include <bsd.prog.mk>

View File

@ -1,4 +1,4 @@
/* $NetBSD: locale.c,v 1.7 2009/01/16 13:30:07 hira Exp $ */
/* $NetBSD: locale.c,v 1.8 2012/01/20 16:31:30 joerg Exp $ */
/*-
* Copyright (c) 2002, 2003 Alexey Zelkin <phantom@FreeBSD.org>
@ -30,7 +30,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: locale.c,v 1.7 2009/01/16 13:30:07 hira Exp $");
__RCSID("$NetBSD: locale.c,v 1.8 2012/01/20 16:31:30 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
/*
@ -56,11 +56,9 @@ __RCSID("$NetBSD: locale.c,v 1.7 2009/01/16 13:30:07 hira Exp $");
#include <stringlist.h>
#include <unistd.h>
#ifdef CITRUS
#include "citrus_namespace.h"
#include "citrus_region.h"
#include "citrus_lookup.h"
#endif
#include "setlocale_local.h"
/* Local prototypes */
@ -443,12 +441,8 @@ void
init_locales_list_alias(void)
{
char aliaspath[PATH_MAX];
#ifdef CITRUS
struct _lookup *hlookup;
struct _region key, dat;
#else
FILE *fp;
#endif
size_t n;
char *s, *t;
@ -458,23 +452,12 @@ init_locales_list_alias(void)
(void)snprintf(aliaspath, sizeof(aliaspath),
"%s/" _LOCALE_ALIAS_NAME, _PathLocale);
#ifdef CITRUS
if (_lookup_seq_open(&hlookup, aliaspath,
_LOOKUP_CASE_SENSITIVE) == 0) {
while (_lookup_seq_next(hlookup, &key, &dat) == 0) {
n = _region_size((const struct _region *)&key);
s = _region_head((const struct _region *)&key);
for (t = s; n > 0 && *s!= '/'; --n, ++s);
#else
fp = fopen(aliaspath, "r");
if (fp != NULL) {
while ((s = fgetln(fp, &n)) != NULL) {
_DIAGASSERT(n > 0);
if (*s == '#' || *s == '\n')
continue;
for (t = s; n > 0 && strchr("/ \t\n", *s) == NULL;
--n, ++s);
#endif
n = (size_t)(s - t);
s = malloc(n + 1);
if (s == NULL)
@ -486,11 +469,7 @@ init_locales_list_alias(void)
else
free(s);
}
#ifdef CITRUS
_lookup_seq_close(hlookup);
#else
fclose(fp);
#endif
}
}