1
0
Fork 0

Adding upstream version 1.65.7.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-05-19 21:29:57 +02:00
parent 5189956325
commit 32b8eb3fd7
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
4153 changed files with 2487292 additions and 0 deletions

122
freebsd/mblocal.h Normal file
View file

@ -0,0 +1,122 @@
// +build ingore
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright 2013 Garrett D'Amore <garrett@damore.org>
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2004 Tim J. Robbins.
* All rights reserved.
*
* Copyright (c) 2011 The FreeBSD Foundation
* All rights reserved.
* Portions of this software were developed by David Chisnall
* under sponsorship from the FreeBSD Foundation.
*
* 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.
*
* $FreeBSD$
*/
#ifndef _MBLOCAL_H_
#define _MBLOCAL_H_
#include <runetype.h>
#include "xlocale_private.h"
#define SS2 0x008e
#define SS3 0x008f
/*
* Conversion function pointers for current encoding.
*/
struct xlocale_ctype {
struct xlocale_component header;
_RuneLocale *runes;
size_t (*__mbrtowc)(wchar_t * __restrict, const char * __restrict,
size_t, mbstate_t * __restrict);
int (*__mbsinit)(const mbstate_t *);
size_t (*__mbsnrtowcs)(wchar_t * __restrict, const char ** __restrict,
size_t, size_t, mbstate_t * __restrict);
size_t (*__wcrtomb)(char * __restrict, wchar_t, mbstate_t * __restrict);
size_t (*__wcsnrtombs)(char * __restrict, const wchar_t ** __restrict,
size_t, size_t, mbstate_t * __restrict);
int __mb_cur_max;
int __mb_sb_limit;
/** Persistent state used by mblen() calls. */
__mbstate_t mblen;
/** Persistent state used by mbrlen() calls. */
__mbstate_t mbrlen;
/** Persistent state used by mbrtoc16() calls. */
__mbstate_t mbrtoc16;
/** Persistent state used by mbrtoc32() calls. */
__mbstate_t mbrtoc32;
/** Persistent state used by mbrtowc() calls. */
__mbstate_t mbrtowc;
/** Persistent state used by mbsnrtowcs() calls. */
__mbstate_t mbsnrtowcs;
/** Persistent state used by mbsrtowcs() calls. */
__mbstate_t mbsrtowcs;
/** Persistent state used by mbtowc() calls. */
__mbstate_t mbtowc;
/** Persistent state used by c16rtomb() calls. */
__mbstate_t c16rtomb;
/** Persistent state used by c32rtomb() calls. */
__mbstate_t c32rtomb;
/** Persistent state used by wcrtomb() calls. */
__mbstate_t wcrtomb;
/** Persistent state used by wcsnrtombs() calls. */
__mbstate_t wcsnrtombs;
/** Persistent state used by wcsrtombs() calls. */
__mbstate_t wcsrtombs;
/** Persistent state used by wctomb() calls. */
__mbstate_t wctomb;
};
#define XLOCALE_CTYPE(x) ((struct xlocale_ctype*)(x)->components[XLC_CTYPE])
extern struct xlocale_ctype __xlocale_global_ctype;
/*
* Rune initialization function prototypes.
*/
int _none_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _UTF8_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _EUC_CN_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _EUC_JP_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _EUC_KR_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _EUC_TW_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _GB18030_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _GB2312_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _GBK_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _BIG5_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _MSKanji_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
int _ascii_init(struct xlocale_ctype *, _RuneLocale *) __hidden;
typedef size_t (*mbrtowc_pfn_t)(wchar_t * __restrict,
const char * __restrict, size_t, mbstate_t * __restrict);
typedef size_t (*wcrtomb_pfn_t)(char * __restrict, wchar_t,
mbstate_t * __restrict);
size_t __mbsnrtowcs_std(wchar_t * __restrict, const char ** __restrict,
size_t, size_t, mbstate_t * __restrict, mbrtowc_pfn_t);
size_t __wcsnrtombs_std(char * __restrict, const wchar_t ** __restrict,
size_t, size_t, mbstate_t * __restrict, wcrtomb_pfn_t);
#endif /* _MBLOCAL_H_ */

13
freebsd/setlocale.h Normal file
View file

@ -0,0 +1,13 @@
#ifndef _SETLOCALE_H_
#define _SETLOCALE_H_
#define ENCODING_LEN 31
#define CATEGORY_LEN 11
extern char *_PathLocale;
int __detect_path_locale(void);
int __wrap_setrunelocale(const char *);
#endif /* !_SETLOCALE_H_ */

267
freebsd/table.c Normal file
View file

@ -0,0 +1,267 @@
// +build ingore
/*-
* SPDX-License-Identifier: BSD-3-Clause
*
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Paul Borman at Krystal Technologies.
*
* Copyright (c) 2011 The FreeBSD Foundation
* All rights reserved.
* Portions of this software were developed by David Chisnall
* under sponsorship from the FreeBSD Foundation.
*
* 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.
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <ctype.h>
#include <runetype.h>
#include <wchar.h>
#include "mblocal.h"
const _RuneLocale _DefaultRuneLocale = {
_RUNE_MAGIC_1,
"NONE",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 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g',
'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o',
'p', 'q', 'r', 's', 't', 'u', 'v', 'w',
'x', 'y', 'z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
},
{ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17,
0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f,
0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27,
0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f,
0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37,
0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f,
0x40, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f,
0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G',
'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W',
'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f,
0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,
0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f,
0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f,
0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7,
0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf,
0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7,
0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf,
0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7,
0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7,
0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff,
},
};
#undef _CurrentRuneLocale
const _RuneLocale *_CurrentRuneLocale = &_DefaultRuneLocale;
_RuneLocale *
__runes_for_locale(locale_t locale, int *mb_sb_limit)
{
FIX_LOCALE(locale);
struct xlocale_ctype *c = XLOCALE_CTYPE(locale);
*mb_sb_limit = c->__mb_sb_limit;
return c->runes;
}

4101
freebsd/table.cpp.c Normal file

File diff suppressed because it is too large Load diff

228
freebsd/xlocale_private.h Normal file
View file

@ -0,0 +1,228 @@
/*-
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
*
* Copyright (c) 2011 The FreeBSD Foundation
* All rights reserved.
*
* This software was developed by David Chisnall under sponsorship from
* the FreeBSD Foundation.
*
* 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.
*
* $FreeBSD$
*/
#ifndef _XLOCALE_PRIVATE__H_
#define _XLOCALE_PRIVATE__H_
#include <xlocale.h>
#include <locale.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/types.h>
#include <machine/atomic.h>
#include "setlocale.h"
/**
* The XLC_ values are indexes into the components array. They are defined in
* the same order as the LC_ values in locale.h, but without the LC_ALL zero
* value. Translating from LC_X to XLC_X is done by subtracting one.
*
* Any reordering of this enum should ensure that these invariants are not
* violated.
*/
enum {
XLC_COLLATE = 0,
XLC_CTYPE,
XLC_MONETARY,
XLC_NUMERIC,
XLC_TIME,
XLC_MESSAGES,
XLC_LAST
};
_Static_assert(XLC_LAST - XLC_COLLATE == 6, "XLC values should be contiguous");
_Static_assert(XLC_COLLATE == LC_COLLATE - 1,
"XLC_COLLATE doesn't match the LC_COLLATE value.");
_Static_assert(XLC_CTYPE == LC_CTYPE - 1,
"XLC_CTYPE doesn't match the LC_CTYPE value.");
_Static_assert(XLC_MONETARY == LC_MONETARY - 1,
"XLC_MONETARY doesn't match the LC_MONETARY value.");
_Static_assert(XLC_NUMERIC == LC_NUMERIC - 1,
"XLC_NUMERIC doesn't match the LC_NUMERIC value.");
_Static_assert(XLC_TIME == LC_TIME - 1,
"XLC_TIME doesn't match the LC_TIME value.");
_Static_assert(XLC_MESSAGES == LC_MESSAGES - 1,
"XLC_MESSAGES doesn't match the LC_MESSAGES value.");
/**
* Header used for objects that are reference counted. Objects may optionally
* have a destructor associated, which is responsible for destroying the
* structure. Global / static versions of the structure should have no
* destructor set - they can then have their reference counts manipulated as
* normal, but will not do anything with them.
*
* The header stores a retain count - objects are assumed to have a reference
* count of 1 when they are created, but the retain count is 0. When the
* retain count is less than 0, they are freed.
*/
struct xlocale_refcounted {
/** Number of references to this component. */
long retain_count;
/** Function used to destroy this component, if one is required*/
void(*destructor)(void*);
};
#define XLOCALE_DEF_VERSION_LEN 12
/**
* Header for a locale component. All locale components must begin with this
* header.
*/
struct xlocale_component {
struct xlocale_refcounted header;
/** Name of the locale used for this component. */
char locale[ENCODING_LEN+1];
/** Version of the definition for this component. */
char version[XLOCALE_DEF_VERSION_LEN];
};
/**
* xlocale structure, stores per-thread locale information.
*/
struct _xlocale {
struct xlocale_refcounted header;
/** Components for the locale. */
struct xlocale_component *components[XLC_LAST];
/** Flag indicating if components[XLC_MONETARY] has changed since the
* last call to localeconv_l() with this locale. */
int monetary_locale_changed;
/** Flag indicating whether this locale is actually using a locale for
* LC_MONETARY (1), or if it should use the C default instead (0). */
int using_monetary_locale;
/** Flag indicating if components[XLC_NUMERIC] has changed since the
* last call to localeconv_l() with this locale. */
int numeric_locale_changed;
/** Flag indicating whether this locale is actually using a locale for
* LC_NUMERIC (1), or if it should use the C default instead (0). */
int using_numeric_locale;
/** Flag indicating whether this locale is actually using a locale for
* LC_TIME (1), or if it should use the C default instead (0). */
int using_time_locale;
/** Flag indicating whether this locale is actually using a locale for
* LC_MESSAGES (1), or if it should use the C default instead (0). */
int using_messages_locale;
/** The structure to be returned from localeconv_l() for this locale. */
struct lconv lconv;
/** Buffer used by nl_langinfo_l() */
char *csym;
};
/**
* Increments the reference count of a reference-counted structure.
*/
__attribute__((unused)) static void*
xlocale_retain(void *val)
{
struct xlocale_refcounted *obj = val;
atomic_add_long(&(obj->retain_count), 1);
return (val);
}
/**
* Decrements the reference count of a reference-counted structure, freeing it
* if this is the last reference, calling its destructor if it has one.
*/
__attribute__((unused)) static void
xlocale_release(void *val)
{
struct xlocale_refcounted *obj = val;
long count;
count = atomic_fetchadd_long(&(obj->retain_count), -1) - 1;
if (count < 0 && obj->destructor != NULL)
obj->destructor(obj);
}
/**
* Load functions. Each takes the name of a locale and a pointer to the data
* to be initialised as arguments. Two special values are allowed for the
*/
extern void* __collate_load(const char*, locale_t);
extern void* __ctype_load(const char*, locale_t);
extern void* __messages_load(const char*, locale_t);
extern void* __monetary_load(const char*, locale_t);
extern void* __numeric_load(const char*, locale_t);
extern void* __time_load(const char*, locale_t);
extern struct _xlocale __xlocale_global_locale;
extern struct _xlocale __xlocale_C_locale;
/**
* Caches the rune table in TLS for fast access.
*/
void __set_thread_rune_locale(locale_t loc);
/**
* Flag indicating whether a per-thread locale has been set. If no per-thread
* locale has ever been set, then we always use the global locale.
*/
extern int __has_thread_locale;
/**
* The per-thread locale. Avoids the need to use pthread lookup functions when
* getting the per-thread locale.
*/
extern _Thread_local locale_t __thread_locale;
/**
* Returns the current locale for this thread, or the global locale if none is
* set. The caller does not have to free the locale. The return value from
* this call is not guaranteed to remain valid after the locale changes. As
* such, this should only be called within libc functions.
*/
static inline locale_t __get_locale(void)
{
if (!__has_thread_locale) {
return (&__xlocale_global_locale);
}
return (__thread_locale ? __thread_locale : &__xlocale_global_locale);
}
/**
* Two magic values are allowed for locale_t objects. NULL and -1. This
* function maps those to the real locales that they represent.
*/
static inline locale_t get_real_locale(locale_t locale)
{
switch ((intptr_t)locale) {
case 0: return (&__xlocale_C_locale);
case -1: return (&__xlocale_global_locale);
default: return (locale);
}
}
/**
* Replace a placeholder locale with the real global or thread-local locale_t.
*/
#define FIX_LOCALE(l) (l = get_real_locale(l))
#endif