aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'newlib/libc')
-rw-r--r--newlib/libc/locale/lctype.c11
-rw-r--r--newlib/libc/locale/lctype.h48
-rw-r--r--newlib/libc/locale/lmessages.c11
-rw-r--r--newlib/libc/locale/lmessages.h58
-rw-r--r--newlib/libc/locale/lmonetary.c11
-rw-r--r--newlib/libc/locale/lmonetary.h77
-rw-r--r--newlib/libc/locale/lnumeric.c11
-rw-r--r--newlib/libc/locale/lnumeric.h55
-rw-r--r--newlib/libc/locale/locale.c25
-rw-r--r--newlib/libc/locale/nl_langinfo.c13
-rw-r--r--newlib/libc/locale/setlocale.h235
-rw-r--r--newlib/libc/locale/timelocal.c11
-rw-r--r--newlib/libc/locale/timelocal.h86
-rw-r--r--newlib/libc/stdio/vfwprintf.c2
-rw-r--r--newlib/libc/stdio/vfwscanf.c2
-rw-r--r--newlib/libc/time/strftime.c4
-rw-r--r--newlib/libc/time/strptime.c4
17 files changed, 235 insertions, 429 deletions
diff --git a/newlib/libc/locale/lctype.c b/newlib/libc/locale/lctype.c
index a776ee0..d59ae37 100644
--- a/newlib/libc/locale/lctype.c
+++ b/newlib/libc/locale/lctype.c
@@ -28,7 +28,7 @@
static char numone[] = { '\1', '\0'};
-static const struct lc_ctype_T _C_ctype_locale = {
+const struct lc_ctype_T _C_ctype_locale = {
"ASCII", /* codeset */
numone /* mb_cur_max */
#ifdef __HAVE_LOCALE_INFO_EXTENDED__
@@ -77,7 +77,7 @@ __ctype_load_locale (struct _thr_locale_t *locale, const char *name,
return -1;
memcpy (ctp, &ct, sizeof *ctp);
}
- locale->ctype = ret == 0 ? NULL : ctp;
+ locale->ctype = ret == 0 ? &_C_ctype_locale : ctp;
if (locale->ctype_buf)
free (locale->ctype_buf);
locale->ctype_buf = bufp;
@@ -118,10 +118,3 @@ __ctype_load_locale (struct _thr_locale_t *locale, const char *name,
#endif
return ret;
}
-
-struct lc_ctype_T *
-__get_current_ctype_locale (void)
-{
- struct _thr_locale_t *cur_locale = __get_current_locale ();
- return cur_locale->ctype ?: (struct lc_ctype_T *) &_C_ctype_locale;
-}
diff --git a/newlib/libc/locale/lctype.h b/newlib/libc/locale/lctype.h
deleted file mode 100644
index ead08c5..0000000
--- a/newlib/libc/locale/lctype.h
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.
- */
-
-#ifndef _LCTYPE_H_
-#define _LCTYPE_H_
-
-#include <_ansi.h>
-#include <sys/cdefs.h>
-#include <wchar.h>
-
-__BEGIN_DECLS
-
-struct lc_ctype_T {
- const char *codeset; /* codeset for mbtowc conversion */
- const char *mb_cur_max;
-#ifdef __HAVE_LOCALE_INFO_EXTENDED__
- const char *outdigits[10];
- const wchar_t *woutdigits[10];
-#endif
-};
-
-struct lc_ctype_T *__get_current_ctype_locale (void);
-int __ctype_load_locale (struct _thr_locale_t *, const char *, void *,
- const char *, int);
-
-__END_DECLS
-
-#endif /* !_LCTYPE_H_ */
diff --git a/newlib/libc/locale/lmessages.c b/newlib/libc/locale/lmessages.c
index 7d9096e..c768e45 100644
--- a/newlib/libc/locale/lmessages.c
+++ b/newlib/libc/locale/lmessages.c
@@ -39,7 +39,7 @@
static char empty[] = "";
#endif
-static const struct lc_messages_T _C_messages_locale = {
+const struct lc_messages_T _C_messages_locale = {
"^[yY]" , /* yesexpr */
"^[nN]" , /* noexpr */
"yes" , /* yesstr */
@@ -87,7 +87,7 @@ __messages_load_locale (struct _thr_locale_t *locale, const char *name,
return -1;
memcpy (mep, &me, sizeof *mep);
}
- locale->messages = ret == 0 ? NULL : mep;
+ locale->messages = ret == 0 ? &_C_messages_locale : mep;
if (locale->messages_buf)
free (locale->messages_buf);
locale->messages_buf = bufp;
@@ -110,13 +110,6 @@ __messages_load_locale (struct _thr_locale_t *locale, const char *name,
return ret;
}
-struct lc_messages_T *
-__get_current_messages_locale (void)
-{
- struct _thr_locale_t *cur_locale = __get_current_locale ();
- return cur_locale->messages ?: (struct lc_messages_T *) &_C_messages_locale;
-}
-
#ifdef LOCALE_DEBUG
void
msgdebug() {
diff --git a/newlib/libc/locale/lmessages.h b/newlib/libc/locale/lmessages.h
deleted file mode 100644
index 242a67e..0000000
--- a/newlib/libc/locale/lmessages.h
+++ /dev/null
@@ -1,58 +0,0 @@
-/*-
- * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
- * All rights reserved.
- *
- * 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: src/lib/libc/locale/lmessages.h,v 1.3 2001/12/20 18:28:52 phantom Exp $
- */
-
-#ifndef _LMESSAGES_H_
-#define _LMESSAGES_H_
-
-#include <_ansi.h>
-#include <sys/cdefs.h>
-#include <wchar.h>
-
-__BEGIN_DECLS
-
-struct lc_messages_T {
- const char *yesexpr;
- const char *noexpr;
- const char *yesstr;
- const char *nostr;
-#ifdef __HAVE_LOCALE_INFO_EXTENDED__
- const char *codeset; /* codeset for mbtowc conversion */
- const wchar_t *wyesexpr;
- const wchar_t *wnoexpr;
- const wchar_t *wyesstr;
- const wchar_t *wnostr;
-#endif
-};
-
-struct lc_messages_T *__get_current_messages_locale (void);
-int __messages_load_locale (struct _thr_locale_t *, const char *, void *,
- const char *);
-
-__END_DECLS
-
-#endif /* !_LMESSAGES_H_ */
diff --git a/newlib/libc/locale/lmonetary.c b/newlib/libc/locale/lmonetary.c
index 344a6d8..32e5ee5 100644
--- a/newlib/libc/locale/lmonetary.c
+++ b/newlib/libc/locale/lmonetary.c
@@ -41,7 +41,7 @@ static char numempty[] = { CHAR_MAX, '\0'};
static wchar_t wempty[] = L"";
#endif
-static const struct lc_monetary_T _C_monetary_locale = {
+const struct lc_monetary_T _C_monetary_locale = {
empty, /* int_curr_symbol */
empty, /* currency_symbol */
empty, /* mon_decimal_point */
@@ -115,7 +115,7 @@ __monetary_load_locale (struct _thr_locale_t *locale, const char *name ,
return -1;
memcpy (mop, &mo, sizeof *mop);
}
- locale->monetary = ret == 0 ? NULL : mop;
+ locale->monetary = ret == 0 ? &_C_monetary_locale : mop;
if (locale->monetary_buf)
free (locale->monetary_buf);
locale->monetary_buf = bufp;
@@ -145,10 +145,3 @@ __monetary_load_locale (struct _thr_locale_t *locale, const char *name ,
#endif
return ret;
}
-
-struct lc_monetary_T *
-__get_current_monetary_locale (void)
-{
- struct _thr_locale_t *cur_locale = __get_current_locale ();
- return cur_locale->monetary ?: (struct lc_monetary_T *) &_C_monetary_locale;
-}
diff --git a/newlib/libc/locale/lmonetary.h b/newlib/libc/locale/lmonetary.h
deleted file mode 100644
index 98000d6..0000000
--- a/newlib/libc/locale/lmonetary.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
- * All rights reserved.
- *
- * 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: src/lib/libc/locale/lmonetary.h,v 1.3 2001/12/20 18:28:52 phantom Exp $
- */
-
-#ifndef _LMONETARY_H_
-#define _LMONETARY_H_
-
-#include <_ansi.h>
-#include <sys/cdefs.h>
-#include <wchar.h>
-
-__BEGIN_DECLS
-
-struct lc_monetary_T {
- const char *int_curr_symbol;
- const char *currency_symbol;
- const char *mon_decimal_point;
- const char *mon_thousands_sep;
- const char *mon_grouping;
- const char *positive_sign;
- const char *negative_sign;
- const char *int_frac_digits;
- const char *frac_digits;
- const char *p_cs_precedes;
- const char *p_sep_by_space;
- const char *n_cs_precedes;
- const char *n_sep_by_space;
- const char *p_sign_posn;
- const char *n_sign_posn;
-#ifdef __HAVE_LOCALE_INFO_EXTENDED__
- const char *int_p_cs_precedes;
- const char *int_p_sep_by_space;
- const char *int_n_cs_precedes;
- const char *int_n_sep_by_space;
- const char *int_p_sign_posn;
- const char *int_n_sign_posn;
- const char *codeset; /* codeset for mbtowc conversion */
- const wchar_t *wint_curr_symbol;
- const wchar_t *wcurrency_symbol;
- const wchar_t *wmon_decimal_point;
- const wchar_t *wmon_thousands_sep;
- const wchar_t *wpositive_sign;
- const wchar_t *wnegative_sign;
-#endif
-};
-
-struct lc_monetary_T *__get_current_monetary_locale (void);
-int __monetary_load_locale (struct _thr_locale_t *, const char *, void *,
- const char *);
-
-__END_DECLS
-
-#endif /* !_LMONETARY_H_ */
diff --git a/newlib/libc/locale/lnumeric.c b/newlib/libc/locale/lnumeric.c
index f74c446..0e56f16 100644
--- a/newlib/libc/locale/lnumeric.c
+++ b/newlib/libc/locale/lnumeric.c
@@ -33,7 +33,7 @@ extern const char *__fix_locale_grouping_str(const char *);
static char numempty[] = { CHAR_MAX, '\0' };
-static const struct lc_numeric_T _C_numeric_locale = {
+const struct lc_numeric_T _C_numeric_locale = {
".", /* decimal_point */
"", /* thousands_sep */
numempty /* grouping */
@@ -77,7 +77,7 @@ __numeric_load_locale (struct _thr_locale_t *locale, const char *name ,
return -1;
memcpy (nmp, &nm, sizeof *nmp);
}
- locale->numeric = ret == 0 ? NULL : nmp;
+ locale->numeric = ret == 0 ? &_C_numeric_locale : nmp;
if (locale->numeric_buf)
free (locale->numeric_buf);
locale->numeric_buf = bufp;
@@ -94,10 +94,3 @@ __numeric_load_locale (struct _thr_locale_t *locale, const char *name ,
#endif
return ret;
}
-
-struct lc_numeric_T *
-__get_current_numeric_locale (void)
-{
- struct _thr_locale_t *cur_locale = __get_current_locale ();
- return cur_locale->numeric ?: (struct lc_numeric_T *) &_C_numeric_locale;
-}
diff --git a/newlib/libc/locale/lnumeric.h b/newlib/libc/locale/lnumeric.h
deleted file mode 100644
index 8a41966..0000000
--- a/newlib/libc/locale/lnumeric.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*-
- * Copyright (c) 2000, 2001 Alexey Zelkin <phantom@FreeBSD.org>
- * All rights reserved.
- *
- * 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: src/lib/libc/locale/lnumeric.h,v 1.3 2001/12/20 18:28:52 phantom Exp $
- */
-
-#ifndef _LNUMERIC_H_
-#define _LNUMERIC_H_
-
-#include <_ansi.h>
-#include <sys/cdefs.h>
-#include <wchar.h>
-
-__BEGIN_DECLS
-
-struct lc_numeric_T {
- const char *decimal_point;
- const char *thousands_sep;
- const char *grouping;
-#ifdef __HAVE_LOCALE_INFO_EXTENDED__
- const char *codeset; /* codeset for mbtowc conversion */
- const wchar_t *wdecimal_point;
- const wchar_t *wthousands_sep;
-#endif
-};
-
-struct lc_numeric_T *__get_current_numeric_locale (void);
-int __numeric_load_locale (struct _thr_locale_t *, const char *, void *,
- const char *);
-
-__END_DECLS
-
-#endif /* !_LNUMERIC_H_ */
diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c
index 83d83a5..eb08dad 100644
--- a/newlib/libc/locale/locale.c
+++ b/newlib/libc/locale/locale.c
@@ -236,24 +236,25 @@ struct _thr_locale_t __global_locale =
__ascii_wctomb,
__ascii_mbtowc,
#endif
- NULL,
0,
+ NULL,
#ifndef __HAVE_LOCALE_INFO__
"\1",
"ASCII",
"ASCII",
#else
+ &_C_ctype_locale,
NULL,
+ &_C_monetary_locale,
NULL,
+ &_C_numeric_locale,
NULL,
+ &_C_time_locale,
NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
+ &_C_messages_locale,
NULL,
#ifdef __CYGWIN__
+ &_C_collate_locale,
NULL,
#endif
#endif
@@ -442,12 +443,6 @@ currentlocale()
#endif /* _MB_CAPABLE */
#ifdef _MB_CAPABLE
-#ifdef __CYGWIN__
-extern void __set_charset_from_locale (const char *locale, char *charset);
-extern char *__set_locale_from_locale_alias (const char *, char *);
-extern int __collate_load_locale (struct _thr_locale_t *, const char *, void *,
- const char *);
-#endif /* __CYGWIN__ */
extern void __set_ctype (struct _reent *, const char *charset);
@@ -952,7 +947,7 @@ char *
_DEFUN_VOID(__locale_charset)
{
#ifdef __HAVE_LOCALE_INFO__
- return (char *) __get_current_ctype_locale ()->codeset;
+ return __get_current_ctype_locale ()->codeset;
#else
return __global_locale.ctype_codeset;
#endif
@@ -1005,8 +1000,8 @@ _DEFUN(_localeconv_r, (data),
struct _reent *data)
{
#ifdef __HAVE_LOCALE_INFO__
- struct lc_numeric_T *n = __get_current_numeric_locale ();
- struct lc_monetary_T *m = __get_current_monetary_locale ();
+ const struct lc_numeric_T *n = __get_current_numeric_locale ();
+ const struct lc_monetary_T *m = __get_current_monetary_locale ();
lconv.decimal_point = (char *) n->decimal_point;
lconv.thousands_sep = (char *) n->thousands_sep;
diff --git a/newlib/libc/locale/nl_langinfo.c b/newlib/libc/locale/nl_langinfo.c
index 3acbc3a..ce6d8d8 100644
--- a/newlib/libc/locale/nl_langinfo.c
+++ b/newlib/libc/locale/nl_langinfo.c
@@ -48,11 +48,11 @@
static struct _nl_item_t
{
union {
- struct lc_ctype_T * (*ctype)(void);
- struct lc_time_T * (*time)(void);
- struct lc_numeric_T * (*numeric)(void);
- struct lc_monetary_T * (*monetary)(void);
- struct lc_messages_T * (*messages)(void);
+ const struct lc_ctype_T * (*ctype)(void);
+ const struct lc_time_T * (*time)(void);
+ const struct lc_numeric_T * (*numeric)(void);
+ const struct lc_monetary_T * (*monetary)(void);
+ const struct lc_messages_T * (*messages)(void);
void * (*base)(void);
};
_off_t offset;
@@ -206,8 +206,7 @@ _DEFUN(nl_langinfo, (item),
#ifdef __CYGWIN__
case _NL_COLLATE_CODESET:
{
- extern const char *__get_current_collate_codeset (void);
- ret = (char *) __get_current_collate_codeset ();
+ ret = (char *) __get_current_collate_locale ()->codeset;
goto do_codeset;
}
#endif /* __CYGWIN__ */
diff --git a/newlib/libc/locale/setlocale.h b/newlib/libc/locale/setlocale.h
index a4b55a6..ffb1cf1 100644
--- a/newlib/libc/locale/setlocale.h
+++ b/newlib/libc/locale/setlocale.h
@@ -29,59 +29,176 @@
#ifndef _SETLOCALE_H_
#define _SETLOCALE_H_
+#include <_ansi.h>
+#include <sys/cdefs.h>
#include <limits.h>
#include <string.h>
#include <stdlib.h>
+#include <wchar.h>
#include <locale.h>
-#include "lctype.h"
-#include "lmessages.h"
-#include "lnumeric.h"
-#include "timelocal.h"
-#include "lmonetary.h"
+
+__BEGIN_DECLS
#define ENCODING_LEN 31
#define CATEGORY_LEN 11
#define _LC_LAST 7
+struct lc_ctype_T {
+ const char *codeset; /* codeset for mbtowc conversion */
+ const char *mb_cur_max;
+#ifdef __HAVE_LOCALE_INFO_EXTENDED__
+ const char *outdigits[10];
+ const wchar_t *woutdigits[10];
+#endif
+};
+extern const struct lc_ctype_T _C_ctype_locale;
+
+struct lc_monetary_T {
+ const char *int_curr_symbol;
+ const char *currency_symbol;
+ const char *mon_decimal_point;
+ const char *mon_thousands_sep;
+ const char *mon_grouping;
+ const char *positive_sign;
+ const char *negative_sign;
+ const char *int_frac_digits;
+ const char *frac_digits;
+ const char *p_cs_precedes;
+ const char *p_sep_by_space;
+ const char *n_cs_precedes;
+ const char *n_sep_by_space;
+ const char *p_sign_posn;
+ const char *n_sign_posn;
+#ifdef __HAVE_LOCALE_INFO_EXTENDED__
+ const char *int_p_cs_precedes;
+ const char *int_p_sep_by_space;
+ const char *int_n_cs_precedes;
+ const char *int_n_sep_by_space;
+ const char *int_p_sign_posn;
+ const char *int_n_sign_posn;
+ const char *codeset; /* codeset for mbtowc conversion */
+ const wchar_t *wint_curr_symbol;
+ const wchar_t *wcurrency_symbol;
+ const wchar_t *wmon_decimal_point;
+ const wchar_t *wmon_thousands_sep;
+ const wchar_t *wpositive_sign;
+ const wchar_t *wnegative_sign;
+#endif
+};
+extern const struct lc_monetary_T _C_monetary_locale;
+
+struct lc_numeric_T {
+ const char *decimal_point;
+ const char *thousands_sep;
+ const char *grouping;
+#ifdef __HAVE_LOCALE_INFO_EXTENDED__
+ const char *codeset; /* codeset for mbtowc conversion */
+ const wchar_t *wdecimal_point;
+ const wchar_t *wthousands_sep;
+#endif
+};
+extern const struct lc_numeric_T _C_numeric_locale;
+
+struct lc_time_T {
+ const char *mon[12];
+ const char *month[12];
+ const char *wday[7];
+ const char *weekday[7];
+ const char *X_fmt;
+ const char *x_fmt;
+ const char *c_fmt;
+ const char *am_pm[2];
+ const char *date_fmt;
+ const char *alt_month[12]; /* unused */
+ const char *md_order;
+ const char *ampm_fmt;
+ const char *era;
+ const char *era_d_fmt;
+ const char *era_d_t_fmt;
+ const char *era_t_fmt;
+ const char *alt_digits;
+#ifdef __HAVE_LOCALE_INFO_EXTENDED__
+ const char *codeset; /* codeset for mbtowc conversion */
+ const wchar_t *wmon[12];
+ const wchar_t *wmonth[12];
+ const wchar_t *wwday[7];
+ const wchar_t *wweekday[7];
+ const wchar_t *wX_fmt;
+ const wchar_t *wx_fmt;
+ const wchar_t *wc_fmt;
+ const wchar_t *wam_pm[2];
+ const wchar_t *wdate_fmt;
+ const wchar_t *wampm_fmt;
+ const wchar_t *wera;
+ const wchar_t *wera_d_fmt;
+ const wchar_t *wera_d_t_fmt;
+ const wchar_t *wera_t_fmt;
+ const wchar_t *walt_digits;
+#endif
+};
+extern const struct lc_time_T _C_time_locale;
+
+struct lc_messages_T {
+ const char *yesexpr;
+ const char *noexpr;
+ const char *yesstr;
+ const char *nostr;
+#ifdef __HAVE_LOCALE_INFO_EXTENDED__
+ const char *codeset; /* codeset for mbtowc conversion */
+ const wchar_t *wyesexpr;
+ const wchar_t *wnoexpr;
+ const wchar_t *wyesstr;
+ const wchar_t *wnostr;
+#endif
+};
+extern const struct lc_messages_T _C_messages_locale;
+
#ifdef __CYGWIN__
-struct lc_collate_T;
+typedef __uint32_t LCID;
+
+struct lc_collate_T
+{
+ LCID lcid;
+ int (*mbtowc) (struct _reent *, wchar_t *, const char *, size_t, const char *,
+ mbstate_t *);
+ char codeset[ENCODING_LEN + 1];
+};
+extern const struct lc_collate_T _C_collate_locale;
#endif
struct _thr_locale_t
{
- char categories[_LC_LAST][ENCODING_LEN + 1];
- int (*__wctomb) (struct _reent *, char *, wchar_t,
- const char *, mbstate_t *);
- int (*__mbtowc) (struct _reent *, wchar_t *, const char *,
- size_t, const char *, mbstate_t *);
- char *ctype_ptr; /* Unused in __global_locale */
- int cjk_lang;
+ char categories[_LC_LAST][ENCODING_LEN + 1];
+ int (*__wctomb) (struct _reent *, char *, wchar_t,
+ const char *, mbstate_t *);
+ int (*__mbtowc) (struct _reent *, wchar_t *,
+ const char *, size_t, const char *,
+ mbstate_t *);
+ char *ctype_ptr; /* Unused in __global_locale */
+ int cjk_lang;
#ifndef __HAVE_LOCALE_INFO__
- char mb_cur_max[2];
- char ctype_codeset[ENCODING_LEN + 1];
- char message_codeset[ENCODING_LEN + 1];
+ char mb_cur_max[2];
+ char ctype_codeset[ENCODING_LEN + 1];
+ char message_codeset[ENCODING_LEN + 1];
#else
- struct lc_ctype_T *ctype;
- char *ctype_buf;
- struct lc_monetary_T *monetary;
- char *monetary_buf;
- struct lc_numeric_T *numeric;
- char *numeric_buf;
- struct lc_time_T *time;
- char *time_buf;
- struct lc_messages_T *messages;
- char *messages_buf;
+ const struct lc_ctype_T *ctype;
+ char *ctype_buf;
+ const struct lc_monetary_T *monetary;
+ char *monetary_buf;
+ const struct lc_numeric_T *numeric;
+ char *numeric_buf;
+ const struct lc_time_T *time;
+ char *time_buf;
+ const struct lc_messages_T *messages;
+ char *messages_buf;
#ifdef __CYGWIN__
- struct lc_collate_T *collate;
+ const struct lc_collate_T *collate;
+ char *collate_buf;
#endif
/* Append more categories here. */
#endif
};
-#ifdef __cplusplus
-extern "C" {
-#endif
-
extern struct _thr_locale_t __global_locale;
/* In POSIX terms the global locale is the process-wide locale. Use this
@@ -109,10 +226,64 @@ __get_current_locale ()
return _REENT->_locale ?: &__global_locale;
}
-#ifdef __cplusplus
+_ELIDABLE_INLINE const struct lc_ctype_T *
+__get_current_ctype_locale (void)
+{
+ return __get_current_locale ()->ctype;
+}
+
+_ELIDABLE_INLINE const struct lc_monetary_T *
+__get_current_monetary_locale (void)
+{
+ return __get_current_locale ()->monetary;
+}
+
+_ELIDABLE_INLINE const struct lc_time_T *
+__get_current_time_locale (void)
+{
+ return __get_current_locale ()->time;
+}
+
+_ELIDABLE_INLINE const struct lc_numeric_T *
+__get_current_numeric_locale (void)
+{
+ return __get_current_locale ()->numeric;
+}
+
+_ELIDABLE_INLINE const struct lc_messages_T *
+__get_current_messages_locale (void)
+{
+ return __get_current_locale ()->messages;
+}
+
+#ifdef __CYGWIN__
+_ELIDABLE_INLINE const struct lc_collate_T *
+__get_current_collate_locale (void)
+{
+ return __get_current_locale ()->collate;
}
#endif
+int __ctype_load_locale (struct _thr_locale_t *, const char *, void *,
+ const char *, int);
+int __monetary_load_locale (struct _thr_locale_t *, const char *, void *,
+ const char *);
+int __numeric_load_locale (struct _thr_locale_t *, const char *, void *,
+ const char *);
+int __time_load_locale (struct _thr_locale_t *, const char *, void *,
+ const char *);
+int __messages_load_locale (struct _thr_locale_t *, const char *, void *,
+ const char *);
+#ifdef __CYGWIN__
+int __collate_load_locale (struct _thr_locale_t *, const char *, void *,
+ const char *);
+
+extern void __set_charset_from_locale (const char *locale, char *charset);
+extern char *__set_locale_from_locale_alias (const char *, char *);
+#endif
+
extern char *_PathLocale;
+__END_DECLS
+
#endif /* !_SETLOCALE_H_ */
diff --git a/newlib/libc/locale/timelocal.c b/newlib/libc/locale/timelocal.c
index eda776a..5e64456 100644
--- a/newlib/libc/locale/timelocal.c
+++ b/newlib/libc/locale/timelocal.c
@@ -34,7 +34,7 @@
#define LCTIME_SIZE (sizeof(struct lc_time_T) / sizeof(char *))
-static const struct lc_time_T _C_time_locale = {
+const struct lc_time_T _C_time_locale = {
{
"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
@@ -177,7 +177,7 @@ __time_load_locale (struct _thr_locale_t *locale, const char *name,
return -1;
memcpy (tip, &ti, sizeof *tip);
}
- locale->time = ret == 0 ? NULL : tip;
+ locale->time = ret == 0 ? &_C_time_locale : tip;
if (locale->time_buf)
free (locale->time_buf);
locale->time_buf = bufp;
@@ -191,10 +191,3 @@ __time_load_locale (struct _thr_locale_t *locale, const char *name,
#endif
return (ret);
}
-
-struct lc_time_T *
-__get_current_time_locale (void)
-{
- struct _thr_locale_t *cur_locale = __get_current_locale ();
- return cur_locale->time ?: (struct lc_time_T *) &_C_time_locale;
-}
diff --git a/newlib/libc/locale/timelocal.h b/newlib/libc/locale/timelocal.h
deleted file mode 100644
index 6004ad8..0000000
--- a/newlib/libc/locale/timelocal.h
+++ /dev/null
@@ -1,86 +0,0 @@
-/*-
- * Copyright (c) 1997-2002 FreeBSD Project.
- * All rights reserved.
- *
- * 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: src/lib/libc/stdtime/timelocal.h,v 1.11 2002/01/24 15:07:44 phantom Exp $
- */
-
-#ifndef _TIMELOCAL_H_
-#define _TIMELOCAL_H_
-
-#include <_ansi.h>
-#include <sys/cdefs.h>
-#include <wchar.h>
-
-__BEGIN_DECLS
-
-/*
- * Private header file for the strftime and strptime localization
- * stuff.
- */
-struct lc_time_T {
- const char *mon[12];
- const char *month[12];
- const char *wday[7];
- const char *weekday[7];
- const char *X_fmt;
- const char *x_fmt;
- const char *c_fmt;
- const char *am_pm[2];
- const char *date_fmt;
- const char *alt_month[12]; /* unused */
- const char *md_order;
- const char *ampm_fmt;
- const char *era;
- const char *era_d_fmt;
- const char *era_d_t_fmt;
- const char *era_t_fmt;
- const char *alt_digits;
-#ifdef __HAVE_LOCALE_INFO_EXTENDED__
- const char *codeset; /* codeset for mbtowc conversion */
- const wchar_t *wmon[12];
- const wchar_t *wmonth[12];
- const wchar_t *wwday[7];
- const wchar_t *wweekday[7];
- const wchar_t *wX_fmt;
- const wchar_t *wx_fmt;
- const wchar_t *wc_fmt;
- const wchar_t *wam_pm[2];
- const wchar_t *wdate_fmt;
- const wchar_t *wampm_fmt;
- const wchar_t *wera;
- const wchar_t *wera_d_fmt;
- const wchar_t *wera_d_t_fmt;
- const wchar_t *wera_t_fmt;
- const wchar_t *walt_digits;
-#endif
-};
-
-struct lc_time_T *__get_current_time_locale (void);
-int __time_load_locale (struct _thr_locale_t *, const char *, void *,
- const char *);
-
-__END_DECLS
-
-#endif /* !_TIMELOCAL_H_ */
diff --git a/newlib/libc/stdio/vfwprintf.c b/newlib/libc/stdio/vfwprintf.c
index c3b8b27..f0179a0 100644
--- a/newlib/libc/stdio/vfwprintf.c
+++ b/newlib/libc/stdio/vfwprintf.c
@@ -132,7 +132,7 @@ SEEALSO
#include "fvwrite.h"
#include "vfieeefp.h"
#ifdef __HAVE_LOCALE_INFO_EXTENDED__
-#include "../locale/lnumeric.h"
+#include "../locale/setlocale.h"
#endif
/* Currently a test is made to see if long double processing is warranted.
diff --git a/newlib/libc/stdio/vfwscanf.c b/newlib/libc/stdio/vfwscanf.c
index 38a060d..a46f8dc 100644
--- a/newlib/libc/stdio/vfwscanf.c
+++ b/newlib/libc/stdio/vfwscanf.c
@@ -163,7 +163,7 @@ C99, POSIX-1.2008
#include <float.h>
#include <locale.h>
#ifdef __HAVE_LOCALE_INFO_EXTENDED__
-#include "../locale/lnumeric.h"
+#include "../locale/setlocale.h"
#endif
/* Currently a test is made to see if long double processing is warranted.
diff --git a/newlib/libc/time/strftime.c b/newlib/libc/time/strftime.c
index ced106a..12c37eb 100644
--- a/newlib/libc/time/strftime.c
+++ b/newlib/libc/time/strftime.c
@@ -276,7 +276,7 @@ the "C" locale settings.
#include <ctype.h>
#include <wctype.h>
#include "local.h"
-#include "../locale/timelocal.h"
+#include "../locale/setlocale.h"
/* Defines to make the file dual use for either strftime() or wcsftime().
* To get wcsftime, define MAKE_WCSFTIME.
@@ -709,7 +709,7 @@ _DEFUN (strftime, (s, maxsize, format, tim_p),
unsigned long width;
int tzset_called = 0;
- struct lc_time_T *_CurrentTimeLocale = __get_current_time_locale ();
+ const struct lc_time_T *_CurrentTimeLocale = __get_current_time_locale ();
for (;;)
{
while (*format && *format != CQ('%'))
diff --git a/newlib/libc/time/strptime.c b/newlib/libc/time/strptime.c
index 19b9fce..88b8978 100644
--- a/newlib/libc/time/strptime.c
+++ b/newlib/libc/time/strptime.c
@@ -37,7 +37,7 @@
#include <strings.h>
#include <ctype.h>
#include <stdlib.h>
-#include "../locale/timelocal.h"
+#include "../locale/setlocale.h"
#define _ctloc(x) (_CurrentTimeLocale->x)
@@ -160,7 +160,7 @@ _DEFUN (strptime, (buf, format, timeptr),
char c;
int ymd = 0;
- struct lc_time_T *_CurrentTimeLocale = __get_current_time_locale ();
+ const struct lc_time_T *_CurrentTimeLocale = __get_current_time_locale ();
for (; (c = *format) != '\0'; ++format) {
char *s;
int ret;