diff --git a/lib/libc/citrus/citrus_lc_ctype.c b/lib/libc/citrus/citrus_lc_ctype.c index 97546fa3690f..5cfcad199ee4 100644 --- a/lib/libc/citrus/citrus_lc_ctype.c +++ b/lib/libc/citrus/citrus_lc_ctype.c @@ -1,4 +1,4 @@ -/* $NetBSD: citrus_lc_ctype.c,v 1.2 2009/01/11 02:46:24 christos Exp $ */ +/* $NetBSD: citrus_lc_ctype.c,v 1.3 2009/01/18 22:03:19 tnozaki Exp $ */ /*- * Copyright (c)2008 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.2 2009/01/11 02:46:24 christos Exp $"); +__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.3 2009/01/18 22:03:19 tnozaki Exp $"); #endif /* LIBC_SCCS and not lint */ #include "reentrant.h" @@ -109,6 +109,14 @@ _citrus_LC_CTYPE_create_impl(const char * __restrict root, _NukeRune(data); return EINVAL; } + data->rl_wctrans[_WCTRANS_INDEX_LOWER].te_name = "tolower"; + data->rl_wctrans[_WCTRANS_INDEX_LOWER].te_cached = &data->rl_maplower[0]; + data->rl_wctrans[_WCTRANS_INDEX_LOWER].te_extmap = &data->rl_maplower_ext; + + data->rl_wctrans[_WCTRANS_INDEX_UPPER].te_name = "toupper"; + data->rl_wctrans[_WCTRANS_INDEX_UPPER].te_cached = &data->rl_mapupper[0]; + data->rl_wctrans[_WCTRANS_INDEX_UPPER].te_extmap = &data->rl_mapupper_ext; + *pdata = data; return 0; } diff --git a/lib/libc/locale/_wctrans.c b/lib/libc/locale/_wctrans.c index 3f1389a5136a..76d6680439e8 100644 --- a/lib/libc/locale/_wctrans.c +++ b/lib/libc/locale/_wctrans.c @@ -1,4 +1,4 @@ -/* $NetBSD: _wctrans.c,v 1.12 2009/01/18 19:53:11 christos Exp $ */ +/* $NetBSD: _wctrans.c,v 1.13 2009/01/18 22:03:19 tnozaki Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -60,11 +60,12 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _wctrans.c,v 1.12 2009/01/18 19:53:11 christos Exp $"); +__RCSID("$NetBSD: _wctrans.c,v 1.13 2009/01/18 22:03:19 tnozaki Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" +#include #include #include #include @@ -72,21 +73,6 @@ __RCSID("$NetBSD: _wctrans.c,v 1.12 2009/01/18 19:53:11 christos Exp $"); #include "rune_local.h" #include "_wctrans_local.h" -/* - * _wctrans_init: - */ - -void -_wctrans_init(_RuneLocale *rl) -{ - rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_name = "tolower"; - rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_cached = rl->rl_maplower; - rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_extmap = &rl->rl_maplower_ext; - rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_name = "toupper"; - rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_cached = rl->rl_mapupper; - rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_extmap = &rl->rl_mapupper_ext; -} - /* * _towctrans_ext: * translate a character (extended part) diff --git a/lib/libc/locale/_wctrans_local.h b/lib/libc/locale/_wctrans_local.h index c493563d1fed..6f70eceaf6d4 100644 --- a/lib/libc/locale/_wctrans_local.h +++ b/lib/libc/locale/_wctrans_local.h @@ -1,4 +1,4 @@ -/* $NetBSD: _wctrans_local.h,v 1.6 2009/01/18 19:53:11 christos Exp $ */ +/* $NetBSD: _wctrans_local.h,v 1.7 2009/01/18 22:03:19 tnozaki Exp $ */ /*- * Copyright (c)2003 Citrus Project, @@ -31,7 +31,6 @@ __BEGIN_DECLS wint_t _towctrans_ext(wint_t, _WCTransEntry *); -void _wctrans_init(_RuneLocale *); __END_DECLS static __inline wint_t @@ -44,16 +43,16 @@ _towctrans(wint_t c, _WCTransEntry *te) static __inline struct _WCTransEntry * _wctrans_lower(_RuneLocale *rl) { - if (rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_name == NULL) - _wctrans_init(rl); + _DIAGASSERT(rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_name != NULL); + return (&rl->rl_wctrans[_WCTRANS_INDEX_LOWER]); } static __inline struct _WCTransEntry * _wctrans_upper(_RuneLocale *rl) { - if (rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_name == NULL) - _wctrans_init(rl); + _DIAGASSERT(rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_name != NULL); + return (&rl->rl_wctrans[_WCTRANS_INDEX_UPPER]); } diff --git a/lib/libc/locale/_wctype.c b/lib/libc/locale/_wctype.c index ce9081009e77..7a1817649473 100644 --- a/lib/libc/locale/_wctype.c +++ b/lib/libc/locale/_wctype.c @@ -1,4 +1,4 @@ -/* $NetBSD: _wctype.c,v 1.4 2009/01/18 19:53:11 christos Exp $ */ +/* $NetBSD: _wctype.c,v 1.5 2009/01/18 22:03:19 tnozaki Exp $ */ /*- * Copyright (c)2008 Citrus Project, @@ -60,7 +60,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _wctype.c,v 1.4 2009/01/18 19:53:11 christos Exp $"); +__RCSID("$NetBSD: _wctype.c,v 1.5 2009/01/18 22:03:19 tnozaki Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -113,6 +113,7 @@ _iswctype_priv(_RuneLocale const *rl, } wint_t +/*ARGSUSED*/ _towctrans_priv(_RuneLocale const *rl, wint_t wc, _WCTransEntry const *te) { @@ -126,8 +127,7 @@ _towctrans_priv(_RuneLocale const *rl, if (wc == WEOF) return wc; - if (te->te_name == NULL) - _wctrans_init(__UNCONST(rl)); + _DIAGASSERT(te->te_name != NULL); if (_RUNE_ISCACHED(wc)) return te->te_cached[(size_t)wc]; wc0 = (__nbrune_t)wc; diff --git a/lib/libc/locale/global_locale.c b/lib/libc/locale/global_locale.c index f3c27f27549c..e1b34ac3f8e0 100644 --- a/lib/libc/locale/global_locale.c +++ b/lib/libc/locale/global_locale.c @@ -1,4 +1,4 @@ -/* $NetBSD: global_locale.c,v 1.2 2009/01/11 02:46:28 christos Exp $ */ +/* $NetBSD: global_locale.c,v 1.3 2009/01/18 22:03:19 tnozaki Exp $ */ /*- * Copyright (c)2008 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: global_locale.c,v 1.2 2009/01/11 02:46:28 christos Exp $"); +__RCSID("$NetBSD: global_locale.c,v 1.3 2009/01/18 22:03:19 tnozaki Exp $"); #endif /* LIBC_SCCS and not lint */ #include @@ -141,7 +141,7 @@ struct _locale_impl_t _global_locale = [(size_t)ALT_DIGITS ] = NULL, }, }, - .query = /*_C_LOCALE*/ { 'C', '\0' }, + .query = { _C_LOCALE }, .part_name = { [(size_t)LC_ALL ] = _C_LOCALE, [(size_t)LC_COLLATE ] = _C_LOCALE, diff --git a/lib/libc/locale/iswctype_mb.c b/lib/libc/locale/iswctype_mb.c index 67207658da86..c0ef9a194653 100644 --- a/lib/libc/locale/iswctype_mb.c +++ b/lib/libc/locale/iswctype_mb.c @@ -1,4 +1,4 @@ -/* $NetBSD: iswctype_mb.c,v 1.4 2009/01/18 19:53:11 christos Exp $ */ +/* $NetBSD: iswctype_mb.c,v 1.5 2009/01/18 22:03:19 tnozaki Exp $ */ /*- * Copyright (c)2008 Citrus Project, @@ -28,7 +28,7 @@ #include #if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: iswctype_mb.c,v 1.4 2009/01/18 19:53:11 christos Exp $"); +__RCSID("$NetBSD: iswctype_mb.c,v 1.5 2009/01/18 22:03:19 tnozaki Exp $"); #endif /* LIBC_SCCS and not lint */ #include "namespace.h" @@ -111,9 +111,8 @@ wctrans(const char *charmap) size_t i; rl = _RUNE_LOCALE(); - if (rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_name == NULL) - _wctrans_init(__UNCONST(rl)); for (i = 0; i < _WCTRANS_NINDEXES; ++i) { + _DIAGASSERT(rl->rl_wctrans[i].te_name != NULL); if (!strcmp(rl->rl_wctrans[i].te_name, charmap)) return (wctrans_t)__UNCONST(&rl->rl_wctype[i]); } diff --git a/lib/libc/locale/rune.h b/lib/libc/locale/rune.h index de904577226e..8b1c9e4f6ed3 100644 --- a/lib/libc/locale/rune.h +++ b/lib/libc/locale/rune.h @@ -1,4 +1,4 @@ -/* $NetBSD: rune.h,v 1.16 2009/01/18 19:53:11 christos Exp $ */ +/* $NetBSD: rune.h,v 1.17 2009/01/18 22:03:19 tnozaki Exp $ */ /*- * Copyright (c) 1993 @@ -89,7 +89,7 @@ extern size_t __mb_len_max_runtime; #define __MB_LEN_MAX_RUNTIME __mb_len_max_runtime -extern _RuneLocale _DefaultRuneLocale; -extern _RuneLocale *_CurrentRuneLocale; +extern const _RuneLocale _DefaultRuneLocale; +extern const _RuneLocale *_CurrentRuneLocale; #endif /*! _RUNE_H_ */ diff --git a/lib/libc/locale/runetable.c b/lib/libc/locale/runetable.c index 5967e7451286..44ae9671f062 100644 --- a/lib/libc/locale/runetable.c +++ b/lib/libc/locale/runetable.c @@ -1,4 +1,4 @@ -/* $NetBSD: runetable.c,v 1.20 2009/01/18 19:53:11 christos Exp $ */ +/* $NetBSD: runetable.c,v 1.21 2009/01/18 22:03:19 tnozaki 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.20 2009/01/18 19:53:11 christos Exp $"); +__RCSID("$NetBSD: runetable.c,v 1.21 2009/01/18 22:03:19 tnozaki Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -54,8 +54,7 @@ __RCSID("$NetBSD: runetable.c,v 1.20 2009/01/18 19:53:11 christos Exp $"); #include "rune.h" #include "rune_local.h" -/*###57 [cc] error: conflicting type qualifiers for '_DefaultRuneLocale'%%%*/ -_RuneLocale _DefaultRuneLocale = { +const _RuneLocale _DefaultRuneLocale = { _RUNE_MAGIC_1, "NONE", _DEFAULT_INVALID_RUNE, @@ -328,8 +327,14 @@ _RuneLocale _DefaultRuneLocale = { "646", &_citrus_ctype_default, { - { NULL, NULL, NULL }, - { NULL, NULL, NULL }, + { "towlower", + __UNCONST(&_DefaultRuneLocale.rl_maplower[0]), + __UNCONST(&_DefaultRuneLocale.rl_maplower_ext) + }, + { "towupper", + __UNCONST(&_DefaultRuneLocale.rl_mapupper[0]), + __UNCONST(&_DefaultRuneLocale.rl_mapupper_ext) + }, }, { { "alnum", _CTYPE_A|_CTYPE_D }, @@ -350,5 +355,4 @@ _RuneLocale _DefaultRuneLocale = { _C_toupper_ }; -/*###352 [cc] error: conflicting types for '_CurrentRuneLocale'%%%*/ -_RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale; +const _RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale;