PR lib/40411, nuke wctrans_init(). lazy initialization is not good idea.
statically initialized _DefaultRuneLocale.rl_wctrans field. so we can re-const-ify _DefaultRuneLocale. pkgsrc/shells/standalone-tcsh should be rebuild, because it's staticaly linked binary.
This commit is contained in:
parent
a0e618bba1
commit
db74109901
|
@ -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 <sys/cdefs.h>
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -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 <sys/cdefs.h>
|
||||
#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 <assert.h>
|
||||
#include <wctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@ -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)
|
||||
|
|
|
@ -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]);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 <sys/cdefs.h>
|
||||
#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 <assert.h>
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 <sys/cdefs.h>
|
||||
#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 <sys/types.h>
|
||||
|
@ -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,
|
||||
|
|
|
@ -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 <sys/cdefs.h>
|
||||
#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]);
|
||||
}
|
||||
|
|
|
@ -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_ */
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue