2000-02-18 03:39:52 +08:00
|
|
|
/*
|
|
|
|
FUNCTION
|
|
|
|
<<setlocale>>, <<localeconv>>---select or query locale
|
|
|
|
|
|
|
|
INDEX
|
|
|
|
setlocale
|
|
|
|
INDEX
|
|
|
|
localeconv
|
|
|
|
INDEX
|
|
|
|
_setlocale_r
|
|
|
|
INDEX
|
|
|
|
_localeconv_r
|
|
|
|
|
2017-11-30 15:20:53 +08:00
|
|
|
SYNOPSIS
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <locale.h>
|
|
|
|
char *setlocale(int <[category]>, const char *<[locale]>);
|
|
|
|
lconv *localeconv(void);
|
|
|
|
|
|
|
|
char *_setlocale_r(void *<[reent]>,
|
|
|
|
int <[category]>, const char *<[locale]>);
|
|
|
|
lconv *_localeconv_r(void *<[reent]>);
|
|
|
|
|
|
|
|
DESCRIPTION
|
|
|
|
<<setlocale>> is the facility defined by ANSI C to condition the
|
|
|
|
execution environment for international collating and formatting
|
|
|
|
information; <<localeconv>> reports on the settings of the current
|
|
|
|
locale.
|
|
|
|
|
2009-03-03 17:28:45 +08:00
|
|
|
This is a minimal implementation, supporting only the required <<"POSIX">>
|
|
|
|
and <<"C">> values for <[locale]>; strings representing other locales are not
|
2009-06-18 17:13:39 +08:00
|
|
|
honored unless _MB_CAPABLE is defined.
|
|
|
|
|
|
|
|
If _MB_CAPABLE is defined, POSIX locale strings are allowed, following
|
|
|
|
the form
|
|
|
|
|
|
|
|
language[_TERRITORY][.charset][@@modifier]
|
|
|
|
|
2010-01-17 22:41:58 +08:00
|
|
|
<<"language">> is a two character string per ISO 639, or, if not available
|
2010-01-17 22:57:32 +08:00
|
|
|
for a given language, a three character string per ISO 639-3.
|
2010-01-17 22:41:58 +08:00
|
|
|
<<"TERRITORY">> is a country code per ISO 3166. For <<"charset">> and
|
|
|
|
<<"modifier">> see below.
|
2009-06-18 17:13:39 +08:00
|
|
|
|
2010-02-07 02:28:33 +08:00
|
|
|
Additionally to the POSIX specifier, the following extension is supported
|
|
|
|
for backward compatibility with older implementations using newlib:
|
|
|
|
<<"C-charset">>.
|
|
|
|
Instead of <<"C-">>, you can also specify <<"C.">>. Both variations allow
|
2009-09-30 03:12:28 +08:00
|
|
|
to specify language neutral locales while using other charsets than ASCII,
|
|
|
|
for instance <<"C.UTF-8">>, which keeps all settings as in the C locale,
|
|
|
|
but uses the UTF-8 charset.
|
|
|
|
|
2010-02-07 20:57:48 +08:00
|
|
|
The following charsets are recognized:
|
2010-02-06 05:24:42 +08:00
|
|
|
<<"UTF-8">>, <<"JIS">>, <<"EUCJP">>, <<"SJIS">>, <<"KOI8-R">>, <<"KOI8-U">>,
|
2010-02-07 02:28:33 +08:00
|
|
|
<<"GEORGIAN-PS">>, <<"PT154">>, <<"TIS-620">>, <<"ISO-8859-x">> with
|
|
|
|
1 <= x <= 16, or <<"CPxxx">> with xxx in [437, 720, 737, 775, 850, 852, 855,
|
|
|
|
857, 858, 862, 866, 874, 932, 1125, 1250, 1251, 1252, 1253, 1254, 1255, 1256,
|
|
|
|
1257, 1258].
|
|
|
|
|
2009-08-25 06:11:11 +08:00
|
|
|
Charsets are case insensitive. For instance, <<"EUCJP">> and <<"eucJP">>
|
2010-02-06 05:24:42 +08:00
|
|
|
are equivalent. Charset names with dashes can also be written without
|
|
|
|
dashes, as in <<"UTF8">>, <<"iso88591">> or <<"koi8r">>. <<"EUCJP">> and
|
2010-04-23 07:32:42 +08:00
|
|
|
<<"EUCKR">> are also recognized with dash, <<"EUC-JP">> and <<"EUC-KR">>.
|
2009-08-22 04:56:13 +08:00
|
|
|
|
2010-02-07 02:28:33 +08:00
|
|
|
Full support for all of the above charsets requires that newlib has been
|
|
|
|
build with multibyte support and support for all ISO and Windows Codepage.
|
|
|
|
Otherwise all singlebyte charsets are simply mapped to ASCII. Right now,
|
|
|
|
only newlib for Cygwin is built with full charset support by default.
|
|
|
|
Under Cygwin, this implementation additionally supports the charsets
|
2010-03-28 05:04:49 +08:00
|
|
|
<<"GBK">>, <<"GB2312">>, <<"eucCN">>, <<"eucKR">>, and <<"Big5">>. Cygwin
|
|
|
|
does not support <<"JIS">>.
|
2010-02-07 02:28:33 +08:00
|
|
|
|
2010-02-07 21:52:34 +08:00
|
|
|
Cygwin additionally supports locales from the file
|
|
|
|
/usr/share/locale/locale.alias.
|
|
|
|
|
2009-03-24 18:13:27 +08:00
|
|
|
(<<"">> is also accepted; if given, the settings are read from the
|
2015-06-18 20:38:12 +08:00
|
|
|
corresponding LC_* environment variables and $LANG according to POSIX rules.)
|
2009-03-24 18:13:27 +08:00
|
|
|
|
2018-03-03 03:21:09 +08:00
|
|
|
This implementation also supports the modifiers <<"cjknarrow">> and
|
|
|
|
<<"cjkwide">>, which affect how the functions <<wcwidth>> and <<wcswidth>>
|
|
|
|
handle characters from the "CJK Ambiguous Width" category of characters
|
|
|
|
described at http://www.unicode.org/reports/tr11/#Ambiguous.
|
2020-10-08 00:35:54 +08:00
|
|
|
These characters have a width of 1 for singlebyte charsets and UTF-8,
|
|
|
|
and a width of 2 for multibyte charsets other than UTF-8. Specifying
|
|
|
|
<<"cjknarrow">> or <<"cjkwide">> forces a width of 1 or 2, respectively.
|
2009-06-18 17:13:39 +08:00
|
|
|
|
2020-02-17 07:00:00 +08:00
|
|
|
This implementation also supports the modifier <<"cjksingle">>
|
|
|
|
to enforce single-width character properties.
|
|
|
|
|
2009-06-18 17:13:39 +08:00
|
|
|
If you use <<NULL>> as the <[locale]> argument, <<setlocale>> returns a
|
|
|
|
pointer to the string representing the current locale. The acceptable
|
|
|
|
values for <[category]> are defined in `<<locale.h>>' as macros
|
|
|
|
beginning with <<"LC_">>.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
<<localeconv>> returns a pointer to a structure (also defined in
|
|
|
|
`<<locale.h>>') describing the locale-specific conventions currently
|
|
|
|
in effect.
|
|
|
|
|
|
|
|
<<_localeconv_r>> and <<_setlocale_r>> are reentrant versions of
|
|
|
|
<<localeconv>> and <<setlocale>> respectively. The extra argument
|
|
|
|
<[reent]> is a pointer to a reentrancy structure.
|
|
|
|
|
|
|
|
RETURNS
|
2009-03-03 17:28:45 +08:00
|
|
|
A successful call to <<setlocale>> returns a pointer to a string
|
|
|
|
associated with the specified category for the new locale. The string
|
|
|
|
returned by <<setlocale>> is such that a subsequent call using that
|
|
|
|
string will restore that category (or all categories in case of LC_ALL),
|
|
|
|
to that state. The application shall not modify the string returned
|
|
|
|
which may be overwritten by a subsequent call to <<setlocale>>.
|
|
|
|
On error, <<setlocale>> returns <<NULL>>.
|
2000-02-18 03:39:52 +08:00
|
|
|
|
|
|
|
<<localeconv>> returns a pointer to a structure of type <<lconv>>,
|
|
|
|
which describes the formatting and collating conventions in effect (in
|
|
|
|
this implementation, always those of the C locale).
|
|
|
|
|
|
|
|
PORTABILITY
|
|
|
|
ANSI C requires <<setlocale>>, but the only locale required across all
|
|
|
|
implementations is the C locale.
|
|
|
|
|
2009-03-24 18:13:27 +08:00
|
|
|
NOTES
|
|
|
|
There is no ISO-8859-12 codepage. It's also refused by this implementation.
|
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
No supporting OS subroutines are required.
|
|
|
|
*/
|
|
|
|
|
2009-03-03 17:28:45 +08:00
|
|
|
/* Parts of this code are originally taken from FreeBSD. */
|
2000-02-18 03:39:52 +08:00
|
|
|
/*
|
2009-03-03 17:28:45 +08:00
|
|
|
* Copyright (c) 1996 - 2002 FreeBSD Project
|
|
|
|
* Copyright (c) 1991, 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
* 4. 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.
|
2000-02-18 03:39:52 +08:00
|
|
|
*/
|
|
|
|
|
2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com>
* configure.in: Define _MB_CAPABLE if mb supported.
* configure: Regenerated.
* configure.host: Remove manual setting of MB_CAPABLE compiler
flag.
* newlib.hin: Add _MB_CAPABLE flag.
* libc/ctype/iswalpha.c, libc/ctype/iswblank.c: Include <newlib.h>
and check for _MB_CAPABLE flag instead of MB_CAPABLE.
* libc/ctype/iswcntrl.c, libc/ctype/iswprint.c: Ditto.
* libc/ctype/iswpunct.c, libc/ctype/iswspace.c: Ditto.
* libc/ctype/jp2uc.c: Ditto.
* libc/ctype/towlower.c, libc/ctype/towupper.c: Ditto.
* libc/locale/locale.c: Ditto
* libc/machine/powerpc/vfscanf.c: Ditto
* libc/stdio/vfprintf.c, libc/stdio/vfscanf.c: Ditto
* libc/stdlib/mblen.c: Ditto
* libc/stdlib/mblen_r.c, libc/stdlib/mbrlen.c: Ditto
* libc/stdlib/mbrtowc.c, libc/stdlib/mbsrtowcs.c: Ditto
* libc/stdlib/mbstowcs.c, libc/stdlib/mbtowc.c: Ditto
* libc/stdlib/mbtowc_r.c, libc/stdlib/wcrtomb.c: Ditto
* libc/stdlib/wcsrtombs.c, libc/stdlib/wcstombs.c: Ditto
* libc/stdlib/wctomb.c, libc/sys/linux/intl/dcigettext.c: Ditto
* libc/sys/linux/intl/explodename.c: Ditto
* libc/sys/linux/intl/finddomain.c: Ditto
* libc/sys/linux/intl/l10nflist.c: Ditto
* libc/sys/linux/intl/loadmsgcat.c: Ditto
* libc/sys/linux/intl/localealias.c: Ditto
2004-04-24 05:44:22 +08:00
|
|
|
#include <newlib.h>
|
2009-03-03 17:28:45 +08:00
|
|
|
#include <errno.h>
|
2000-02-18 03:39:52 +08:00
|
|
|
#include <string.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <reent.h>
|
2009-03-03 17:28:45 +08:00
|
|
|
#include <stdlib.h>
|
2009-03-24 18:13:27 +08:00
|
|
|
#include <wchar.h>
|
2016-07-13 22:51:33 +08:00
|
|
|
#include "setlocale.h"
|
2016-08-25 20:18:31 +08:00
|
|
|
#include "../ctype/ctype_.h"
|
2009-03-24 18:13:27 +08:00
|
|
|
#include "../stdlib/local.h"
|
2009-03-03 17:28:45 +08:00
|
|
|
|
2016-07-13 22:51:33 +08:00
|
|
|
#ifdef __CYGWIN__ /* Has to be kept available as exported symbol for
|
|
|
|
backward compatibility. Set it in setlocale, but
|
|
|
|
otherwise ignore it. Applications compiled after
|
|
|
|
2010 don't use it anymore. */
|
2012-03-30 04:27:15 +08:00
|
|
|
int __EXPORT __mb_cur_max = 6;
|
|
|
|
#endif
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2002-08-17 13:19:18 +08:00
|
|
|
char *_PathLocale = NULL;
|
|
|
|
|
2009-03-03 17:28:45 +08:00
|
|
|
#ifdef _MB_CAPABLE
|
|
|
|
/*
|
|
|
|
* Category names for getenv()
|
|
|
|
*/
|
|
|
|
static char *categories[_LC_LAST] = {
|
|
|
|
"LC_ALL",
|
|
|
|
"LC_COLLATE",
|
|
|
|
"LC_CTYPE",
|
|
|
|
"LC_MONETARY",
|
|
|
|
"LC_NUMERIC",
|
|
|
|
"LC_TIME",
|
|
|
|
"LC_MESSAGES",
|
|
|
|
};
|
2016-08-23 18:49:23 +08:00
|
|
|
#endif /* _MB_CAPABLE */
|
2009-03-03 17:28:45 +08:00
|
|
|
|
2009-10-09 16:25:28 +08:00
|
|
|
/*
|
|
|
|
* Default locale per POSIX. Can be overridden on a per-target base.
|
|
|
|
*/
|
|
|
|
#ifndef DEFAULT_LOCALE
|
|
|
|
#define DEFAULT_LOCALE "C"
|
|
|
|
#endif
|
2016-08-23 18:49:23 +08:00
|
|
|
|
|
|
|
#ifdef _MB_CAPABLE
|
2009-10-09 16:25:28 +08:00
|
|
|
/*
|
|
|
|
* This variable can be changed by any outside mechanism. This allows,
|
|
|
|
* for instance, to load the default locale from a file.
|
|
|
|
*/
|
|
|
|
char __default_locale[ENCODING_LEN + 1] = DEFAULT_LOCALE;
|
|
|
|
|
2016-07-23 04:54:07 +08:00
|
|
|
const struct __locale_t __C_locale =
|
|
|
|
{
|
|
|
|
{ "C", "C", "C", "C", "C", "C", "C", },
|
|
|
|
__ascii_wctomb,
|
|
|
|
__ascii_mbtowc,
|
|
|
|
0,
|
2016-08-25 20:18:31 +08:00
|
|
|
DEFAULT_CTYPE_PTR,
|
2016-07-25 17:23:36 +08:00
|
|
|
{
|
|
|
|
".", "", "", "", "", "", "", "", "", "",
|
|
|
|
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
|
|
|
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
|
|
|
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
|
|
|
CHAR_MAX, CHAR_MAX
|
|
|
|
},
|
2016-07-23 04:54:07 +08:00
|
|
|
#ifndef __HAVE_LOCALE_INFO__
|
|
|
|
"\1",
|
|
|
|
"ASCII",
|
|
|
|
"ASCII",
|
2016-08-23 18:43:40 +08:00
|
|
|
#else /* __HAVE_LOCALE_INFO__ */
|
2016-07-23 04:54:07 +08:00
|
|
|
{
|
|
|
|
{ NULL, NULL }, /* LC_ALL */
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
{ &_C_collate_locale, NULL }, /* LC_COLLATE */
|
|
|
|
#else
|
|
|
|
{ NULL, NULL }, /* LC_COLLATE */
|
|
|
|
#endif
|
|
|
|
{ &_C_ctype_locale, NULL }, /* LC_CTYPE */
|
|
|
|
{ &_C_monetary_locale, NULL }, /* LC_MONETARY */
|
|
|
|
{ &_C_numeric_locale, NULL }, /* LC_NUMERIC */
|
|
|
|
{ &_C_time_locale, NULL }, /* LC_TIME */
|
|
|
|
{ &_C_messages_locale, NULL }, /* LC_MESSAGES */
|
|
|
|
},
|
2016-08-23 18:43:40 +08:00
|
|
|
#endif /* __HAVE_LOCALE_INFO__ */
|
2016-07-23 04:54:07 +08:00
|
|
|
};
|
2016-08-23 18:49:23 +08:00
|
|
|
#endif /* _MB_CAPABLE */
|
2016-07-23 04:54:07 +08:00
|
|
|
|
2016-07-22 02:49:42 +08:00
|
|
|
struct __locale_t __global_locale =
|
2016-07-13 22:51:33 +08:00
|
|
|
{
|
|
|
|
{ "C", "C", DEFAULT_LOCALE, "C", "C", "C", "C", },
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
__utf8_wctomb,
|
|
|
|
__utf8_mbtowc,
|
|
|
|
#else
|
|
|
|
__ascii_wctomb,
|
|
|
|
__ascii_mbtowc,
|
|
|
|
#endif
|
|
|
|
0,
|
2016-08-25 20:18:31 +08:00
|
|
|
DEFAULT_CTYPE_PTR,
|
2016-07-25 17:23:36 +08:00
|
|
|
{
|
|
|
|
".", "", "", "", "", "", "", "", "", "",
|
|
|
|
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
|
|
|
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
|
|
|
CHAR_MAX, CHAR_MAX, CHAR_MAX, CHAR_MAX,
|
|
|
|
CHAR_MAX, CHAR_MAX
|
|
|
|
},
|
2016-07-13 22:51:33 +08:00
|
|
|
#ifndef __HAVE_LOCALE_INFO__
|
|
|
|
"\1",
|
|
|
|
"ASCII",
|
|
|
|
"ASCII",
|
2016-08-23 18:43:40 +08:00
|
|
|
#else /* __HAVE_LOCALE_INFO__ */
|
2016-07-23 01:57:56 +08:00
|
|
|
{
|
|
|
|
{ NULL, NULL }, /* LC_ALL */
|
2016-07-13 22:51:33 +08:00
|
|
|
#ifdef __CYGWIN__
|
2016-07-23 01:57:56 +08:00
|
|
|
{ &_C_collate_locale, NULL }, /* LC_COLLATE */
|
|
|
|
#else
|
|
|
|
{ NULL, NULL }, /* LC_COLLATE */
|
2016-07-13 22:51:33 +08:00
|
|
|
#endif
|
2016-07-23 01:57:56 +08:00
|
|
|
{ &_C_ctype_locale, NULL }, /* LC_CTYPE */
|
|
|
|
{ &_C_monetary_locale, NULL }, /* LC_MONETARY */
|
|
|
|
{ &_C_numeric_locale, NULL }, /* LC_NUMERIC */
|
|
|
|
{ &_C_time_locale, NULL }, /* LC_TIME */
|
|
|
|
{ &_C_messages_locale, NULL }, /* LC_MESSAGES */
|
|
|
|
},
|
2016-08-23 18:43:40 +08:00
|
|
|
#endif /* __HAVE_LOCALE_INFO__ */
|
2009-03-03 17:28:45 +08:00
|
|
|
};
|
|
|
|
|
2016-08-23 18:49:23 +08:00
|
|
|
#ifdef _MB_CAPABLE
|
2016-07-13 22:51:33 +08:00
|
|
|
/* Renamed from current_locale_string to make clear this is only the
|
|
|
|
*global* string for setlocale (LC_ALL, NULL). There's no equivalent
|
|
|
|
functionality for uselocale. */
|
|
|
|
static char global_locale_string[_LC_LAST * (ENCODING_LEN + 1/*"/"*/ + 1)];
|
2016-07-22 02:49:42 +08:00
|
|
|
static char *currentlocale (void);
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2010-02-07 20:57:48 +08:00
|
|
|
#endif /* _MB_CAPABLE */
|
2002-08-17 13:19:18 +08:00
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
char *
|
2017-12-04 11:43:30 +08:00
|
|
|
_setlocale_r (struct _reent *p,
|
2017-12-04 09:31:41 +08:00
|
|
|
int category,
|
2017-12-04 10:25:16 +08:00
|
|
|
const char *locale)
|
2000-02-18 03:39:52 +08:00
|
|
|
{
|
2004-04-23 Artem B. Bityuckiy <abitytsky@softminecorp.com>
* configure.in: Define _MB_CAPABLE if mb supported.
* configure: Regenerated.
* configure.host: Remove manual setting of MB_CAPABLE compiler
flag.
* newlib.hin: Add _MB_CAPABLE flag.
* libc/ctype/iswalpha.c, libc/ctype/iswblank.c: Include <newlib.h>
and check for _MB_CAPABLE flag instead of MB_CAPABLE.
* libc/ctype/iswcntrl.c, libc/ctype/iswprint.c: Ditto.
* libc/ctype/iswpunct.c, libc/ctype/iswspace.c: Ditto.
* libc/ctype/jp2uc.c: Ditto.
* libc/ctype/towlower.c, libc/ctype/towupper.c: Ditto.
* libc/locale/locale.c: Ditto
* libc/machine/powerpc/vfscanf.c: Ditto
* libc/stdio/vfprintf.c, libc/stdio/vfscanf.c: Ditto
* libc/stdlib/mblen.c: Ditto
* libc/stdlib/mblen_r.c, libc/stdlib/mbrlen.c: Ditto
* libc/stdlib/mbrtowc.c, libc/stdlib/mbsrtowcs.c: Ditto
* libc/stdlib/mbstowcs.c, libc/stdlib/mbtowc.c: Ditto
* libc/stdlib/mbtowc_r.c, libc/stdlib/wcrtomb.c: Ditto
* libc/stdlib/wcsrtombs.c, libc/stdlib/wcstombs.c: Ditto
* libc/stdlib/wctomb.c, libc/sys/linux/intl/dcigettext.c: Ditto
* libc/sys/linux/intl/explodename.c: Ditto
* libc/sys/linux/intl/finddomain.c: Ditto
* libc/sys/linux/intl/l10nflist.c: Ditto
* libc/sys/linux/intl/loadmsgcat.c: Ditto
* libc/sys/linux/intl/localealias.c: Ditto
2004-04-24 05:44:22 +08:00
|
|
|
#ifndef _MB_CAPABLE
|
2000-02-18 03:39:52 +08:00
|
|
|
if (locale)
|
|
|
|
{
|
2009-03-03 17:28:45 +08:00
|
|
|
if (strcmp (locale, "POSIX") && strcmp (locale, "C")
|
|
|
|
&& strcmp (locale, ""))
|
|
|
|
return NULL;
|
2000-02-18 03:39:52 +08:00
|
|
|
}
|
|
|
|
return "C";
|
2016-08-23 18:43:40 +08:00
|
|
|
#else /* _MB_CAPABLE */
|
2016-07-23 01:57:56 +08:00
|
|
|
static char new_categories[_LC_LAST][ENCODING_LEN + 1];
|
|
|
|
static char saved_categories[_LC_LAST][ENCODING_LEN + 1];
|
2009-03-03 17:28:45 +08:00
|
|
|
int i, j, len, saverr;
|
|
|
|
const char *env, *r;
|
2000-08-25 00:25:36 +08:00
|
|
|
|
2009-03-03 17:28:45 +08:00
|
|
|
if (category < LC_ALL || category >= _LC_LAST)
|
2000-02-18 03:39:52 +08:00
|
|
|
{
|
2009-03-03 17:28:45 +08:00
|
|
|
p->_errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (locale == NULL)
|
2016-07-23 04:40:45 +08:00
|
|
|
return category != LC_ALL ? __get_global_locale ()->categories[category]
|
|
|
|
: currentlocale();
|
2009-03-03 17:28:45 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Default to the current locale for everything.
|
|
|
|
*/
|
|
|
|
for (i = 1; i < _LC_LAST; ++i)
|
2016-07-23 04:40:45 +08:00
|
|
|
strcpy (new_categories[i], __get_global_locale ()->categories[i]);
|
2000-02-18 03:39:52 +08:00
|
|
|
|
2009-03-03 17:28:45 +08:00
|
|
|
/*
|
|
|
|
* Now go fill up new_categories from the locale argument
|
|
|
|
*/
|
|
|
|
if (!*locale)
|
|
|
|
{
|
|
|
|
if (category == LC_ALL)
|
|
|
|
{
|
|
|
|
for (i = 1; i < _LC_LAST; ++i)
|
|
|
|
{
|
|
|
|
env = __get_locale_env (p, i);
|
|
|
|
if (strlen (env) > ENCODING_LEN)
|
|
|
|
{
|
|
|
|
p->_errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
strcpy (new_categories[i], env);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
env = __get_locale_env (p, category);
|
|
|
|
if (strlen (env) > ENCODING_LEN)
|
|
|
|
{
|
|
|
|
p->_errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
strcpy (new_categories[category], env);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (category != LC_ALL)
|
|
|
|
{
|
|
|
|
if (strlen (locale) > ENCODING_LEN)
|
|
|
|
{
|
|
|
|
p->_errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
strcpy (new_categories[category], locale);
|
2000-02-18 03:39:52 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-03-03 17:28:45 +08:00
|
|
|
if ((r = strchr (locale, '/')) == NULL)
|
|
|
|
{
|
|
|
|
if (strlen (locale) > ENCODING_LEN)
|
|
|
|
{
|
|
|
|
p->_errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
for (i = 1; i < _LC_LAST; ++i)
|
|
|
|
strcpy (new_categories[i], locale);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
for (i = 1; r[1] == '/'; ++r)
|
|
|
|
;
|
|
|
|
if (!r[1])
|
|
|
|
{
|
|
|
|
p->_errno = EINVAL;
|
|
|
|
return NULL; /* Hmm, just slashes... */
|
|
|
|
}
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (i == _LC_LAST)
|
|
|
|
break; /* Too many slashes... */
|
|
|
|
if ((len = r - locale) > ENCODING_LEN)
|
|
|
|
{
|
|
|
|
p->_errno = EINVAL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
strlcpy (new_categories[i], locale, len + 1);
|
|
|
|
i++;
|
|
|
|
while (*r == '/')
|
|
|
|
r++;
|
|
|
|
locale = r;
|
|
|
|
while (*r && *r != '/')
|
|
|
|
r++;
|
|
|
|
}
|
|
|
|
while (*locale);
|
|
|
|
while (i < _LC_LAST)
|
|
|
|
{
|
|
|
|
strcpy (new_categories[i], new_categories[i-1]);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2000-02-18 03:39:52 +08:00
|
|
|
}
|
2009-03-03 17:28:45 +08:00
|
|
|
|
|
|
|
if (category != LC_ALL)
|
2016-07-24 03:40:50 +08:00
|
|
|
return __loadlocale (__get_global_locale (), category,
|
|
|
|
new_categories[category]);
|
2009-03-03 17:28:45 +08:00
|
|
|
|
|
|
|
for (i = 1; i < _LC_LAST; ++i)
|
|
|
|
{
|
2016-07-23 04:40:45 +08:00
|
|
|
strcpy (saved_categories[i], __get_global_locale ()->categories[i]);
|
2016-07-24 03:40:50 +08:00
|
|
|
if (__loadlocale (__get_global_locale (), i, new_categories[i]) == NULL)
|
2009-03-03 17:28:45 +08:00
|
|
|
{
|
|
|
|
saverr = p->_errno;
|
|
|
|
for (j = 1; j < i; j++)
|
|
|
|
{
|
|
|
|
strcpy (new_categories[j], saved_categories[j]);
|
2016-07-24 03:40:50 +08:00
|
|
|
if (__loadlocale (__get_global_locale (), j, new_categories[j])
|
2016-07-22 02:49:42 +08:00
|
|
|
== NULL)
|
2009-03-03 17:28:45 +08:00
|
|
|
{
|
|
|
|
strcpy (new_categories[j], "C");
|
2016-07-24 03:40:50 +08:00
|
|
|
__loadlocale (__get_global_locale (), j, new_categories[j]);
|
2009-03-03 17:28:45 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
p->_errno = saverr;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return currentlocale ();
|
2016-08-23 18:43:40 +08:00
|
|
|
#endif /* _MB_CAPABLE */
|
2009-03-03 17:28:45 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef _MB_CAPABLE
|
|
|
|
static char *
|
2016-07-22 02:49:42 +08:00
|
|
|
currentlocale ()
|
2009-03-03 17:28:45 +08:00
|
|
|
{
|
2016-07-23 04:40:45 +08:00
|
|
|
int i;
|
|
|
|
|
|
|
|
strcpy (global_locale_string, __get_global_locale ()->categories[1]);
|
|
|
|
|
|
|
|
for (i = 2; i < _LC_LAST; ++i)
|
|
|
|
if (strcmp (__get_global_locale ()->categories[1],
|
|
|
|
__get_global_locale ()->categories[i]))
|
|
|
|
{
|
|
|
|
for (i = 2; i < _LC_LAST; ++i)
|
|
|
|
{
|
|
|
|
(void)strcat(global_locale_string, "/");
|
|
|
|
(void)strcat(global_locale_string,
|
|
|
|
__get_global_locale ()->categories[i]);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return global_locale_string;
|
2009-03-03 17:28:45 +08:00
|
|
|
}
|
2009-03-24 18:13:27 +08:00
|
|
|
|
2016-07-22 02:49:42 +08:00
|
|
|
extern void __set_ctype (struct __locale_t *, const char *charset);
|
2009-03-31 17:31:38 +08:00
|
|
|
|
2016-07-24 03:40:50 +08:00
|
|
|
char *
|
2018-10-10 17:18:02 +08:00
|
|
|
__loadlocale (struct __locale_t *loc, int category, char *new_locale)
|
2009-03-03 17:28:45 +08:00
|
|
|
{
|
|
|
|
/* At this point a full-featured system would just load the locale
|
|
|
|
specific data from the locale files.
|
|
|
|
What we do here for now is to check the incoming string for correctness.
|
|
|
|
The string must be in one of the allowed locale strings, either
|
|
|
|
one in POSIX-style, or one in the old newlib style to maintain
|
|
|
|
backward compatibility. If the local string is correct, the charset
|
2016-07-13 22:51:33 +08:00
|
|
|
is extracted and stored in ctype_codeset or message_charset
|
2009-03-03 17:28:45 +08:00
|
|
|
dependent on the cateogry. */
|
2010-02-07 21:52:34 +08:00
|
|
|
char *locale = NULL;
|
2009-03-03 17:28:45 +08:00
|
|
|
char charset[ENCODING_LEN + 1];
|
2016-07-21 04:05:59 +08:00
|
|
|
long val = 0;
|
2010-11-19 18:02:36 +08:00
|
|
|
char *end, *c = NULL;
|
2009-03-03 17:28:45 +08:00
|
|
|
int mbc_max;
|
2016-07-21 04:05:59 +08:00
|
|
|
wctomb_p l_wctomb;
|
|
|
|
mbtowc_p l_mbtowc;
|
2020-02-17 07:00:00 +08:00
|
|
|
int cjksingle = 0;
|
2009-06-18 17:13:39 +08:00
|
|
|
int cjknarrow = 0;
|
2018-03-03 03:21:09 +08:00
|
|
|
int cjkwide = 0;
|
2010-04-28 17:59:37 +08:00
|
|
|
|
Fix duplocale (libc/locale/duplocale.c) which fails to properly call __loadlocale
Problem:
After passing locales created by 'duplocale' to 'uselocale',
referencing 'MB_CUR_MAX', which is actually expanded to
'__locale_mb_cur_max()' by preprocessors, causes segmentation faults.
Direct use of locales from 'newlocale' does not cause the problem.
This is the problem of 'duplocale'.
$ echo $LANG
ja_JP.UTF-8
$ cat test.c
#include <stdlib.h>
#include <locale.h>
volatile int var;
int main(void) {
locale_t const loc = newlocale(LC_ALL_MASK, "", NULL);
locale_t const dup = duplocale(loc);
locale_t const old = uselocale(dup);
var = MB_CUR_MAX; /* <-- crashes here */
uselocale(old);
freelocale(dup);
freelocale(loc);
return 0;
}
$ gcc test.c
$ ./a
Segmentation fault (core dumped)
# Note: "core dumped" in the above message was actually written in
# Japanese, but I translated the part to post a mail in English.
Bug:
In the beginning of '__loadlocale' (newlib/libc/locale/locale.c:501),
there is a code which checks if the operations can be skipped:
> /* Avoid doing everything twice if nothing has changed. */
> if (!strcmp (new_locale, loc->categories[category]))
> return loc->categories[category];
While, in the function '_duplocale_r' (newlib/libc/locale/
duplocale.c), '__loadlocale' is called as in the quoted codes:
> /* If the object is not a "C" locale category, copy it. Just call
> __loadlocale. It knows what to do to replicate the category. */
> tmp_locale.lc_cat[i].ptr = NULL;
> tmp_locale.lc_cat[i].buf = NULL;
> if (!__loadlocale (&tmp_locale, i, tmp_locale.categories[i]))
> goto error;
This call of '__loadlocale' results in the skip check being
!strcmp(tmp_locale.categories[i], tmp_locale.categories[i]),
which is always true. This means that the actual operations of
'__loadLocale' will never be performed for 'duplocale'.
Fix:
The call of '__loadlocale' in '_duplocale_r' is modified.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-03-12 00:27:26 +08:00
|
|
|
/* Avoid doing everything twice if nothing has changed.
|
|
|
|
|
|
|
|
duplocale relies on this test to go wrong so the locale is actually
|
|
|
|
duplicated when required. Any change here has to be synced with a
|
|
|
|
matching change in duplocale. */
|
2016-07-22 02:49:42 +08:00
|
|
|
if (!strcmp (new_locale, loc->categories[category]))
|
|
|
|
return loc->categories[category];
|
2010-04-28 17:59:37 +08:00
|
|
|
|
2010-01-22 21:03:42 +08:00
|
|
|
#ifdef __CYGWIN__
|
2010-02-26 00:10:42 +08:00
|
|
|
/* This additional code handles the case that the incoming locale string
|
|
|
|
is not valid. If so, it calls the function __set_locale_from_locale_alias,
|
|
|
|
which is only available on Cygwin right now. The function reads the
|
|
|
|
file /usr/share/locale/locale.alias. The file contains locale aliases
|
|
|
|
and their replacement locale. For instance, the alias "french" is
|
|
|
|
translated to "fr_FR.ISO-8859-1", the alias "thai" is translated to
|
|
|
|
"th_TH.TIS-620". If successful, the function returns with a pointer
|
2010-02-26 00:16:16 +08:00
|
|
|
to the second argument, which is a buffer in which the replacement locale
|
2010-02-26 00:10:42 +08:00
|
|
|
gets stored. Otherwise the function returns NULL. */
|
2010-02-07 21:52:34 +08:00
|
|
|
char tmp_locale[ENCODING_LEN + 1];
|
2010-01-22 21:03:42 +08:00
|
|
|
int ret = 0;
|
2010-02-07 21:52:34 +08:00
|
|
|
|
|
|
|
restart:
|
|
|
|
if (!locale)
|
2018-10-10 17:18:02 +08:00
|
|
|
locale = new_locale;
|
2010-02-07 21:52:34 +08:00
|
|
|
else if (locale != tmp_locale)
|
|
|
|
{
|
|
|
|
locale = __set_locale_from_locale_alias (locale, tmp_locale);
|
|
|
|
if (!locale)
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
# define FAIL goto restart
|
|
|
|
#else
|
2016-07-22 02:49:42 +08:00
|
|
|
locale = new_locale;
|
2010-02-07 21:52:34 +08:00
|
|
|
# define FAIL return NULL
|
2010-01-22 21:03:42 +08:00
|
|
|
#endif
|
2010-02-07 21:52:34 +08:00
|
|
|
|
2009-03-03 17:28:45 +08:00
|
|
|
/* "POSIX" is translated to "C", as on Linux. */
|
|
|
|
if (!strcmp (locale, "POSIX"))
|
|
|
|
strcpy (locale, "C");
|
|
|
|
if (!strcmp (locale, "C")) /* Default "C" locale */
|
2009-03-24 18:13:27 +08:00
|
|
|
strcpy (charset, "ASCII");
|
2009-09-30 03:12:28 +08:00
|
|
|
else if (locale[0] == 'C'
|
|
|
|
&& (locale[1] == '-' /* Old newlib style */
|
|
|
|
|| locale[1] == '.')) /* Extension for the C locale to allow
|
|
|
|
specifying different charsets while
|
|
|
|
sticking to the C locale in terms
|
|
|
|
of sort order, etc. Proposed in
|
|
|
|
the Debian project. */
|
2010-11-19 18:02:36 +08:00
|
|
|
{
|
|
|
|
char *chp;
|
|
|
|
|
|
|
|
c = locale + 2;
|
|
|
|
strcpy (charset, c);
|
|
|
|
if ((chp = strchr (charset, '@')))
|
|
|
|
/* Strip off modifier */
|
|
|
|
*chp = '\0';
|
|
|
|
c += strlen (charset);
|
|
|
|
}
|
2009-03-03 17:28:45 +08:00
|
|
|
else /* POSIX style */
|
|
|
|
{
|
2010-02-06 05:24:42 +08:00
|
|
|
c = locale;
|
2009-03-03 17:28:45 +08:00
|
|
|
|
|
|
|
/* Don't use ctype macros here, they might be localized. */
|
|
|
|
/* Language */
|
2009-03-23 19:28:12 +08:00
|
|
|
if (c[0] < 'a' || c[0] > 'z'
|
|
|
|
|| c[1] < 'a' || c[1] > 'z')
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-03-03 17:28:45 +08:00
|
|
|
c += 2;
|
2010-01-17 22:57:32 +08:00
|
|
|
/* Allow three character Language per ISO 639-3 */
|
2010-01-17 22:41:58 +08:00
|
|
|
if (c[0] >= 'a' && c[0] <= 'z')
|
|
|
|
++c;
|
2009-03-03 17:28:45 +08:00
|
|
|
if (c[0] == '_')
|
|
|
|
{
|
|
|
|
/* Territory */
|
|
|
|
++c;
|
2009-03-23 19:28:12 +08:00
|
|
|
if (c[0] < 'A' || c[0] > 'Z'
|
|
|
|
|| c[1] < 'A' || c[1] > 'Z')
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-03-03 17:28:45 +08:00
|
|
|
c += 2;
|
|
|
|
}
|
|
|
|
if (c[0] == '.')
|
|
|
|
{
|
|
|
|
/* Charset */
|
2009-06-18 17:13:39 +08:00
|
|
|
char *chp;
|
|
|
|
|
|
|
|
++c;
|
|
|
|
strcpy (charset, c);
|
|
|
|
if ((chp = strchr (charset, '@')))
|
2009-03-03 17:28:45 +08:00
|
|
|
/* Strip off modifier */
|
2009-06-18 17:13:39 +08:00
|
|
|
*chp = '\0';
|
|
|
|
c += strlen (charset);
|
2009-03-03 17:28:45 +08:00
|
|
|
}
|
|
|
|
else if (c[0] == '\0' || c[0] == '@')
|
|
|
|
/* End of string or just a modifier */
|
2009-03-24 18:13:27 +08:00
|
|
|
#ifdef __CYGWIN__
|
2010-02-26 00:10:42 +08:00
|
|
|
/* The Cygwin-only function __set_charset_from_locale checks
|
|
|
|
for the default charset which is connected to the given locale.
|
|
|
|
The function uses Windows functions in turn so it can't be easily
|
|
|
|
adapted to other targets. However, if any other target provides
|
|
|
|
equivalent functionality, preferrably using the same function name
|
|
|
|
it would be sufficient to change the guarding #ifdef. */
|
2010-01-22 21:03:42 +08:00
|
|
|
__set_charset_from_locale (locale, charset);
|
2009-03-24 18:13:27 +08:00
|
|
|
#else
|
2009-03-03 17:28:45 +08:00
|
|
|
strcpy (charset, "ISO-8859-1");
|
2009-03-24 18:13:27 +08:00
|
|
|
#endif
|
2009-03-03 17:28:45 +08:00
|
|
|
else
|
|
|
|
/* Invalid string */
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2010-11-19 18:02:36 +08:00
|
|
|
}
|
|
|
|
if (c && c[0] == '@')
|
|
|
|
{
|
2020-02-17 07:00:00 +08:00
|
|
|
/* Modifier "cjksingle" is recognized to enforce single-width mode. */
|
2018-03-03 03:21:09 +08:00
|
|
|
/* Modifiers "cjknarrow" or "cjkwide" are recognized to modify the
|
|
|
|
behaviour of wcwidth() and wcswidth() for East Asian languages.
|
2010-11-19 18:02:36 +08:00
|
|
|
For details see the comment at the end of this function. */
|
2020-02-17 07:00:00 +08:00
|
|
|
if (!strcmp (c + 1, "cjksingle"))
|
|
|
|
cjksingle = 1;
|
|
|
|
else if (!strcmp (c + 1, "cjknarrow"))
|
2010-11-19 18:02:36 +08:00
|
|
|
cjknarrow = 1;
|
2018-03-03 03:21:09 +08:00
|
|
|
else if (!strcmp (c + 1, "cjkwide"))
|
|
|
|
cjkwide = 1;
|
2009-03-03 17:28:45 +08:00
|
|
|
}
|
|
|
|
/* We only support this subset of charsets. */
|
|
|
|
switch (charset[0])
|
|
|
|
{
|
|
|
|
case 'U':
|
2009-08-22 04:56:13 +08:00
|
|
|
case 'u':
|
|
|
|
if (strcasecmp (charset, "UTF-8") && strcasecmp (charset, "UTF8"))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-08-22 04:56:13 +08:00
|
|
|
strcpy (charset, "UTF-8");
|
2009-03-03 17:28:45 +08:00
|
|
|
mbc_max = 6;
|
2009-03-25 21:52:08 +08:00
|
|
|
l_wctomb = __utf8_wctomb;
|
|
|
|
l_mbtowc = __utf8_mbtowc;
|
2009-03-03 17:28:45 +08:00
|
|
|
break;
|
2010-01-23 22:32:25 +08:00
|
|
|
#ifndef __CYGWIN__
|
2010-02-26 00:10:42 +08:00
|
|
|
/* Cygwin does not support JIS at all. */
|
2009-03-03 17:28:45 +08:00
|
|
|
case 'J':
|
2009-08-22 04:56:13 +08:00
|
|
|
case 'j':
|
|
|
|
if (strcasecmp (charset, "JIS"))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-08-22 04:56:13 +08:00
|
|
|
strcpy (charset, "JIS");
|
2009-03-03 17:28:45 +08:00
|
|
|
mbc_max = 8;
|
2009-03-25 21:52:08 +08:00
|
|
|
l_wctomb = __jis_wctomb;
|
|
|
|
l_mbtowc = __jis_mbtowc;
|
2009-03-03 17:28:45 +08:00
|
|
|
break;
|
2010-01-24 00:41:08 +08:00
|
|
|
#endif /* !__CYGWIN__ */
|
2009-03-03 17:28:45 +08:00
|
|
|
case 'E':
|
2009-03-25 00:56:33 +08:00
|
|
|
case 'e':
|
2010-03-28 05:04:49 +08:00
|
|
|
if (strncasecmp (charset, "EUC", 3))
|
|
|
|
FAIL;
|
|
|
|
c = charset + 3;
|
|
|
|
if (*c == '-')
|
|
|
|
++c;
|
|
|
|
if (!strcasecmp (c, "JP"))
|
2009-03-25 02:18:14 +08:00
|
|
|
{
|
|
|
|
strcpy (charset, "EUCJP");
|
2009-04-06 18:36:49 +08:00
|
|
|
mbc_max = 3;
|
2009-03-25 21:52:08 +08:00
|
|
|
l_wctomb = __eucjp_wctomb;
|
|
|
|
l_mbtowc = __eucjp_mbtowc;
|
2009-03-25 02:18:14 +08:00
|
|
|
}
|
|
|
|
#ifdef __CYGWIN__
|
2010-03-28 05:04:49 +08:00
|
|
|
/* Newlib does neither provide EUC-KR nor EUC-CN, and Cygwin's
|
|
|
|
implementation requires Windows support. */
|
|
|
|
else if (!strcasecmp (c, "KR"))
|
2009-03-25 02:18:14 +08:00
|
|
|
{
|
|
|
|
strcpy (charset, "EUCKR");
|
|
|
|
mbc_max = 2;
|
2009-03-25 21:52:08 +08:00
|
|
|
l_wctomb = __kr_wctomb;
|
|
|
|
l_mbtowc = __kr_mbtowc;
|
2009-03-25 02:18:14 +08:00
|
|
|
}
|
2010-03-28 05:04:49 +08:00
|
|
|
else if (!strcasecmp (c, "CN"))
|
|
|
|
{
|
|
|
|
strcpy (charset, "EUCCN");
|
|
|
|
mbc_max = 2;
|
|
|
|
l_wctomb = __gbk_wctomb;
|
|
|
|
l_mbtowc = __gbk_mbtowc;
|
|
|
|
}
|
2010-01-24 00:41:08 +08:00
|
|
|
#endif /* __CYGWIN__ */
|
2009-03-25 02:18:14 +08:00
|
|
|
else
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-03-03 17:28:45 +08:00
|
|
|
break;
|
|
|
|
case 'S':
|
2009-08-22 04:56:13 +08:00
|
|
|
case 's':
|
|
|
|
if (strcasecmp (charset, "SJIS"))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-08-22 04:56:13 +08:00
|
|
|
strcpy (charset, "SJIS");
|
2009-03-03 17:28:45 +08:00
|
|
|
mbc_max = 2;
|
2009-03-25 21:52:08 +08:00
|
|
|
l_wctomb = __sjis_wctomb;
|
|
|
|
l_mbtowc = __sjis_mbtowc;
|
2009-03-03 17:28:45 +08:00
|
|
|
break;
|
|
|
|
case 'I':
|
2009-08-22 04:56:13 +08:00
|
|
|
case 'i':
|
2009-03-24 18:13:27 +08:00
|
|
|
/* Must be exactly one of ISO-8859-1, [...] ISO-8859-16, except for
|
2010-02-06 05:24:42 +08:00
|
|
|
ISO-8859-12. This code also recognizes the aliases without dashes. */
|
|
|
|
if (strncasecmp (charset, "ISO", 3))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2010-02-06 05:24:42 +08:00
|
|
|
c = charset + 3;
|
|
|
|
if (*c == '-')
|
|
|
|
++c;
|
|
|
|
if (strncasecmp (c, "8859", 4))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2010-02-06 05:24:42 +08:00
|
|
|
c += 4;
|
|
|
|
if (*c == '-')
|
|
|
|
++c;
|
2016-07-22 02:49:42 +08:00
|
|
|
val = strtol (c, &end, 10);
|
2009-03-24 18:13:27 +08:00
|
|
|
if (val < 1 || val > 16 || val == 12 || *end)
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2010-02-06 05:24:42 +08:00
|
|
|
strcpy (charset, "ISO-8859-");
|
|
|
|
c = charset + 9;
|
|
|
|
if (val > 10)
|
|
|
|
*c++ = '1';
|
|
|
|
*c++ = val % 10 + '0';
|
|
|
|
*c = '\0';
|
2009-03-03 17:28:45 +08:00
|
|
|
mbc_max = 1;
|
2009-03-24 18:13:27 +08:00
|
|
|
#ifdef _MB_EXTENDED_CHARSETS_ISO
|
2016-07-21 04:05:59 +08:00
|
|
|
l_wctomb = __iso_wctomb (val);
|
|
|
|
l_mbtowc = __iso_mbtowc (val);
|
2009-03-24 18:13:27 +08:00
|
|
|
#else /* !_MB_EXTENDED_CHARSETS_ISO */
|
2009-03-25 21:52:08 +08:00
|
|
|
l_wctomb = __ascii_wctomb;
|
|
|
|
l_mbtowc = __ascii_mbtowc;
|
2009-03-24 18:13:27 +08:00
|
|
|
#endif /* _MB_EXTENDED_CHARSETS_ISO */
|
|
|
|
break;
|
|
|
|
case 'C':
|
2009-08-22 04:56:13 +08:00
|
|
|
case 'c':
|
|
|
|
if (charset[1] != 'P' && charset[1] != 'p')
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-08-22 04:56:13 +08:00
|
|
|
strncpy (charset, "CP", 2);
|
2016-07-22 02:49:42 +08:00
|
|
|
val = strtol (charset + 2, &end, 10);
|
2009-03-24 18:13:27 +08:00
|
|
|
if (*end)
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-03-24 18:13:27 +08:00
|
|
|
switch (val)
|
|
|
|
{
|
|
|
|
case 437:
|
|
|
|
case 720:
|
|
|
|
case 737:
|
|
|
|
case 775:
|
|
|
|
case 850:
|
|
|
|
case 852:
|
|
|
|
case 855:
|
|
|
|
case 857:
|
|
|
|
case 858:
|
|
|
|
case 862:
|
|
|
|
case 866:
|
|
|
|
case 874:
|
|
|
|
case 1125:
|
|
|
|
case 1250:
|
|
|
|
case 1251:
|
|
|
|
case 1252:
|
|
|
|
case 1253:
|
|
|
|
case 1254:
|
|
|
|
case 1255:
|
|
|
|
case 1256:
|
|
|
|
case 1257:
|
|
|
|
case 1258:
|
|
|
|
mbc_max = 1;
|
|
|
|
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
|
2016-07-21 04:05:59 +08:00
|
|
|
l_wctomb = __cp_wctomb (val);
|
|
|
|
l_mbtowc = __cp_mbtowc (val);
|
2009-03-24 18:13:27 +08:00
|
|
|
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */
|
2009-03-25 21:52:08 +08:00
|
|
|
l_wctomb = __ascii_wctomb;
|
|
|
|
l_mbtowc = __ascii_mbtowc;
|
2009-03-24 18:13:27 +08:00
|
|
|
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
|
2010-01-24 00:41:08 +08:00
|
|
|
break;
|
|
|
|
case 932:
|
|
|
|
mbc_max = 2;
|
|
|
|
l_wctomb = __sjis_wctomb;
|
|
|
|
l_mbtowc = __sjis_mbtowc;
|
2009-03-24 18:13:27 +08:00
|
|
|
break;
|
|
|
|
default:
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-03-24 18:13:27 +08:00
|
|
|
}
|
|
|
|
break;
|
2009-08-25 06:11:11 +08:00
|
|
|
case 'K':
|
|
|
|
case 'k':
|
2010-02-06 05:24:42 +08:00
|
|
|
/* KOI8-R, KOI8-U and the aliases without dash */
|
|
|
|
if (strncasecmp (charset, "KOI8", 4))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2010-02-06 05:24:42 +08:00
|
|
|
c = charset + 4;
|
|
|
|
if (*c == '-')
|
|
|
|
++c;
|
|
|
|
if (*c == 'R' || *c == 'r')
|
2016-07-21 04:05:59 +08:00
|
|
|
{
|
|
|
|
val = 20866;
|
|
|
|
strcpy (charset, "CP20866");
|
|
|
|
}
|
2010-02-06 05:24:42 +08:00
|
|
|
else if (*c == 'U' || *c == 'u')
|
2016-07-21 04:05:59 +08:00
|
|
|
{
|
|
|
|
val = 21866;
|
|
|
|
strcpy (charset, "CP21866");
|
|
|
|
}
|
2009-08-25 06:11:11 +08:00
|
|
|
else
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-08-26 02:47:24 +08:00
|
|
|
mbc_max = 1;
|
2009-08-25 06:11:11 +08:00
|
|
|
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
|
2016-07-21 04:05:59 +08:00
|
|
|
l_wctomb = __cp_wctomb (val);
|
|
|
|
l_mbtowc = __cp_mbtowc (val);
|
2009-08-25 06:11:11 +08:00
|
|
|
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */
|
|
|
|
l_wctomb = __ascii_wctomb;
|
|
|
|
l_mbtowc = __ascii_mbtowc;
|
|
|
|
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
|
|
|
|
break;
|
2009-03-24 18:13:27 +08:00
|
|
|
case 'A':
|
2009-08-22 04:56:13 +08:00
|
|
|
case 'a':
|
|
|
|
if (strcasecmp (charset, "ASCII"))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-08-22 04:56:13 +08:00
|
|
|
strcpy (charset, "ASCII");
|
2009-03-24 18:13:27 +08:00
|
|
|
mbc_max = 1;
|
2009-03-25 21:52:08 +08:00
|
|
|
l_wctomb = __ascii_wctomb;
|
|
|
|
l_mbtowc = __ascii_mbtowc;
|
2009-03-03 17:28:45 +08:00
|
|
|
break;
|
2009-03-24 18:13:27 +08:00
|
|
|
case 'G':
|
2009-08-22 04:56:13 +08:00
|
|
|
case 'g':
|
2010-02-07 02:28:33 +08:00
|
|
|
#ifdef __CYGWIN__
|
2010-03-28 05:04:49 +08:00
|
|
|
/* Newlib does not provide GBK/GB2312 and Cygwin's implementation
|
2010-02-26 00:10:42 +08:00
|
|
|
requires Windows support. */
|
2010-03-28 05:04:49 +08:00
|
|
|
if (!strcasecmp (charset, "GBK")
|
|
|
|
|| !strcasecmp (charset, "GB2312"))
|
2010-02-07 02:28:33 +08:00
|
|
|
{
|
2010-03-28 05:04:49 +08:00
|
|
|
strcpy (charset, charset[2] == '2' ? "GB2312" : "GBK");
|
2010-02-07 02:28:33 +08:00
|
|
|
mbc_max = 2;
|
|
|
|
l_wctomb = __gbk_wctomb;
|
|
|
|
l_mbtowc = __gbk_mbtowc;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif /* __CYGWIN__ */
|
|
|
|
/* GEORGIAN-PS and the alias without dash */
|
|
|
|
if (!strncasecmp (charset, "GEORGIAN", 8))
|
|
|
|
{
|
|
|
|
c = charset + 8;
|
|
|
|
if (*c == '-')
|
|
|
|
++c;
|
|
|
|
if (strcasecmp (c, "PS"))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2016-07-21 04:05:59 +08:00
|
|
|
val = 101;
|
2010-02-07 02:28:33 +08:00
|
|
|
strcpy (charset, "CP101");
|
|
|
|
mbc_max = 1;
|
|
|
|
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
|
2016-07-21 04:05:59 +08:00
|
|
|
l_wctomb = __cp_wctomb (val);
|
|
|
|
l_mbtowc = __cp_mbtowc (val);
|
2010-02-07 02:28:33 +08:00
|
|
|
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */
|
|
|
|
l_wctomb = __ascii_wctomb;
|
|
|
|
l_mbtowc = __ascii_mbtowc;
|
|
|
|
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
|
|
|
|
}
|
|
|
|
else
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-03-24 18:13:27 +08:00
|
|
|
break;
|
2010-02-07 02:28:33 +08:00
|
|
|
case 'P':
|
|
|
|
case 'p':
|
|
|
|
/* PT154 */
|
|
|
|
if (strcasecmp (charset, "PT154"))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2016-07-21 04:05:59 +08:00
|
|
|
val = 102;
|
2010-02-07 02:28:33 +08:00
|
|
|
strcpy (charset, "CP102");
|
|
|
|
mbc_max = 1;
|
|
|
|
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
|
2016-07-21 04:05:59 +08:00
|
|
|
l_wctomb = __cp_wctomb (val);
|
|
|
|
l_mbtowc = __cp_mbtowc (val);
|
2010-02-07 02:28:33 +08:00
|
|
|
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */
|
|
|
|
l_wctomb = __ascii_wctomb;
|
|
|
|
l_mbtowc = __ascii_mbtowc;
|
|
|
|
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
|
2010-01-23 22:32:25 +08:00
|
|
|
break;
|
|
|
|
case 'T':
|
|
|
|
case 't':
|
2010-02-07 02:28:33 +08:00
|
|
|
if (strncasecmp (charset, "TIS", 3))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2010-02-07 02:28:33 +08:00
|
|
|
c = charset + 3;
|
|
|
|
if (*c == '-')
|
|
|
|
++c;
|
2020-09-04 20:21:10 +08:00
|
|
|
if (strcmp (c, "620"))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2016-07-28 04:27:06 +08:00
|
|
|
val = 874;
|
2010-01-23 22:32:25 +08:00
|
|
|
strcpy (charset, "CP874");
|
|
|
|
mbc_max = 1;
|
2010-02-07 02:28:33 +08:00
|
|
|
#ifdef _MB_EXTENDED_CHARSETS_WINDOWS
|
2016-07-21 04:05:59 +08:00
|
|
|
l_wctomb = __cp_wctomb (val);
|
|
|
|
l_mbtowc = __cp_mbtowc (val);
|
2010-02-07 02:28:33 +08:00
|
|
|
#else /* !_MB_EXTENDED_CHARSETS_WINDOWS */
|
|
|
|
l_wctomb = __ascii_wctomb;
|
|
|
|
l_mbtowc = __ascii_mbtowc;
|
|
|
|
#endif /* _MB_EXTENDED_CHARSETS_WINDOWS */
|
|
|
|
break;
|
|
|
|
#ifdef __CYGWIN__
|
2010-02-26 00:10:42 +08:00
|
|
|
/* Newlib does not provide Big5 and Cygwin's implementation
|
|
|
|
requires Windows support. */
|
2010-02-07 02:28:33 +08:00
|
|
|
case 'B':
|
|
|
|
case 'b':
|
|
|
|
if (strcasecmp (charset, "BIG5"))
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2010-02-07 02:28:33 +08:00
|
|
|
strcpy (charset, "BIG5");
|
|
|
|
mbc_max = 2;
|
|
|
|
l_wctomb = __big5_wctomb;
|
|
|
|
l_mbtowc = __big5_mbtowc;
|
2009-03-24 18:13:27 +08:00
|
|
|
break;
|
|
|
|
#endif /* __CYGWIN__ */
|
|
|
|
default:
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2009-03-03 17:28:45 +08:00
|
|
|
}
|
2010-04-28 17:59:37 +08:00
|
|
|
switch (category)
|
2009-03-03 17:28:45 +08:00
|
|
|
{
|
2010-04-28 17:59:37 +08:00
|
|
|
case LC_CTYPE:
|
2016-07-13 22:51:33 +08:00
|
|
|
#ifndef __HAVE_LOCALE_INFO__
|
2016-07-22 02:49:42 +08:00
|
|
|
strcpy (loc->ctype_codeset, charset);
|
|
|
|
loc->mb_cur_max[0] = mbc_max;
|
2016-07-13 22:51:33 +08:00
|
|
|
#endif
|
|
|
|
#ifdef __CYGWIN__
|
|
|
|
__mb_cur_max = mbc_max; /* Only for backward compat */
|
|
|
|
#endif
|
2016-07-22 02:49:42 +08:00
|
|
|
loc->wctomb = l_wctomb;
|
|
|
|
loc->mbtowc = l_mbtowc;
|
2016-08-25 20:18:31 +08:00
|
|
|
__set_ctype (loc, charset);
|
2020-02-17 07:00:00 +08:00
|
|
|
/* Set CJK width mode (1: ambiguous-wide, 0: normal, -1: disabled). */
|
2010-11-18 19:02:53 +08:00
|
|
|
/* Determine the width for the "CJK Ambiguous Width" category of
|
|
|
|
characters. This is used in wcwidth(). Assume single width for
|
|
|
|
single-byte charsets, and double width for multi-byte charsets
|
2020-10-08 00:35:54 +08:00
|
|
|
other than UTF-8. For UTF-8, use single width.
|
2018-03-03 03:21:09 +08:00
|
|
|
Single width can also be forced with the "@cjknarrow" modifier.
|
|
|
|
Double width can also be forced with the "@cjkwide" modifier.
|
|
|
|
*/
|
|
|
|
loc->cjk_lang = cjkwide ||
|
2020-10-08 00:35:54 +08:00
|
|
|
(!cjknarrow && mbc_max > 1 && charset[0] != 'U');
|
2020-02-17 07:00:00 +08:00
|
|
|
if (cjksingle)
|
|
|
|
loc->cjk_lang = -1; /* Disable CJK dual-width */
|
2010-04-28 17:59:37 +08:00
|
|
|
#ifdef __HAVE_LOCALE_INFO__
|
2016-07-22 02:49:42 +08:00
|
|
|
ret = __ctype_load_locale (loc, locale, (void *) l_wctomb, charset,
|
|
|
|
mbc_max);
|
2010-04-28 17:59:37 +08:00
|
|
|
#endif /* __HAVE_LOCALE_INFO__ */
|
|
|
|
break;
|
|
|
|
case LC_MESSAGES:
|
2010-02-26 00:10:42 +08:00
|
|
|
#ifdef __HAVE_LOCALE_INFO__
|
2016-07-22 02:49:42 +08:00
|
|
|
ret = __messages_load_locale (loc, locale, (void *) l_wctomb, charset);
|
2010-02-09 16:58:38 +08:00
|
|
|
if (!ret)
|
2016-07-13 22:51:33 +08:00
|
|
|
#else
|
2016-07-22 02:49:42 +08:00
|
|
|
strcpy (loc->message_codeset, charset);
|
2010-02-26 00:10:42 +08:00
|
|
|
#endif /* __HAVE_LOCALE_INFO__ */
|
2010-04-28 17:59:37 +08:00
|
|
|
break;
|
2010-02-26 00:10:42 +08:00
|
|
|
#ifdef __HAVE_LOCALE_INFO__
|
2010-01-22 21:03:42 +08:00
|
|
|
#ifdef __CYGWIN__
|
2010-02-26 00:10:42 +08:00
|
|
|
/* Right now only Cygwin supports a __collate_load_locale function at all. */
|
2010-04-28 17:59:37 +08:00
|
|
|
case LC_COLLATE:
|
2016-07-22 02:49:42 +08:00
|
|
|
ret = __collate_load_locale (loc, locale, (void *) l_mbtowc, charset);
|
2010-04-28 17:59:37 +08:00
|
|
|
break;
|
2010-02-26 00:10:42 +08:00
|
|
|
#endif
|
2010-04-28 17:59:37 +08:00
|
|
|
case LC_MONETARY:
|
2016-07-22 02:49:42 +08:00
|
|
|
ret = __monetary_load_locale (loc, locale, (void *) l_wctomb, charset);
|
2010-04-28 17:59:37 +08:00
|
|
|
break;
|
|
|
|
case LC_NUMERIC:
|
2016-07-22 02:49:42 +08:00
|
|
|
ret = __numeric_load_locale (loc, locale, (void *) l_wctomb, charset);
|
2010-04-28 17:59:37 +08:00
|
|
|
break;
|
|
|
|
case LC_TIME:
|
2016-07-22 02:49:42 +08:00
|
|
|
ret = __time_load_locale (loc, locale, (void *) l_wctomb, charset);
|
2010-04-28 17:59:37 +08:00
|
|
|
break;
|
2010-05-12 04:40:14 +08:00
|
|
|
#endif /* __HAVE_LOCALE_INFO__ */
|
2010-04-28 17:59:37 +08:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2010-05-12 04:40:14 +08:00
|
|
|
#ifdef __HAVE_LOCALE_INFO__
|
2010-01-22 21:03:42 +08:00
|
|
|
if (ret)
|
2010-02-07 21:52:34 +08:00
|
|
|
FAIL;
|
2010-02-26 00:10:42 +08:00
|
|
|
#endif /* __HAVE_LOCALE_INFO__ */
|
2016-07-22 02:49:42 +08:00
|
|
|
return strcpy(loc->categories[category], new_locale);
|
2000-02-18 03:39:52 +08:00
|
|
|
}
|
|
|
|
|
2016-07-24 03:40:50 +08:00
|
|
|
const char *
|
2016-07-22 02:49:42 +08:00
|
|
|
__get_locale_env (struct _reent *p, int category)
|
2009-03-03 17:28:45 +08:00
|
|
|
{
|
|
|
|
const char *env;
|
|
|
|
|
|
|
|
/* 1. check LC_ALL. */
|
|
|
|
env = _getenv_r (p, categories[0]);
|
|
|
|
|
|
|
|
/* 2. check LC_* */
|
|
|
|
if (env == NULL || !*env)
|
|
|
|
env = _getenv_r (p, categories[category]);
|
|
|
|
|
|
|
|
/* 3. check LANG */
|
|
|
|
if (env == NULL || !*env)
|
|
|
|
env = _getenv_r (p, "LANG");
|
|
|
|
|
2009-10-09 16:25:28 +08:00
|
|
|
/* 4. if none is set, fall to default locale */
|
2009-03-03 17:28:45 +08:00
|
|
|
if (env == NULL || !*env)
|
2009-10-09 16:25:28 +08:00
|
|
|
env = __default_locale;
|
2009-03-03 17:28:45 +08:00
|
|
|
|
|
|
|
return env;
|
|
|
|
}
|
2010-02-07 20:57:48 +08:00
|
|
|
#endif /* _MB_CAPABLE */
|
2009-03-03 17:28:45 +08:00
|
|
|
|
2010-04-28 17:59:37 +08:00
|
|
|
int
|
2017-12-04 11:00:43 +08:00
|
|
|
__locale_mb_cur_max (void)
|
2010-04-28 17:59:37 +08:00
|
|
|
{
|
2016-07-13 22:51:33 +08:00
|
|
|
#ifdef __HAVE_LOCALE_INFO__
|
2010-04-28 17:59:37 +08:00
|
|
|
return __get_current_ctype_locale ()->mb_cur_max[0];
|
|
|
|
#else
|
2016-07-28 15:50:43 +08:00
|
|
|
return __get_current_locale ()->mb_cur_max[0];
|
2010-04-28 17:59:37 +08:00
|
|
|
#endif
|
2009-03-03 17:28:45 +08:00
|
|
|
}
|
|
|
|
|
2018-09-06 12:39:40 +08:00
|
|
|
#ifdef __HAVE_LOCALE_INFO__
|
2016-08-17 15:40:28 +08:00
|
|
|
const char *
|
2016-08-25 20:18:31 +08:00
|
|
|
__locale_ctype_ptr_l (struct __locale_t *locale)
|
2016-07-13 22:51:33 +08:00
|
|
|
{
|
2016-08-25 20:18:31 +08:00
|
|
|
return locale->ctype_ptr;
|
2016-07-13 22:51:33 +08:00
|
|
|
}
|
|
|
|
|
2016-08-17 15:40:28 +08:00
|
|
|
const char *
|
2016-08-25 20:18:31 +08:00
|
|
|
__locale_ctype_ptr (void)
|
2016-07-23 04:54:07 +08:00
|
|
|
{
|
2016-11-27 09:13:31 +08:00
|
|
|
return __get_current_locale ()->ctype_ptr;
|
2016-07-23 04:54:07 +08:00
|
|
|
}
|
2018-09-06 12:39:40 +08:00
|
|
|
#endif /* __HAVE_LOCALE_INFO__ */
|
2016-07-23 04:54:07 +08:00
|
|
|
|
2000-02-18 03:39:52 +08:00
|
|
|
#ifndef _REENT_ONLY
|
|
|
|
|
|
|
|
char *
|
2017-12-04 11:43:30 +08:00
|
|
|
setlocale (int category,
|
2017-12-04 10:25:16 +08:00
|
|
|
const char *locale)
|
2000-02-18 03:39:52 +08:00
|
|
|
{
|
|
|
|
return _setlocale_r (_REENT, category, locale);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|