aboutsummaryrefslogtreecommitdiff
path: root/newlib/libc/include
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2010-04-28 09:59:37 +0000
committerCorinna Vinschen <corinna@vinschen.de>2010-04-28 09:59:37 +0000
commitd47d5b850bed398357e7f05d8fef508be1bb7f51 (patch)
tree8571d6a5751c102c12b11c58261ee663e83d7fce /newlib/libc/include
parent9b53b52a80f79a7746f51e2092b23dfab3d50c6f (diff)
downloadnewlib-d47d5b850bed398357e7f05d8fef508be1bb7f51.zip
newlib-d47d5b850bed398357e7f05d8fef508be1bb7f51.tar.gz
newlib-d47d5b850bed398357e7f05d8fef508be1bb7f51.tar.bz2
Extend locale support to maintain wide char values of native strings
if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/include/langinfo.h (enum __nl_item): New type. Define all native values accessible through nl_langinfo. Define previously existing POSIX-compatible values as macros as well. * libc/include/stdlib.h (__mb_cur_max): Drop declaration. (__locale_mb_cur_max): Declare. (MB_CUR_MAX): Re-define calling __locale_mb_cur_max. * libc/locale/Makefile.am (ELIX_SOURCES): Add lctype.c. * libc/locale/Makefile.in: Regenerate. * libc/locale/lctype.c: New file to define and load LC_CTYPE category. * libc/locale/lctype.h: New file, matching header. * libc/locale/lmessages.c (_C_messages_locale): Add default values for wide char members. (__messages_load_locale): Add _C_messages_locale in call to __set_lc_messages_from_win. * libc/locale/lmessages.h (struct lc_messages_T): Add wide char members. * libc/locale/lmonetary.c (_C_monetary_locale): Add default values for wide char members. (__monetary_load_locale): Add _C_monetary_locale in call to __set_lc_monetary_from_win. * libc/locale/lmonetary.h (struct lc_monetary_T): Add wide char members. Add numerical values for international currency formatting per POSIX-1.2008, if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/locale/lnumeric.c (_C_numeric_locale): Add default values for wide char members. (__numeric_load_locale): Add _C_numeric_locale in call to __set_lc_numeric_from_win. * libc/locale/lnumeric.h (struct lc_numeric_T): Add wide char members. * libc/locale/locale.c (loadlocale): Return doing nothing if category locale didn't change. Convert category if chain to switch statement. Call __ctype_load_locale in LC_CTYPE case. (__locale_charset): Add (but disable for now) returning codeset from __get_current_ctype_locale. (__locale_mb_cur_max): Add (but disable for now) returning mb_cur_max from __get_current_ctype_locale. (__locale_msgcharset): Add returning codeset from __get_current_messages_locale. (_localeconv_r): Accommodate int_XXX values. * libc/locale/nl_langinfo.c (nl_ext): New array to define what is to be returned for non-POSIX values. (nl_Langinfo): Return correct codeset for each locale category. Return extended values if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/locale/timelocal.c (_C_time_locale): Add default values for wide char members. (__time_load_locale): Add _C_time_locale in call to __set_lc_time_from_win. * libc/locale/timelocal.h (struct lc_time_T): Add wide char members. * libc/stdio/vfwprintf.c (_VFWPRINTF_R): Use wide char decimal point and thousands_sep if __HAVE_LOCALE_INFO_EXTENDED__ is defined. * libc/time/strftime.c: Rework to accommodate availability of wide char strings in LC_TIME category if __HAVE_LOCALE_INFO_EXTENDED__ is defined.
Diffstat (limited to 'newlib/libc/include')
-rw-r--r--newlib/libc/include/langinfo.h358
-rw-r--r--newlib/libc/include/stdlib.h4
2 files changed, 267 insertions, 95 deletions
diff --git a/newlib/libc/include/langinfo.h b/newlib/libc/include/langinfo.h
index c0c31b3..542e438 100644
--- a/newlib/libc/include/langinfo.h
+++ b/newlib/libc/include/langinfo.h
@@ -29,113 +29,285 @@
#ifndef _LANGINFO_H_
#define _LANGINFO_H_
+#include <newlib.h>
+#include <sys/config.h>
#include <sys/cdefs.h>
typedef int nl_item;
-/* Extract the category and item index from a constructed `nl_item' value. */
-#define _NL_ITEM_CATEGORY(item) ((int) (item) >> 16)
-#define _NL_ITEM_INDEX(item) ((int) (item) & 0xffff)
-
-#define CODESET 0 /* codeset name */
-#define D_T_FMT 1 /* string for formatting date and time */
-#define D_FMT 2 /* date format string */
-#define T_FMT 3 /* time format string */
-#define T_FMT_AMPM 4 /* a.m. or p.m. time formatting string */
-#define AM_STR 5 /* Ante Meridian affix */
-#define PM_STR 6 /* Post Meridian affix */
+enum __nl_item
+{
+ /* POSIX and BSD defined items have to stick to the original values
+ to maintain backward compatibility. */
+ _NL_CTYPE_CODESET_NAME = 0, /* codeset name */
+#define CODESET _NL_CTYPE_CODESET_NAME
+ D_T_FMT, /* string for formatting date and time */
+#define D_T_FMT D_T_FMT
+ D_FMT, /* date format string */
+#define D_FMT D_FMT
+ T_FMT, /* time format string */
+#define T_FMT T_FMT
+ T_FMT_AMPM, /* a.m. or p.m. time formatting string */
+#define T_FMT_AMPM T_FMT_AMPM
+ AM_STR, /* Ante Meridian affix */
+#define AM_STR AM_STR
+ PM_STR, /* Post Meridian affix */
+#define PM_STR PM_STR
/* week day names */
-#define DAY_1 7
-#define DAY_2 8
-#define DAY_3 9
-#define DAY_4 10
-#define DAY_5 11
-#define DAY_6 12
-#define DAY_7 13
+ DAY_1,
+#define DAY_1 DAY_1
+ DAY_2,
+#define DAY_2 DAY_2
+ DAY_3,
+#define DAY_3 DAY_3
+ DAY_4,
+#define DAY_4 DAY_4
+ DAY_5,
+#define DAY_5 DAY_5
+ DAY_6,
+#define DAY_6 DAY_6
+ DAY_7,
+#define DAY_7 DAY_7
/* abbreviated week day names */
-#define ABDAY_1 14
-#define ABDAY_2 15
-#define ABDAY_3 16
-#define ABDAY_4 17
-#define ABDAY_5 18
-#define ABDAY_6 19
-#define ABDAY_7 20
+ ABDAY_1,
+#define ABDAY_1 ABDAY_1
+ ABDAY_2,
+#define ABDAY_2 ABDAY_2
+ ABDAY_3,
+#define ABDAY_3 ABDAY_3
+ ABDAY_4,
+#define ABDAY_4 ABDAY_4
+ ABDAY_5,
+#define ABDAY_5 ABDAY_5
+ ABDAY_6,
+#define ABDAY_6 ABDAY_6
+ ABDAY_7,
+#define ABDAY_7 ABDAY_7
/* month names */
-#define MON_1 21
-#define MON_2 22
-#define MON_3 23
-#define MON_4 24
-#define MON_5 25
-#define MON_6 26
-#define MON_7 27
-#define MON_8 28
-#define MON_9 29
-#define MON_10 30
-#define MON_11 31
-#define MON_12 32
+ MON_1,
+#define MON_1 MON_1
+ MON_2,
+#define MON_2 MON_2
+ MON_3,
+#define MON_3 MON_3
+ MON_4,
+#define MON_4 MON_4
+ MON_5,
+#define MON_5 MON_5
+ MON_6,
+#define MON_6 MON_6
+ MON_7,
+#define MON_7 MON_7
+ MON_8,
+#define MON_8 MON_8
+ MON_9,
+#define MON_9 MON_9
+ MON_10,
+#define MON_10 MON_10
+ MON_11,
+#define MON_11 MON_11
+ MON_12,
+#define MON_12 MON_12
/* abbreviated month names */
-#define ABMON_1 33
-#define ABMON_2 34
-#define ABMON_3 35
-#define ABMON_4 36
-#define ABMON_5 37
-#define ABMON_6 38
-#define ABMON_7 39
-#define ABMON_8 40
-#define ABMON_9 41
-#define ABMON_10 42
-#define ABMON_11 43
-#define ABMON_12 44
-
-#define ERA 45 /* era description segments */
-#define ERA_D_FMT 46 /* era date format string */
-#define ERA_D_T_FMT 47 /* era date and time format string */
-#define ERA_T_FMT 48 /* era time format string */
-#define ALT_DIGITS 49 /* alternative symbols for digits */
-
-#define RADIXCHAR 50 /* radix char */
-#define THOUSEP 51 /* separator for thousands */
-
-#define YESEXPR 52 /* affirmative response expression */
-#define NOEXPR 53 /* negative response expression */
-#define YESSTR 54 /* affirmative response for yes/no queries */
-#define NOSTR 55 /* negative response for yes/no queries */
-
-#define CRNCYSTR 56 /* currency symbol */
-
-#define D_MD_ORDER 57 /* month/day order (local extension) */
-
-#define _NL_CTYPE_TRANSLIT_TAB_SIZE 58
-#define _NL_CTYPE_TRANSLIT_FROM_IDX 59
-#define _NL_CTYPE_TRANSLIT_FROM_TBL 60
-#define _NL_CTYPE_TRANSLIT_TO_IDX 61
-#define _NL_CTYPE_TRANSLIT_TO_TBL 62
-#define _NL_CTYPE_TRANSLIT_DEFAULT_MISSING_LEN 63
-#define _NL_CTYPE_TRANSLIT_DEFAULT_MISSING 64
-#define _NL_CTYPE_TRANSLIT_IGNORE_LEN 65
-#define _NL_CTYPE_TRANSLIT_IGNORE 66
-#define _NL_CTYPE_EXTRA_MAP_1 70
-#define _NL_CTYPE_EXTRA_MAP_2 71
-#define _NL_CTYPE_EXTRA_MAP_3 72
-#define _NL_CTYPE_EXTRA_MAP_4 73
-#define _NL_CTYPE_EXTRA_MAP_5 74
-#define _NL_CTYPE_EXTRA_MAP_6 75
-#define _NL_CTYPE_EXTRA_MAP_7 76
-#define _NL_CTYPE_EXTRA_MAP_8 77
-#define _NL_CTYPE_EXTRA_MAP_9 78
-#define _NL_CTYPE_EXTRA_MAP_10 79
-#define _NL_CTYPE_EXTRA_MAP_11 80
-#define _NL_CTYPE_EXTRA_MAP_12 81
-#define _NL_CTYPE_EXTRA_MAP_13 82
-#define _NL_CTYPE_EXTRA_MAP_14 83
-
-#define _NL_TIME_DATE_FMT 84
+ ABMON_1,
+#define ABMON_1 ABMON_1
+ ABMON_2,
+#define ABMON_2 ABMON_2
+ ABMON_3,
+#define ABMON_3 ABMON_3
+ ABMON_4,
+#define ABMON_4 ABMON_4
+ ABMON_5,
+#define ABMON_5 ABMON_5
+ ABMON_6,
+#define ABMON_6 ABMON_6
+ ABMON_7,
+#define ABMON_7 ABMON_7
+ ABMON_8,
+#define ABMON_8 ABMON_8
+ ABMON_9,
+#define ABMON_9 ABMON_9
+ ABMON_10,
+#define ABMON_10 ABMON_10
+ ABMON_11,
+#define ABMON_11 ABMON_11
+ ABMON_12,
+#define ABMON_12 ABMON_12
+
+ ERA, /* era description segments */
+#define ERA ERA
+ ERA_D_FMT, /* era date format string */
+#define ERA_D_FMT ERA_D_FMT
+ ERA_D_T_FMT, /* era date and time format string */
+#define ERA_D_T_FMT ERA_D_T_FMT
+ ERA_T_FMT, /* era time format string */
+#define ERA_T_FMT ERA_T_FMT
+ ALT_DIGITS, /* alternative symbols for digits */
+#define ALT_DIGITS ALT_DIGITS
+
+ RADIXCHAR, /* radix char */
+#define RADIXCHAR RADIXCHAR
+ THOUSEP, /* separator for thousands */
+#define THOUSEP THOUSEP
+
+ YESEXPR, /* affirmative response expression */
+#define YESEXPR YESEXPR
+ NOEXPR, /* negative response expression */
+#define NOEXPR NOEXPR
+ YESSTR, /* affirmative response for yes/no queries */
+#define YESSTR YESSTR
+ NOSTR, /* negative response for yes/no queries */
+#define NOSTR NOSTR
+
+ CRNCYSTR, /* currency symbol */
+#define CRNCYSTR CRNCYSTR
+
+ D_MD_ORDER, /* month/day order (BSD extension) */
+#define D_MD_ORDER D_MD_ORDER
+
+ _NL_TIME_DATE_FMT = 84, /* date fmt used by date(1) (GNU extension) */
#define _DATE_FMT _NL_TIME_DATE_FMT
+#ifdef __HAVE_LOCALE_INFO__
+ _NL_CTYPE_MB_CUR_MAX,
+ _NL_MESSAGES_CODESET,
+
+#ifdef __HAVE_LOCALE_INFO_EXTENDED__
+
+ /* NOTE:
+
+ Always maintain the order and position of existing entries!
+ Always append new entry to the list, prior to the definition
+ of _NL_LOCALE_EXTENDED_LAST_ENTRY. */
+
+ _NL_LOCALE_EXTENDED_FIRST_ENTRY,
+
+ _NL_CTYPE_OUTDIGITS0_MB,
+ _NL_CTYPE_OUTDIGITS1_MB,
+ _NL_CTYPE_OUTDIGITS2_MB,
+ _NL_CTYPE_OUTDIGITS3_MB,
+ _NL_CTYPE_OUTDIGITS4_MB,
+ _NL_CTYPE_OUTDIGITS5_MB,
+ _NL_CTYPE_OUTDIGITS6_MB,
+ _NL_CTYPE_OUTDIGITS7_MB,
+ _NL_CTYPE_OUTDIGITS8_MB,
+ _NL_CTYPE_OUTDIGITS9_MB,
+ _NL_CTYPE_OUTDIGITS0_WC,
+ _NL_CTYPE_OUTDIGITS1_WC,
+ _NL_CTYPE_OUTDIGITS2_WC,
+ _NL_CTYPE_OUTDIGITS3_WC,
+ _NL_CTYPE_OUTDIGITS4_WC,
+ _NL_CTYPE_OUTDIGITS5_WC,
+ _NL_CTYPE_OUTDIGITS6_WC,
+ _NL_CTYPE_OUTDIGITS7_WC,
+ _NL_CTYPE_OUTDIGITS8_WC,
+ _NL_CTYPE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UPING,
+ _NL_NUMERIC_DECIMAL_POINT_WC,
+ _NL_NUMERIC_THOUSANDS_SEP_WC,
+
+ _NL_MONETARY_INT_CURR_SYMBOL,
+ _NL_MONETARY_CURRENCY_SYMBOL,
+ _NL_MONETARY_MON_DECIMAL_POINT,
+ _NL_MONETARY_MON_THOUSANDS_SEP,
+ _NL_MONETARY_MON_GROUPING,
+ _NL_MONETARY_POSITIVE_SIGN,
+ _NL_MONETARY_NEGATIVE_SIGN,
+ _NL_MONETARY_INT_FRAC_DIGITS,
+ _NL_MONETARY_FRAC_DIGITS,
+ _NL_MONETARY_P_CS_PRECEDES,
+ _NL_MONETARY_P_SEP_BY_SPACE,
+ _NL_MONETARY_N_CS_PRECEDES,
+ _NL_MONETARY_N_SEP_BY_SPACE,
+ _NL_MONETARY_P_SIGN_POSN,
+ _NL_MONETARY_N_SIGN_POSN,
+ _NL_MONETARY_INT_P_CS_PRECEDES,
+ _NL_MONETARY_INT_P_SEP_BY_SPACE,
+ _NL_MONETARY_INT_N_CS_PRECEDES,
+ _NL_MONETARY_INT_N_SEP_BY_SPACE,
+ _NL_MONETARY_INT_P_SIGN_POSN,
+ _NL_MONETARY_INT_N_SIGN_POSN,
+ _NL_MONETARY_CODESET,
+ _NL_MONETARY_WINT_CURR_SYMBOL,
+ _NL_MONETARY_WCURRENCY_SYMBOL,
+ _NL_MONETARY_WMON_DECIMAL_POINT,
+ _NL_MONETARY_WMON_THOUSANDS_SEP,
+ _NL_MONETARY_WPOSITIVE_SIGN,
+ _NL_MONETARY_WNEGATIVE_SIGN,
+
+ _NL_MESSAGES_WYESEXPR,
+ _NL_MESSAGES_WNOEXPR,
+ _NL_MESSAGES_WYESSTR,
+ _NL_MESSAGES_WNOSTR,
+
+ _NL_COLLATE_CODESET,
+
+ /* This MUST be the last entry since it's used to check for an array
+ index in nl_langinfo(). */
+ _NL_LOCALE_EXTENDED_LAST_ENTRY
+};
+
+#endif /* __HAVE_LOCALE_INFO_EXTENDED__ */
+#endif /* __HAVE_LOCALE_INFO__ */
+
__BEGIN_DECLS
char *nl_langinfo(nl_item);
__END_DECLS
diff --git a/newlib/libc/include/stdlib.h b/newlib/libc/include/stdlib.h
index b33503d..453bb50 100644
--- a/newlib/libc/include/stdlib.h
+++ b/newlib/libc/include/stdlib.h
@@ -55,9 +55,9 @@ typedef struct
#define RAND_MAX __RAND_MAX
-extern __IMPORT int __mb_cur_max;
+int _EXFUN(__locale_mb_cur_max,(_VOID));
-#define MB_CUR_MAX __mb_cur_max
+#define MB_CUR_MAX __locale_mb_cur_max()
_VOID _EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn)));
int _EXFUN(abs,(int));