Libraries updates and cleanup

* Updating common/lib
 * Updating lib/csu
 * Updating lib/libc
 * Updating libexec/ld.elf_so
 * Corrected test on __minix in featuretest to actually follow the
   meaning of the comment.
 * Cleaned up _REENTRANT-related defintions.
 * Disabled -D_REENTRANT for libfetch
 * Removing some unneeded __NBSD_LIBC defines and tests

Change-Id: Ic1394baef74d11b9f86b312f5ff4bbc3cbf72ce2
This commit is contained in:
2013-01-14 11:36:26 +01:00
parent f6aac1c3b5
commit f14fb60209
1285 changed files with 44244 additions and 14308 deletions
+2 -5
View File
@@ -1,4 +1,4 @@
/* $NetBSD: _wcstol.h,v 1.3 2005/11/29 03:11:59 christos Exp $ */
/* $NetBSD: _wcstol.h,v 1.4 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c) 1990, 1993
@@ -45,10 +45,7 @@
*/
__INT
_FUNCNAME(nptr, endptr, base)
const wchar_t *nptr;
wchar_t **endptr;
int base;
_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
{
const wchar_t *s;
__INT acc, cutoff;
+2 -5
View File
@@ -1,4 +1,4 @@
/* $NetBSD: _wcstoul.h,v 1.3 2005/11/29 03:11:59 christos Exp $ */
/* $NetBSD: _wcstoul.h,v 1.4 2012/06/25 22:32:44 abs Exp $ */
/*
* Copyright (c) 1990, 1993
@@ -44,10 +44,7 @@
*/
__UINT
_FUNCNAME(nptr, endptr, base)
const wchar_t *nptr;
wchar_t **endptr;
int base;
_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base)
{
const wchar_t *s;
__UINT acc, cutoff;
-129
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;
}
-178
View File
@@ -1,178 +0,0 @@
/* $NetBSD: bsdctype.c,v 1.9 2010/06/20 02:23:15 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: bsdctype.c,v 1.9 2010/06/20 02:23:15 tnozaki 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_file(const char * __restrict var, size_t lenvar,
_BSDCTypeLocalePriv * __restrict blp)
{
const _FileBSDCTypeLocale *fbl;
uint32_t value;
int i;
_DIAGASSERT(blp != NULL);
if (lenvar < sizeof(*fbl))
return EFTYPE;
fbl = (const _FileBSDCTypeLocale *)(const void *)var;
if (memcmp(&fbl->fbl_id[0], _CTYPE_ID, sizeof(fbl->fbl_id)))
return EFTYPE;
value = be32toh(fbl->fbl_rev);
if (value != _CTYPE_REV)
return EFTYPE;
value = be32toh(fbl->fbl_num_chars);
if (value != _CTYPE_CACHE_SIZE)
return EFTYPE;
for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) {
blp->blp_ctype_tab [i + 1] = fbl->fbl_ctype_tab[i];
blp->blp_tolower_tab[i + 1] = be16toh(fbl->fbl_tolower_tab[i]);
blp->blp_toupper_tab[i + 1] = be16toh(fbl->fbl_toupper_tab[i]);
}
return 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 'B':
_bsdctype_read_file(var, lenvar, blp);
break;
case 'R':
_bsdctype_read_runetype(var, lenvar, blp);
break;
default:
ret = EFTYPE;
}
if (ret)
free(blp);
else
*pbl = &blp->bl;
return ret;
}
-46
View File
@@ -1,46 +0,0 @@
/* $NetBSD: bsdctype_file.h,v 1.1 2010/06/13 04:14:57 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_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_ID "BSDCTYPE"
#define _CTYPE_REV 2
#endif /*_BSDCTYPE_FILE_H_*/
-48
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_*/
+3 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: current_locale.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/* $NetBSD: current_locale.c,v 1.3 2012/03/20 17:44:18 matt Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: current_locale.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
__RCSID("$NetBSD: current_locale.c,v 1.3 2012/03/20 17:44:18 matt Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
@@ -43,7 +43,7 @@ __RCSID("$NetBSD: current_locale.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
static struct _locale_impl_t *__current_locale = &_global_locale;
struct _locale_impl_t **
_current_locale()
_current_locale(void)
{
return &__current_locale;
}
+2 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: dummy_lc_collate.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/* $NetBSD: dummy_lc_collate.c,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: dummy_lc_collate.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
__RCSID("$NetBSD: dummy_lc_collate.c,v 1.3 2012/03/04 21:14:56 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -51,4 +51,3 @@ __RCSID("$NetBSD: dummy_lc_collate.c,v 1.2 2009/01/11 02:46:28 christos Exp $");
#define _CATEGORY_NAME "LC_COLLATE"
#include "dummy_lc_template.h"
_LOCALE_CATEGORY_ENTRY(_dummy_LC_COLLATE_);
+2 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: dummy_lc_template.h,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/* $NetBSD: dummy_lc_template.h,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -31,7 +31,7 @@
#include "generic_lc_template_decl.h"
static const char *
const char *
_PREFIX(setlocale)(const char * __restrict name,
struct _locale_impl_t * __restrict locale)
{
@@ -51,6 +51,4 @@ _PREFIX(setlocale)(const char * __restrict name,
return locale->part_name[(size_t)_CATEGORY_ID];
}
#include "generic_lc_template.h"
#endif /*_DUMMY_LC_TEMPLATE_H_*/
+3 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: fix_grouping.c,v 1.5 2010/06/01 13:52:08 tnozaki Exp $ */
/* $NetBSD: fix_grouping.c,v 1.6 2012/03/21 14:11:24 christos Exp $ */
/*
* Copyright (c) 2001 Alexey Zelkin <phantom@FreeBSD.org>
@@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: fix_grouping.c,v 1.5 2010/06/01 13:52:08 tnozaki Exp $");
__RCSID("$NetBSD: fix_grouping.c,v 1.6 2012/03/21 14:11:24 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <limits.h>
@@ -44,7 +44,7 @@ __RCSID("$NetBSD: fix_grouping.c,v 1.5 2010/06/01 13:52:08 tnozaki Exp $");
#include "fix_grouping.h"
#ifndef NBCHAR_MAX
#define NBCHAR_MAX CHAR_MAX
#define NBCHAR_MAX (char)CHAR_MAX
#endif
#ifndef __UNCONST
+11 -18
View File
@@ -1,4 +1,4 @@
/* $NetBSD: generic_lc_all.c,v 1.3 2009/10/04 21:05:18 tnozaki Exp $ */
/* $NetBSD: generic_lc_all.c,v 1.4 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: generic_lc_all.c,v 1.3 2009/10/04 21:05:18 tnozaki Exp $");
__RCSID("$NetBSD: generic_lc_all.c,v 1.4 2012/03/04 21:14:56 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -53,13 +53,13 @@ const char *
_generic_LC_ALL_setlocale(const char * __restrict name,
struct _locale_impl_t * __restrict locale)
{
_locale_category_t *l;
_locale_set_t sl;
char head[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)], *tail;
const char *tokens[_LC_LAST], *s, *t;
int load_locale_success, i, j;
l = _find_category(1);
_DIAGASSERT(l != NULL);
sl = _find_category(1);
_DIAGASSERT(sl != NULL);
load_locale_success = 0;
if (name != NULL) {
strlcpy(&head[0], name, sizeof(head));
@@ -82,20 +82,20 @@ _generic_LC_ALL_setlocale(const char * __restrict name,
if (tail != NULL)
return NULL;
}
if ((*l->setlocale)(tokens[1], locale) != NULL)
if ((*sl)(tokens[1], locale) != NULL)
load_locale_success = 1;
}
s = (*l->setlocale)(NULL, locale);
s = (*sl)(NULL, locale);
_DIAGASSERT(s != NULL);
strlcpy(&locale->query[0], s, sizeof(locale->query));
for (i = 2, j = 0; i < _LC_LAST; ++i) {
l = _find_category(i);
_DIAGASSERT(l != NULL);
sl = _find_category(i);
_DIAGASSERT(sl != NULL);
if (name != NULL) {
if ((*l->setlocale)(tokens[i], locale) != NULL)
if ((*sl)(tokens[i], locale) != NULL)
load_locale_success = 1;
}
t = (*l->setlocale)(NULL, locale);
t = (*sl)(NULL, locale);
_DIAGASSERT(t != NULL);
if (j == 0) {
if (!strcmp(s, t))
@@ -115,10 +115,3 @@ _generic_LC_ALL_setlocale(const char * __restrict name,
return (const char *)&locale->query[0];
}
/*
* macro requrired by generic_lc_template.h
*/
#define _CATEGORY_ID LC_ALL
#include "generic_lc_template.h"
_LOCALE_CATEGORY_ENTRY(_generic_LC_ALL_);
-38
View File
@@ -1,38 +0,0 @@
/* $NetBSD: generic_lc_template.h,v 1.3 2009/03/09 02:22:25 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 _GENERIC_LC_TEMPLATE_H_
#define _GENERIC_LC_TEMPLATE_H_
#define _LOCALE_CATEGORY_ENTRY(name) \
const _locale_category_t name##desc = { \
.category = _CATEGORY_ID, \
.setlocale = &name##setlocale, \
}
#endif /*_GENERIC_LC_TEMPLATE_H_*/
+2 -2
View File
@@ -1,4 +1,4 @@
/* $NetBSD: generic_lc_template_decl.h,v 1.2 2009/01/11 02:46:28 christos Exp $ */
/* $NetBSD: generic_lc_template_decl.h,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -29,7 +29,7 @@
#ifndef _GENERIC_LC_TEMPLATE_DECL_H_
#define _GENERIC_LC_TEMPLATE_DECL_H_
static const char * _PREFIX(setlocale)(const char * __restrict,
const char * _PREFIX(setlocale)(const char * __restrict,
struct _locale_impl_t * __restrict);
#endif /*_GENERIC_LC_TEMPLATE_DECL_H_*/
+21 -25
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.13 2012/03/21 14:11:24 christos 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.13 2012/03/21 14:11:24 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -39,14 +39,14 @@ __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"
#ifndef NBCHAR_MAX
#define NBCHAR_MAX (char)CHAR_MAX
#endif
static struct lconv _global_ldata = {
.decimal_point = __UNCONST("."),
.thousands_sep = __UNCONST(""),
@@ -58,20 +58,20 @@ static struct lconv _global_ldata = {
.mon_grouping = __UNCONST(""),
.positive_sign = __UNCONST(""),
.negative_sign = __UNCONST(""),
.int_frac_digits = CHAR_MAX,
.frac_digits = CHAR_MAX,
.p_cs_precedes = CHAR_MAX,
.p_sep_by_space = CHAR_MAX,
.n_cs_precedes = CHAR_MAX,
.n_sep_by_space = CHAR_MAX,
.p_sign_posn = CHAR_MAX,
.n_sign_posn = CHAR_MAX,
.int_p_cs_precedes = CHAR_MAX,
.int_n_cs_precedes = CHAR_MAX,
.int_p_sep_by_space = CHAR_MAX,
.int_n_sep_by_space = CHAR_MAX,
.int_p_sign_posn = CHAR_MAX,
.int_n_sign_posn = CHAR_MAX,
.int_frac_digits = NBCHAR_MAX,
.frac_digits = NBCHAR_MAX,
.p_cs_precedes = NBCHAR_MAX,
.p_sep_by_space = NBCHAR_MAX,
.n_cs_precedes = NBCHAR_MAX,
.n_sep_by_space = NBCHAR_MAX,
.p_sign_posn = NBCHAR_MAX,
.n_sign_posn = NBCHAR_MAX,
.int_p_cs_precedes = NBCHAR_MAX,
.int_n_cs_precedes = NBCHAR_MAX,
.int_p_sep_by_space = NBCHAR_MAX,
.int_n_sep_by_space = NBCHAR_MAX,
.int_p_sign_posn = NBCHAR_MAX,
.int_n_sign_posn = NBCHAR_MAX,
};
static const char *_global_items[(size_t)ALT_DIGITS + 1] = {
@@ -159,11 +159,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)
-199
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);
}
+3 -3
View File
@@ -1,4 +1,4 @@
/* $NetBSD: localeconv.c,v 1.18 2010/05/22 13:15:59 tnozaki Exp $ */
/* $NetBSD: localeconv.c,v 1.19 2012/06/24 15:26:03 christos Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: localeconv.c,v 1.18 2010/05/22 13:15:59 tnozaki Exp $");
__RCSID("$NetBSD: localeconv.c,v 1.19 2012/06/24 15:26:03 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -39,7 +39,7 @@ __RCSID("$NetBSD: localeconv.c,v 1.18 2010/05/22 13:15:59 tnozaki Exp $");
#include "setlocale_local.h"
struct lconv *
localeconv()
localeconv(void)
{
return _current_cache()->ldata;
}
-177
View File
@@ -1,177 +0,0 @@
/* $NetBSD: localeio.c,v 1.5 2010/06/19 13:26:52 tnozaki 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.5 2010/06/19 13:26:52 tnozaki 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);
if (fd == -1)
return errno;
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1 || 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;
}
-122
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_);
-83
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_);
-95
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_);
-90
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_);
-84
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_);
+4 -3
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: mbstowcs.3,v 1.11 2010/12/16 17:42:27 wiz Exp $
.\" $NetBSD: mbstowcs.3,v 1.12 2011/03/16 09:32:12 mbalmer Exp $
.\"
.\" Copyright (c)2002 Citrus Project,
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd February 3, 2002
.Dd March 16, 2011
.Dt MBSTOWCS 3
.Os
.\" ----------------------------------------------------------------------
@@ -117,7 +117,8 @@ points to a string containing an invalid or incomplete multibyte character.
.\" ----------------------------------------------------------------------
.Sh SEE ALSO
.Xr mbtowc 3 ,
.Xr setlocale 3
.Xr setlocale 3 ,
.Xr wcstombs 3
.\" ----------------------------------------------------------------------
.Sh STANDARDS
The
-265
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;
}
+2 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: nb_lc_template.h,v 1.3 2010/05/22 13:15:59 tnozaki Exp $ */
/* $NetBSD: nb_lc_template.h,v 1.4 2012/03/04 21:14:56 tnozaki Exp $ */
/*-
* Copyright (c)1999, 2008 Citrus Project,
@@ -214,7 +214,7 @@ done:
return ret;
}
static const char *
const char *
_PREFIX(setlocale)(const char * __restrict name,
struct _locale_impl_t * __restrict locale)
{
@@ -243,6 +243,4 @@ _PREFIX(setlocale)(const char * __restrict name,
return locale->part_name[(size_t)_CATEGORY_ID];
}
#include "generic_lc_template.h"
#endif /*_NB_LC_TEMPLATE_H_*/
+3 -2
View File
@@ -1,9 +1,9 @@
.\" $NetBSD: nl_langinfo.3,v 1.19 2010/03/22 19:30:54 joerg Exp $
.\" $NetBSD: nl_langinfo.3,v 1.20 2011/04/14 05:50:49 jruoho Exp $
.\"
.\" Written by J.T. Conklin <jtc@NetBSD.org>.
.\" Public domain.
.\"
.Dd February 12, 2003
.Dd April 14, 2011
.Dt NL_LANGINFO 3
.Os
.Sh NAME
@@ -135,6 +135,7 @@ int main(void)
.\" .Ed
.Sh SEE ALSO
.Xr setlocale 3 ,
.Xr tm 3 ,
.Xr nls 7
.Sh STANDARDS
The
+7 -58
View File
@@ -1,5 +1,4 @@
/* $NetBSD: rune.c,v 1.41 2010/11/30 15:25:05 tnozaki Exp $ */
/* $NetBSD: rune.c,v 1.45 2012/08/08 20:16:50 wiz Exp $ */
/*-
* Copyright (c)2010 Citrus Project,
* All rights reserved.
@@ -47,7 +46,6 @@
#include "citrus_ctype.h"
#include "runetype_local.h"
#include "bsdctype_local.h"
#include "multibyte.h"
@@ -163,7 +161,7 @@ _rune_read_file(const char * __restrict var, size_t lenvar,
variable_len = be32toh((uint32_t)frl->frl_variable_len);
n = (len * sizeof(*fre)) + variable_len;
n = len * sizeof(*fre);
if (lenvar < n)
return EFTYPE;
lenvar -= n;
@@ -220,15 +218,15 @@ do { \
READ_RANGE(maplower);
READ_RANGE(mapupper);
memcpy((void *)rune, (void const *)frune, variable_len);
rl->rl_variable_len = variable_len;
rl->rl_variable = (void *)rune;
if (lenvar > 0) {
if (lenvar < variable_len) {
ret = EFTYPE;
goto err;
}
memcpy((void *)rune, (void const *)frune, variable_len);
rl->rl_variable_len = variable_len;
rl->rl_variable = (void *)rune;
_rune_find_codeset(rlp->rlp_codeset, sizeof(rlp->rlp_codeset),
(char *)rl->rl_variable, &rl->rl_variable_len);
@@ -280,52 +278,6 @@ err:
return ret;
}
static __inline int
_rune_read_bsdctype(const char * __restrict var, size_t lenvar,
_RuneLocale ** __restrict prl)
{
const _FileBSDCTypeLocale *fbl;
uint32_t value;
int i, bits;
uint16_t lower, upper;
_RuneLocalePriv *rlp;
_RuneLocale *rl;
if (lenvar < sizeof(*fbl))
return EFTYPE;
fbl = (const _FileBSDCTypeLocale *)(const void *)var;
if (memcmp(&fbl->fbl_id[0], _CTYPE_ID, sizeof(fbl->fbl_id)))
return EFTYPE;
value = be32toh(fbl->fbl_rev);
if (value != _CTYPE_REV)
return EFTYPE;
value = be32toh(fbl->fbl_num_chars);
if (value != _CTYPE_CACHE_SIZE)
return EFTYPE;
rlp = (_RuneLocalePriv *)malloc(sizeof(*rlp));
if (rlp == NULL)
return ENOMEM;
_rune_init_priv(rlp);
rlp->rlp_codeset[0] = '\0';
rl = &rlp->rl;
for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) {
bits = fbl->fbl_ctype_tab[i];
lower = be16toh(fbl->fbl_tolower_tab[i]);
upper = be16toh(fbl->fbl_toupper_tab[i]);
rlp->rlp_ctype_tab [i + 1] = (unsigned char)bits;
rlp->rlp_tolower_tab[i + 1] = (short)lower;
rlp->rlp_toupper_tab[i + 1] = (short)upper;
rl->rl_runetype[i] = _runetype_from_ctype(bits, i);
rl->rl_maplower[i] = (__nbrune_t)lower;
rl->rl_mapupper[i] = (__nbrune_t)upper;
}
*prl = rl;
return 0;
}
int
_rune_load(const char * __restrict var, size_t lenvar,
_RuneLocale ** __restrict prl)
@@ -341,9 +293,6 @@ _rune_load(const char * __restrict var, size_t lenvar,
case 'R':
ret = _rune_read_file(var, lenvar, prl);
break;
case 'B':
ret = _rune_read_bsdctype(var, lenvar, prl);
break;
default:
ret = EFTYPE;
}
+1 -49
View File
@@ -1,4 +1,4 @@
/* $NetBSD: runetype_misc.h,v 1.2 2010/12/14 02:28:57 joerg Exp $ */
/* $NetBSD: runetype_misc.h,v 1.3 2012/01/18 14:22:27 joerg Exp $ */
/*-
* Copyright (c) 1993
@@ -79,52 +79,4 @@ _runetype_to_ctype(_RuneType bits)
return ret;
}
static __inline _RuneType
_runetype_from_ctype(int bits, int ch)
{
_RuneType ret;
/*
* TWEAKS!
* - old locale file declarations do not have proper _B
* in many cases.
* - isprint() declaration in ctype.h incorrectly uses _B.
* _B means "isprint but !isgraph", not "isblank" with the
* declaration.
* - _X and _RUNETYPE_X have negligible difference in meaning.
* - we don't set digit value, fearing that it would be
* too much of hardcoding. we may need to revisit it.
*/
ret = (_RuneType)0;
if (bits & _CTYPE_U)
ret |= _RUNETYPE_U;
if (bits & _CTYPE_L)
ret |= _RUNETYPE_L;
if (bits & _CTYPE_N)
ret |= _RUNETYPE_D;
if (bits & _CTYPE_S)
ret |= _RUNETYPE_S;
if (bits & _CTYPE_P)
ret |= _RUNETYPE_P;
if (bits & _CTYPE_C)
ret |= _RUNETYPE_C;
/* derived flag bits, duplicate of ctype.h */
if (bits & (_CTYPE_U|_CTYPE_L))
ret |= _RUNETYPE_A;
if (bits & (_CTYPE_N|_CTYPE_X))
ret |= _RUNETYPE_X;
if (bits & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N))
ret |= _RUNETYPE_G;
/* we don't really trust _B in the file. see above. */
if (bits & _CTYPE_B)
ret |= _RUNETYPE_B;
if ((bits & (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_N|_CTYPE_B)) ||
ch == ' ')
ret |= (_RUNETYPE_R | _RUNETYPE_SW1);
if (ch == ' ' || ch == '\t')
ret |= _RUNETYPE_B;
return ret;
}
#endif /* !_RUNETYPE_MISC_H_ */
+23 -86
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.60 2012/03/04 21:14:56 tnozaki 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.60 2012/03/04 21:14:56 tnozaki Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@@ -43,81 +43,21 @@ __RCSID("$NetBSD: setlocale.c,v 1.58 2010/06/07 13:52:30 tnozaki Exp $");
const char *_PathLocale = NULL;
__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
#ifdef __minix
/* GNU binutils 2.x a.out support is rotten and link sets are not
supported. Workaround this by explicitely creating the structure
the linker was supposed to create. */
struct {
int __ls_length;
_locale_category_t *__ls_items[7];
} __link_set_all_categories = {
.__ls_length = 7,
.__ls_items = {
[0] = __UNCONST(&_generic_LC_ALL_desc),
[1] = __UNCONST(&_dummy_LC_COLLATE_desc),
#ifdef WITH_RUNE
[2] = __UNCONST(&_citrus_LC_CTYPE_desc),
[3] = __UNCONST(&_citrus_LC_MONETARY_desc),
[4] = __UNCONST(&_citrus_LC_NUMERIC_desc),
[5] = __UNCONST(&_citrus_LC_TIME_desc),
[6] = __UNCONST(&_citrus_LC_MESSAGES_desc),
#else
[2] = __UNCONST(&_localeio_LC_CTYPE_desc),
[3] = __UNCONST(&_localeio_LC_MONETARY_desc),
[4] = __UNCONST(&_localeio_LC_NUMERIC_desc),
[5] = __UNCONST(&_localeio_LC_TIME_desc),
[6] = __UNCONST(&_localeio_LC_MESSAGES_desc),
#endif
},
static _locale_set_t all_categories[_LC_LAST] = {
[LC_ALL ] = &_generic_LC_ALL_setlocale,
[LC_COLLATE ] = &_dummy_LC_COLLATE_setlocale,
[LC_CTYPE ] = &_citrus_LC_CTYPE_setlocale,
[LC_MONETARY] = &_citrus_LC_MONETARY_setlocale,
[LC_NUMERIC ] = &_citrus_LC_NUMERIC_setlocale,
[LC_TIME ] = &_citrus_LC_TIME_setlocale,
[LC_MESSAGES] = &_citrus_LC_MESSAGES_setlocale,
};
#endif /* __minix */
__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 *
_locale_set_t
_find_category(int category)
{
_locale_category_t * const *p;
__link_set_foreach(p, all_categories) {
if ((*p)->category == category)
return *p;
}
if (category >= LC_ALL && category < _LC_LAST)
return all_categories[category];
return NULL;
}
@@ -145,21 +85,18 @@ _get_locale_env(const char *category)
char *
__setlocale(int category, const char *name)
{
_locale_category_t *l;
_locale_set_t sl;
struct _locale_impl_t *impl;
if (category >= LC_ALL && category < _LC_LAST) {
l = _find_category(category);
if (l != NULL) {
if (issetugid() || ((_PathLocale == NULL &&
(_PathLocale = getenv("PATH_LOCALE")) == NULL) ||
*_PathLocale == '\0'))
_PathLocale = _PATH_LOCALE;
impl = *_current_locale();
return __UNCONST((*l->setlocale)(name, impl));
}
}
return NULL;
sl = _find_category(category);
if (sl == NULL)
return NULL;
if (issetugid() || ((_PathLocale == NULL &&
(_PathLocale = getenv("PATH_LOCALE")) == NULL) ||
*_PathLocale == '\0'))
_PathLocale = _PATH_LOCALE;
impl = *_current_locale();
return __UNCONST((*sl)(name, impl));
}
char *
+17 -8
View File
@@ -1,4 +1,4 @@
/* $NetBSD: setlocale_local.h,v 1.7 2010/06/07 13:52:30 tnozaki Exp $ */
/* $NetBSD: setlocale_local.h,v 1.8 2012/03/04 21:14:57 tnozaki Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@@ -58,17 +58,26 @@ struct _locale_impl_t {
typedef const char *(*_locale_set_t)(const char * __restrict,
struct _locale_impl_t * __restrict);
typedef struct {
const char* name;
int category;
_locale_set_t setlocale;
} _locale_category_t;
__BEGIN_DECLS
_locale_category_t *_find_category(int);
_locale_set_t _find_category(int);
const char *_get_locale_env(const char *);
struct _locale_impl_t **_current_locale(void);
char *__setlocale(int, const char *);
const char *_generic_LC_ALL_setlocale(
const char * __restrict, struct _locale_impl_t * __restrict);
const char *_dummy_LC_COLLATE_setlocale(
const char * __restrict, struct _locale_impl_t * __restrict);
const char *_citrus_LC_CTYPE_setlocale(
const char * __restrict, struct _locale_impl_t * __restrict);
const char *_citrus_LC_MONETARY_setlocale(
const char * __restrict, struct _locale_impl_t * __restrict);
const char *_citrus_LC_NUMERIC_setlocale(
const char * __restrict, struct _locale_impl_t * __restrict);
const char *_citrus_LC_TIME_setlocale(
const char * __restrict, struct _locale_impl_t * __restrict);
const char *_citrus_LC_MESSAGES_setlocale(
const char * __restrict, struct _locale_impl_t * __restrict);
__END_DECLS
static __inline struct _locale_cache_t *
+3 -4
View File
@@ -1,4 +1,4 @@
/* $NetBSD: wcscoll.c,v 1.1 2003/03/02 22:18:16 tshiozak Exp $ */
/* $NetBSD: wcscoll.c,v 1.2 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcscoll.c,v 1.1 2003/03/02 22:18:16 tshiozak Exp $");
__RCSID("$NetBSD: wcscoll.c,v 1.2 2012/06/25 22:32:44 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -40,8 +40,7 @@ __RCSID("$NetBSD: wcscoll.c,v 1.1 2003/03/02 22:18:16 tshiozak Exp $");
* Compare strings with using collating information.
*/
int
wcscoll(s1, s2)
const wchar_t *s1, *s2;
wcscoll(const wchar_t *s1, const wchar_t *s2)
{
/* XXX: LC_COLLATE should be implemented. */
return (wcscmp(s1, s2));
+4 -3
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: wcsftime.3,v 1.2 2005/04/06 21:39:17 kleink Exp $
.\" $NetBSD: wcsftime.3,v 1.3 2011/04/14 05:50:49 jruoho Exp $
.\"
.\" Copyright (c) 2002 Tim J. Robbins
.\" All rights reserved.
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD: /repoman/r/ncvs/src/lib/libc/locale/wcsftime.3,v 1.2 2002/11/29 17:35:09 ru Exp $
.\"
.Dd September 8, 2002
.Dd April 14, 2011
.Dt WCSFTIME 3
.Os
.Sh NAME
@@ -61,7 +61,8 @@ argument with type
instead of
.Vt "const wchar_t *" .
.Sh SEE ALSO
.Xr strftime 3
.Xr strftime 3 ,
.Xr tm 3
.Sh STANDARDS
The
.Fn wcsftime
+3 -2
View File
@@ -1,4 +1,4 @@
.\" $NetBSD: wcstombs.3,v 1.12 2010/12/16 17:42:27 wiz Exp $
.\" $NetBSD: wcstombs.3,v 1.13 2011/03/16 09:32:12 mbalmer Exp $
.\"
.\" Copyright (c)2002 Citrus Project,
.\" All rights reserved.
@@ -24,7 +24,7 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.Dd August 8, 2006
.Dd March 16, 2011
.Dt WCSTOMBS 3
.Os
.\" ----------------------------------------------------------------------
@@ -120,6 +120,7 @@ points to a string containing an invalid wide character.
.El
.\" ----------------------------------------------------------------------
.Sh SEE ALSO
.Xr mbstowcs 3 ,
.Xr setlocale 3 ,
.Xr wctomb 3
.\" ----------------------------------------------------------------------
+3 -6
View File
@@ -1,4 +1,4 @@
/* $NetBSD: wcsxfrm.c,v 1.2 2006/10/15 16:14:08 christos Exp $ */
/* $NetBSD: wcsxfrm.c,v 1.3 2012/06/25 22:32:44 abs Exp $ */
/*-
* Copyright (c)2003 Citrus Project,
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: wcsxfrm.c,v 1.2 2006/10/15 16:14:08 christos Exp $");
__RCSID("$NetBSD: wcsxfrm.c,v 1.3 2012/06/25 22:32:44 abs Exp $");
#endif /* LIBC_SCCS and not lint */
#include "namespace.h"
@@ -40,10 +40,7 @@ __RCSID("$NetBSD: wcsxfrm.c,v 1.2 2006/10/15 16:14:08 christos Exp $");
* Compare strings with using collating information.
*/
size_t
wcsxfrm(s1, s2, n)
wchar_t *s1;
const wchar_t *s2;
size_t n;
wcsxfrm(wchar_t *s1, const wchar_t *s2, size_t n)
{
size_t len;