Rename fixup to update_global to better reflect the purpose.

Remove the various Current pointers, they are implementation internals
that shouldn't be leaked. Remove _CATEGORY_DEFAULT related handling and
directly pick the implemenation pointer from the C locale.
Merge the C locale data into global_locale.c with the exception of
_DefaultRuneLocale. Mark that one hidden. Move _RUNE_LOCALE and
_CITRUS_CTYPE into multibyte.h and pick up the correct rl_citrus_ctype
for non-default locales.
This commit is contained in:
joerg 2013-08-18 20:03:48 +00:00
parent e1e1d514de
commit 2933c53464
19 changed files with 145 additions and 260 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: citrus_lc_ctype.c,v 1.11 2013/04/13 10:21:20 joerg Exp $ */
/* $NetBSD: citrus_lc_ctype.c,v 1.12 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.11 2013/04/13 10:21:20 joerg Exp $");
__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.12 2013/08/18 20:03:48 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include "reentrant.h"
@ -115,7 +115,7 @@ _PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
}
static __inline void
_PREFIX(fixup)(_RuneLocale *data)
_PREFIX(update_global)(_RuneLocale *data)
{
_DIAGASSERT(data != NULL);
@ -123,7 +123,6 @@ _PREFIX(fixup)(_RuneLocale *data)
_ctype_tab_ = data->rl_ctype_tab;
_tolower_tab_ = data->rl_tolower_tab;
_toupper_tab_ = data->rl_toupper_tab;
_CurrentRuneLocale = data;
#ifdef __BUILD_LEGACY
_ctype_ = data->rl_compat_bsdctype;
@ -135,6 +134,5 @@ _PREFIX(fixup)(_RuneLocale *data)
*/
#define _CATEGORY_ID LC_CTYPE
#define _CATEGORY_NAME "LC_CTYPE"
#define _CATEGORY_DEFAULT _DefaultRuneLocale
#include "nb_lc_template.h"

View File

@ -1,11 +1,10 @@
# from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91
# $NetBSD: Makefile.inc,v 1.63 2013/05/17 12:55:57 joerg Exp $
# $NetBSD: Makefile.inc,v 1.64 2013/08/18 20:03:48 joerg Exp $
# locale sources
.PATH: ${ARCHDIR}/locale ${.CURDIR}/locale
SRCS+= _def_messages.c _def_monetary.c _def_numeric.c _def_time.c \
setlocale.c __mb_cur_max.c \
SRCS+= setlocale.c __mb_cur_max.c \
duplocale.c global_locale.c fix_grouping.c \
freelocale.c localeconv.c newlocale.c nl_langinfo.c \
generic_lc_all.c dummy_lc_collate.c \

View File

@ -1,24 +0,0 @@
/* $NetBSD: _def_messages.c,v 1.6 2005/06/12 05:21:27 lukem Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _def_messages.c,v 1.6 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <locale.h>
const _MessagesLocale _DefaultMessagesLocale =
{
"^[Yy]",
"^[Nn]",
"yes",
"no"
} ;
const _MessagesLocale *_CurrentMessagesLocale = &_DefaultMessagesLocale;

View File

@ -1,42 +0,0 @@
/* $NetBSD: _def_monetary.c,v 1.8 2005/06/12 05:21:27 lukem Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _def_monetary.c,v 1.8 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <limits.h>
#include <locale.h>
const _MonetaryLocale _DefaultMonetaryLocale =
{
"",
"",
"",
"",
"",
"",
"",
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX
};
const _MonetaryLocale *_CurrentMonetaryLocale = &_DefaultMonetaryLocale;

View File

@ -1,23 +0,0 @@
/* $NetBSD: _def_numeric.c,v 1.6 2005/06/12 05:21:27 lukem Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _def_numeric.c,v 1.6 2005/06/12 05:21:27 lukem Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <locale.h>
const _NumericLocale _DefaultNumericLocale =
{
".",
"",
""
};
const _NumericLocale *_CurrentNumericLocale = &_DefaultNumericLocale;

View File

@ -1,40 +0,0 @@
/* $NetBSD: _def_time.c,v 1.11 2013/04/21 17:45:46 joerg Exp $ */
/*
* Written by J.T. Conklin <jtc@NetBSD.org>.
* Public domain.
*/
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: _def_time.c,v 1.11 2013/04/21 17:45:46 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/localedef.h>
#include <locale.h>
const _TimeLocale _DefaultTimeLocale =
{
{
"Sun","Mon","Tue","Wed","Thu","Fri","Sat",
},
{
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"
},
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
},
{
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
},
{
"AM", "PM"
},
"%a %b %e %H:%M:%S %Y",
"%m/%d/%y",
"%H:%M:%S",
"%I:%M:%S %p"
};

View File

@ -1,4 +1,4 @@
/* $NetBSD: global_locale.c,v 1.17 2013/05/17 12:55:57 joerg Exp $ */
/* $NetBSD: global_locale.c,v 1.18 2013/08/18 20:03:48 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.17 2013/05/17 12:55:57 joerg Exp $");
__RCSID("$NetBSD: global_locale.c,v 1.18 2013/08/18 20:03:48 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -47,6 +47,69 @@ __RCSID("$NetBSD: global_locale.c,v 1.17 2013/05/17 12:55:57 joerg Exp $");
#define NBCHAR_MAX (char)CHAR_MAX
#endif
static const _MessagesLocale _DefaultMessagesLocale = {
"^[Yy]",
"^[Nn]",
"yes",
"no"
};
static const _MonetaryLocale _DefaultMonetaryLocale = {
"",
"",
"",
"",
"",
"",
"",
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX,
(char)CHAR_MAX
};
static const _NumericLocale _DefaultNumericLocale = {
".",
"",
""
};
static const _TimeLocale _DefaultTimeLocale =
{
{
"Sun","Mon","Tue","Wed","Thu","Fri","Sat",
},
{
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday"
},
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
},
{
"January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"
},
{
"AM", "PM"
},
"%a %b %e %H:%M:%S %Y",
"%m/%d/%y",
"%H:%M:%S",
"%I:%M:%S %p"
};
static const struct lconv _C_ldata = {
.decimal_point = __UNCONST("."),
.thousands_sep = __UNCONST(""),

View File

@ -1,4 +1,4 @@
/* $NetBSD: multibyte.h,v 1.5 2009/01/11 02:46:28 christos Exp $ */
/* $NetBSD: multibyte.h,v 1.6 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2002 Citrus Project,
@ -49,15 +49,14 @@ typedef union _RuneState {
} _RuneState;
#define _PRIVSIZE (sizeof(mbstate_t)-offsetof(_RuneStatePriv, __private))
#define _RUNE_LOCALE(loc) \
((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE]))
#define _CITRUS_CTYPE(loc) \
(((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE]))->rl_citrus_ctype)
/* */
static __inline _citrus_ctype_t
_to_cur_ctype(void)
{
return (_CurrentRuneLocale->rl_citrus_ctype);
}
static __inline _RuneState *
_ps_to_runestate(mbstate_t *ps)
{
@ -77,10 +76,10 @@ _ps_to_runelocale(mbstate_t const *ps)
}
static __inline _citrus_ctype_t
_ps_to_ctype(mbstate_t const *ps)
_ps_to_ctype(mbstate_t const *ps, locale_t loc)
{
if (!ps)
return _to_cur_ctype();
return _CITRUS_CTYPE(loc);
_DIAGASSERT(_ps_to_runelocale(ps) != NULL);

View File

@ -1,4 +1,4 @@
/* $NetBSD: multibyte_amd1.c,v 1.13 2013/05/28 16:57:56 joerg Exp $ */
/* $NetBSD: multibyte_amd1.c,v 1.14 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2002, 2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: multibyte_amd1.c,v 1.13 2013/05/28 16:57:56 joerg Exp $");
__RCSID("$NetBSD: multibyte_amd1.c,v 1.14 2013/08/18 20:03:48 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -47,12 +47,6 @@ __RCSID("$NetBSD: multibyte_amd1.c,v 1.13 2013/05/28 16:57:56 joerg Exp $");
#include "runetype_local.h"
#include "multibyte.h"
#define _RUNE_LOCALE(loc) \
((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE]))
#define _CITRUS_CTYPE(loc) \
(_RUNE_LOCALE(loc)->rl_citrus_ctype)
size_t
mbrlen_l(const char *s, size_t n, mbstate_t *ps, locale_t loc)
{
@ -61,7 +55,7 @@ mbrlen_l(const char *s, size_t n, mbstate_t *ps, locale_t loc)
_fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_mbrlen(_ps_to_ctype(ps), s, n,
err0 = _citrus_ctype_mbrlen(_ps_to_ctype(ps, loc), s, n,
_ps_to_private(ps), &ret);
if (err0)
errno = err0;
@ -113,7 +107,7 @@ mbrtowc_l(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps, locale_t loc)
_fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_mbrtowc(_ps_to_ctype(ps), pwc, s, n,
err0 = _citrus_ctype_mbrtowc(_ps_to_ctype(ps, loc), pwc, s, n,
_ps_to_private(ps), &ret);
if (err0)
errno = err0;
@ -136,7 +130,7 @@ mbsrtowcs_l(wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps,
_fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_mbsrtowcs(_ps_to_ctype(ps), pwcs, s, n,
err0 = _citrus_ctype_mbsrtowcs(_ps_to_ctype(ps, loc), pwcs, s, n,
_ps_to_private(ps), &ret);
if (err0)
errno = err0;
@ -159,7 +153,7 @@ mbsnrtowcs_l(wchar_t *pwcs, const char **s, size_t in, size_t n, mbstate_t *ps,
_fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_mbsnrtowcs(_ps_to_ctype(ps), pwcs, s, in, n,
err0 = _citrus_ctype_mbsnrtowcs(_ps_to_ctype(ps, loc), pwcs, s, in, n,
_ps_to_private(ps), &ret);
if (err0)
errno = err0;
@ -181,7 +175,7 @@ wcrtomb_l(char *s, wchar_t wc, mbstate_t *ps, locale_t loc)
_fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_wcrtomb(_ps_to_ctype(ps), s, wc,
err0 = _citrus_ctype_wcrtomb(_ps_to_ctype(ps, loc), s, wc,
_ps_to_private(ps), &ret);
if (err0)
errno = err0;
@ -204,7 +198,7 @@ wcsrtombs_l(char *s, const wchar_t **ppwcs, size_t n, mbstate_t *ps,
_fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_wcsrtombs(_ps_to_ctype(ps), s, ppwcs, n,
err0 = _citrus_ctype_wcsrtombs(_ps_to_ctype(ps, loc), s, ppwcs, n,
_ps_to_private(ps), &ret);
if (err0)
errno = err0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: multibyte_c90.c,v 1.11 2013/05/28 16:57:56 joerg Exp $ */
/* $NetBSD: multibyte_c90.c,v 1.12 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2002, 2008 Citrus Project,
@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
__RCSID("$NetBSD: multibyte_c90.c,v 1.11 2013/05/28 16:57:56 joerg Exp $");
__RCSID("$NetBSD: multibyte_c90.c,v 1.12 2013/08/18 20:03:48 joerg Exp $");
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -47,12 +47,6 @@ __RCSID("$NetBSD: multibyte_c90.c,v 1.11 2013/05/28 16:57:56 joerg Exp $");
#include "runetype_local.h"
#include "multibyte.h"
#define _RUNE_LOCALE(loc) \
((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE]))
#define _CITRUS_CTYPE(loc) \
(((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE]))->rl_citrus_ctype)
int
mblen_l(const char *s, size_t n, locale_t loc)
{
@ -139,7 +133,7 @@ wcsnrtombs_l(char *s, const wchar_t **ppwcs, size_t in, size_t n, mbstate_t *ps,
_fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL);
err0 = _citrus_ctype_wcsnrtombs(_ps_to_ctype(ps), s, ppwcs, in, n,
err0 = _citrus_ctype_wcsnrtombs(_ps_to_ctype(ps, loc), s, ppwcs, in, n,
_ps_to_private(ps), &ret);
if (err0)
errno = err0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: nb_lc_messages_misc.h,v 1.3 2010/03/27 15:25:22 tnozaki Exp $ */
/* $NetBSD: nb_lc_messages_misc.h,v 1.4 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -49,11 +49,8 @@ _PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
}
static __inline void
_PREFIX(fixup)(_MessagesLocale *data)
_PREFIX(update_global)(_MessagesLocale *data)
{
_DIAGASSERT(data != NULL);
_CurrentMessagesLocale = data;
}
/*
@ -61,6 +58,5 @@ _PREFIX(fixup)(_MessagesLocale *data)
*/
#define _CATEGORY_ID LC_MESSAGES
#define _CATEGORY_NAME "LC_MESSAGES"
#define _CATEGORY_DEFAULT _DefaultMessagesLocale
#endif /*_NB_LC_MESSAGES_MISC_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: nb_lc_monetary_misc.h,v 1.3 2010/03/27 15:25:22 tnozaki Exp $ */
/* $NetBSD: nb_lc_monetary_misc.h,v 1.4 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -73,11 +73,8 @@ _PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
}
static __inline void
_PREFIX(fixup)(_MonetaryLocale *data)
_PREFIX(update_global)(_MonetaryLocale *data)
{
_DIAGASSERT(data != NULL);
_CurrentMonetaryLocale = data;
}
/*
@ -85,6 +82,5 @@ _PREFIX(fixup)(_MonetaryLocale *data)
*/
#define _CATEGORY_ID LC_MONETARY
#define _CATEGORY_NAME "LC_MONETARY"
#define _CATEGORY_DEFAULT _DefaultMonetaryLocale
#endif /*_RUNE_LC_MONETARY_MISC_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: nb_lc_numeric_misc.h,v 1.3 2010/03/27 15:25:22 tnozaki Exp $ */
/* $NetBSD: nb_lc_numeric_misc.h,v 1.4 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -55,11 +55,8 @@ _PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
}
static __inline void
_PREFIX(fixup)(_NumericLocale *data)
_PREFIX(update_global)(_NumericLocale *data)
{
_DIAGASSERT(data != NULL);
_CurrentNumericLocale = data;
}
/*
@ -67,6 +64,5 @@ _PREFIX(fixup)(_NumericLocale *data)
*/
#define _CATEGORY_ID LC_NUMERIC
#define _CATEGORY_NAME "LC_NUMERIC"
#define _CATEGORY_DEFAULT _DefaultNumericLocale
#endif /*_NB_LC_NUMERIC_MISC_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: nb_lc_template.h,v 1.6 2013/05/17 12:55:57 joerg Exp $ */
/* $NetBSD: nb_lc_template.h,v 1.7 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)1999, 2008 Citrus Project,
@ -92,8 +92,6 @@
#define _nb_part_t _PREFIX(part_t)
#define _nb_part_cache _PREFIX(part_cache)
#define _nb_default_c _PREFIX(default_c)
#define _nb_default_posix _PREFIX(default_posix)
#define _nb_mutex _PREFIX(mutex)
typedef struct _nb_part_t {
@ -105,46 +103,43 @@ typedef struct _nb_part_t {
static SIMPLEQ_HEAD(, _nb_part_t) _nb_part_cache =
SIMPLEQ_HEAD_INITIALIZER(_nb_part_cache);
static const _nb_part_t _nb_default_c = {
_C_LOCALE,
__UNCONST(&_CATEGORY_DEFAULT),
{ NULL },
};
static const _nb_part_t _nb_default_posix = {
_POSIX_LOCALE,
__UNCONST(&_CATEGORY_DEFAULT),
{ NULL },
};
#ifdef _REENTRANT
static mutex_t _nb_mutex = MUTEX_INITIALIZER;
#endif
static int
_PREFIX(load_sub)(const char * __restrict name, const char * __restrict real,
_nb_part_t ** __restrict part, int force)
const char ** __restrict out_name, _CATEGORY_TYPE ** __restrict out_impl,
int force)
{
_nb_part_t *p, *q;
const char *cached_name;
_CATEGORY_TYPE *cached_impl;
_nb_part_t *p;
int ret;
_DIAGASSERT(name != NULL);
_DIAGASSERT(part != NULL);
_DIAGASSERT(out_name != NULL);
_DIAGASSERT(out_impl != NULL);
if (!strcmp(_C_LOCALE, name)) {
p = __UNCONST(&_nb_default_c);
cached_name = _lc_C_locale.part_name[_CATEGORY_ID];
cached_impl = _lc_C_locale.part_impl[_CATEGORY_ID];
} else if (!strcmp(_POSIX_LOCALE, name)) {
p = __UNCONST(&_nb_default_posix);
cached_name = _POSIX_LOCALE;
cached_impl = _lc_C_locale.part_impl[_CATEGORY_ID];
} else {
SIMPLEQ_FOREACH(p, &_nb_part_cache, entry) {
if (!strcmp((const char *)&p->name[0], name))
if (!strcmp((const char *)&p->name[0], name)) {
cached_name = p->name;
cached_impl = p->impl;
goto found;
}
}
p = malloc(sizeof(*p));
if (p == NULL)
return ENOMEM;
if (force) {
p->impl = __UNCONST(&_CATEGORY_DEFAULT);
p->impl = _lc_C_locale.part_impl[_CATEGORY_ID];
} else {
_DIAGASSERT(_PathLocale != NULL);
ret = _PREFIX(create_impl)((const char *)_PathLocale,
@ -156,24 +151,27 @@ _PREFIX(load_sub)(const char * __restrict name, const char * __restrict real,
}
strlcpy(&p->name[0], name, sizeof(p->name));
SIMPLEQ_INSERT_TAIL(&_nb_part_cache, p, entry);
cached_name = p->name;
cached_impl = p->impl;
}
found:
if (real != NULL) {
q = malloc(sizeof(*q));
if (q == NULL)
p = malloc(sizeof(*p));
if (p == NULL)
return ENOMEM;
strlcpy(&q->name[0], real, sizeof(p->name));
q->impl = p->impl;
SIMPLEQ_INSERT_TAIL(&_nb_part_cache, q, entry);
p = q;
strlcpy(&p->name[0], real, sizeof(p->name));
cached_name = p->name;
p->impl = cached_impl;
SIMPLEQ_INSERT_TAIL(&_nb_part_cache, p, entry);
}
*part = p;
*out_name = cached_name;
*out_impl = cached_impl;
return 0;
}
static __inline int
_PREFIX(load)(const char * __restrict name,
_nb_part_t ** __restrict part)
const char ** __restrict out_name, _CATEGORY_TYPE ** __restrict out_impl)
{
int ret, force;
char path[PATH_MAX + 1], loccat[PATH_MAX + 1], buf[PATH_MAX + 1];
@ -184,8 +182,10 @@ do { \
alias = __unaliasname(aliaspath, key, &buf[0], sizeof(buf)); \
if (alias != NULL) { \
ret = (force = !__isforcemapping(alias)) \
? _PREFIX(load_sub)(name, NULL, part, force) \
: _PREFIX(load_sub)(alias, name, part, force); \
? _PREFIX(load_sub)(name, NULL, out_name, out_impl, \
force) \
: _PREFIX(load_sub)(alias, name, out_name, out_impl, \
force); \
_DIAGASSERT(!ret || !force); \
goto done; \
} \
@ -193,7 +193,7 @@ do { \
/* (1) non-aliased file */
mutex_lock(&_nb_mutex);
ret = _PREFIX(load_sub)(name, NULL, part, 0);
ret = _PREFIX(load_sub)(name, NULL, out_name, out_impl, 0);
if (ret != ENOENT)
goto done;
@ -218,7 +218,8 @@ const char *
_PREFIX(setlocale)(const char * __restrict name,
struct _locale * __restrict locale)
{
_nb_part_t *part;
const char *loaded_name;
_CATEGORY_TYPE *loaded_impl;
/* name may be NULL */
_DIAGASSERT(locale != NULL);
@ -229,15 +230,13 @@ _PREFIX(setlocale)(const char * __restrict name,
_DIAGASSERT(name != NULL);
_DIAGASSERT(locale->part_name[(size_t)_CATEGORY_ID] != NULL);
if (strcmp(name, locale->part_name[(size_t)_CATEGORY_ID])) {
if (_PREFIX(load)(name, &part))
if (_PREFIX(load)(name, &loaded_name, &loaded_impl))
return NULL;
locale->part_name[(size_t)_CATEGORY_ID]
= &part->name[0];
locale->part_impl[(size_t)_CATEGORY_ID]
= part->impl;
_PREFIX(build_cache)(locale->cache, part->impl);
locale->part_name[(size_t)_CATEGORY_ID] = loaded_name;
locale->part_impl[(size_t)_CATEGORY_ID] = loaded_impl;
_PREFIX(build_cache)(locale->cache, loaded_impl);
if (locale == &_lc_global_locale)
_PREFIX(fixup)(part->impl);
_PREFIX(update_global)(loaded_impl);
}
}
return locale->part_name[(size_t)_CATEGORY_ID];

View File

@ -1,4 +1,4 @@
/* $NetBSD: nb_lc_template_decl.h,v 1.2 2009/01/11 02:46:29 christos Exp $ */
/* $NetBSD: nb_lc_template_decl.h,v 1.3 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -40,6 +40,6 @@ _PREFIX(build_cache)(struct _locale_cache_t * __restrict,
_CATEGORY_TYPE * __restrict);
static __inline void
_PREFIX(fixup)(_CATEGORY_TYPE *);
_PREFIX(update_global)(_CATEGORY_TYPE *);
#endif /*_NB_LC_TEMPLATE_DECL_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: nb_lc_time_misc.h,v 1.4 2013/04/21 17:45:46 joerg Exp $ */
/* $NetBSD: nb_lc_time_misc.h,v 1.5 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c)2008 Citrus Project,
@ -75,9 +75,8 @@ _PREFIX(build_cache)(struct _locale_cache_t * __restrict cache,
}
static __inline void
_PREFIX(fixup)(_TimeLocale *data)
_PREFIX(update_global)(_TimeLocale *data)
{
_DIAGASSERT(data != NULL);
}
/*
@ -85,6 +84,5 @@ _PREFIX(fixup)(_TimeLocale *data)
*/
#define _CATEGORY_ID LC_TIME
#define _CATEGORY_NAME "LC_TIME"
#define _CATEGORY_DEFAULT _DefaultTimeLocale
#endif /*_NB_LC_TIME_MISC_H_*/

View File

@ -1,4 +1,4 @@
/* $NetBSD: runetable.c,v 1.28 2013/04/13 10:21:21 joerg Exp $ */
/* $NetBSD: runetable.c,v 1.29 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c) 1993
@ -39,7 +39,7 @@
#if 0
static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93";
#else
__RCSID("$NetBSD: runetable.c,v 1.28 2013/04/13 10:21:21 joerg Exp $");
__RCSID("$NetBSD: runetable.c,v 1.29 2013/08/18 20:03:48 joerg Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
@ -51,7 +51,7 @@ __RCSID("$NetBSD: runetable.c,v 1.28 2013/04/13 10:21:21 joerg Exp $");
#include "citrus_ctype.h"
#include "runetype_local.h"
const _RuneLocale _DefaultRuneLocale = {
__dso_hidden const _RuneLocale _DefaultRuneLocale = {
{ /*00*/ _RUNETYPE_C,
_RUNETYPE_C,
_RUNETYPE_C,
@ -351,5 +351,3 @@ const _RuneLocale _DefaultRuneLocale = {
_C_compat_bsdctype,
#endif
};
const _RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale;

View File

@ -1,4 +1,4 @@
/* $NetBSD: runetype_local.h,v 1.13 2013/04/13 10:21:21 joerg Exp $ */
/* $NetBSD: runetype_local.h,v 1.14 2013/08/18 20:03:48 joerg Exp $ */
/*-
* Copyright (c) 1993
@ -136,8 +136,7 @@ typedef struct _RuneLocale {
/*
* global variables
*/
extern const _RuneLocale _DefaultRuneLocale;
extern const _RuneLocale *_CurrentRuneLocale;
extern __dso_hidden const _RuneLocale _DefaultRuneLocale;
__BEGIN_DECLS
int _rune_load(const char * __restrict, size_t, _RuneLocale ** __restrict);

View File

@ -1,4 +1,4 @@
/* $NetBSD: localedef.h,v 1.9 2008/05/17 03:49:54 ginsbach Exp $ */
/* $NetBSD: localedef.h,v 1.10 2013/08/18 20:03:48 joerg Exp $ */
/*
* Copyright (c) 1994 Winning Strategies, Inc.
@ -40,10 +40,6 @@ typedef struct {
const char *nostr;
} _MessagesLocale;
extern const _MessagesLocale *_CurrentMessagesLocale;
extern const _MessagesLocale _DefaultMessagesLocale;
typedef struct {
const char *int_curr_symbol;
const char *currency_symbol;
@ -68,20 +64,12 @@ typedef struct {
char int_n_sign_posn;
} _MonetaryLocale;
extern const _MonetaryLocale *_CurrentMonetaryLocale;
extern const _MonetaryLocale _DefaultMonetaryLocale;
typedef struct {
const char *decimal_point;
const char *thousands_sep;
const char *grouping;
} _NumericLocale;
extern const _NumericLocale *_CurrentNumericLocale;
extern const _NumericLocale _DefaultNumericLocale;
typedef struct {
const char *abday[7];
const char *day[7];
@ -94,7 +82,4 @@ typedef struct {
const char *t_fmt_ampm;
} _TimeLocale;
extern const _TimeLocale *_CurrentTimeLocale;
extern const _TimeLocale _DefaultTimeLocale;
#endif /* !_SYS_LOCALEDEF_H_ */