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.
This commit is contained in:
		| @@ -1,3 +1,58 @@ | |||||||
|  | 2010-04-28  Corinna Vinschen  <corinna@vinschen.de> | ||||||
|  |  | ||||||
|  | 	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. | ||||||
|  |  | ||||||
| 2010-04-22  DJ Delorie  <dj@redhat.com> | 2010-04-22  DJ Delorie  <dj@redhat.com> | ||||||
|  |  | ||||||
| 	* libc/Makefile.am (SUBDEFS): Add LIBC_POSIX_DEF. | 	* libc/Makefile.am (SUBDEFS): Add LIBC_POSIX_DEF. | ||||||
|   | |||||||
| @@ -29,113 +29,285 @@ | |||||||
| #ifndef _LANGINFO_H_ | #ifndef _LANGINFO_H_ | ||||||
| #define	_LANGINFO_H_ | #define	_LANGINFO_H_ | ||||||
|  |  | ||||||
|  | #include <newlib.h> | ||||||
|  | #include <sys/config.h> | ||||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||||
|  |  | ||||||
| typedef int nl_item; | typedef int nl_item; | ||||||
|  |  | ||||||
| /* Extract the category and item index from a constructed `nl_item' value.  */ | enum __nl_item | ||||||
| #define _NL_ITEM_CATEGORY(item)		((int) (item) >> 16) | { | ||||||
| #define _NL_ITEM_INDEX(item)		((int) (item) & 0xffff) |   /* POSIX and BSD defined items have to stick to the original values | ||||||
|  |      to maintain backward compatibility. */ | ||||||
| #define	CODESET		0	/* codeset name */ |   _NL_CTYPE_CODESET_NAME = 0,	/* codeset name */ | ||||||
| #define	D_T_FMT		1	/* string for formatting date and time */ | #define CODESET _NL_CTYPE_CODESET_NAME | ||||||
| #define	D_FMT		2	/* date format string */ |   D_T_FMT,			/* string for formatting date and time */ | ||||||
| #define	T_FMT		3	/* time format string */ | #define D_T_FMT D_T_FMT | ||||||
| #define	T_FMT_AMPM	4	/* a.m. or p.m. time formatting string */ |   D_FMT,			/* date format string */ | ||||||
| #define	AM_STR		5	/* Ante Meridian affix */ | #define D_FMT D_FMT | ||||||
| #define	PM_STR		6	/* Post Meridian affix */ |   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 */ | /* week day names */ | ||||||
| #define	DAY_1		7 |   DAY_1, | ||||||
| #define	DAY_2		8 | #define DAY_1 DAY_1 | ||||||
| #define	DAY_3		9 |   DAY_2, | ||||||
| #define	DAY_4		10 | #define DAY_2 DAY_2 | ||||||
| #define	DAY_5		11 |   DAY_3, | ||||||
| #define	DAY_6		12 | #define DAY_3 DAY_3 | ||||||
| #define	DAY_7		13 |   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 */ | /* abbreviated week day names */ | ||||||
| #define	ABDAY_1		14 |   ABDAY_1, | ||||||
| #define	ABDAY_2		15 | #define ABDAY_1 ABDAY_1 | ||||||
| #define	ABDAY_3		16 |   ABDAY_2, | ||||||
| #define	ABDAY_4		17 | #define ABDAY_2 ABDAY_2 | ||||||
| #define	ABDAY_5		18 |   ABDAY_3, | ||||||
| #define	ABDAY_6		19 | #define ABDAY_3 ABDAY_3 | ||||||
| #define	ABDAY_7		20 |   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 */ | /* month names */ | ||||||
| #define	MON_1		21 |   MON_1, | ||||||
| #define	MON_2		22 | #define MON_1 MON_1 | ||||||
| #define	MON_3		23 |   MON_2, | ||||||
| #define	MON_4		24 | #define MON_2 MON_2 | ||||||
| #define	MON_5		25 |   MON_3, | ||||||
| #define	MON_6		26 | #define MON_3 MON_3 | ||||||
| #define	MON_7		27 |   MON_4, | ||||||
| #define	MON_8		28 | #define MON_4 MON_4 | ||||||
| #define	MON_9		29 |   MON_5, | ||||||
| #define	MON_10		30 | #define MON_5 MON_5 | ||||||
| #define	MON_11		31 |   MON_6, | ||||||
| #define	MON_12		32 | #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 */ | /* abbreviated month names */ | ||||||
| #define	ABMON_1		33 |   ABMON_1, | ||||||
| #define	ABMON_2		34 | #define ABMON_1 ABMON_1 | ||||||
| #define	ABMON_3		35 |   ABMON_2, | ||||||
| #define	ABMON_4		36 | #define ABMON_2 ABMON_2 | ||||||
| #define	ABMON_5		37 |   ABMON_3, | ||||||
| #define	ABMON_6		38 | #define ABMON_3 ABMON_3 | ||||||
| #define	ABMON_7		39 |   ABMON_4, | ||||||
| #define	ABMON_8		40 | #define ABMON_4 ABMON_4 | ||||||
| #define	ABMON_9		41 |   ABMON_5, | ||||||
| #define	ABMON_10	42 | #define ABMON_5 ABMON_5 | ||||||
| #define	ABMON_11	43 |   ABMON_6, | ||||||
| #define	ABMON_12	44 | #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 | ||||||
|  |  | ||||||
| #define	ERA		45	/* era description segments */ |   ERA,				/* era description segments */ | ||||||
| #define	ERA_D_FMT	46	/* era date format string */ | #define ERA ERA | ||||||
| #define	ERA_D_T_FMT	47	/* era date and time format string */ |   ERA_D_FMT,			/* era date format string */ | ||||||
| #define	ERA_T_FMT	48	/* era time format string */ | #define ERA_D_FMT ERA_D_FMT | ||||||
| #define	ALT_DIGITS	49	/* alternative symbols for digits */ |   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 | ||||||
|  |  | ||||||
| #define	RADIXCHAR	50	/* radix char */ |   RADIXCHAR,			/* radix char */ | ||||||
| #define	THOUSEP		51	/* separator for thousands */ | #define RADIXCHAR RADIXCHAR | ||||||
|  |   THOUSEP,			/* separator for thousands */ | ||||||
|  | #define THOUSEP THOUSEP | ||||||
|  |  | ||||||
| #define	YESEXPR		52	/* affirmative response expression */ |   YESEXPR,			/* affirmative response expression */ | ||||||
| #define	NOEXPR		53	/* negative response expression */ | #define YESEXPR YESEXPR | ||||||
| #define	YESSTR		54	/* affirmative response for yes/no queries */ |   NOEXPR,			/* negative response expression */ | ||||||
| #define	NOSTR		55	/* negative response for yes/no queries */ | #define NOEXPR NOEXPR | ||||||
|  |   YESSTR,			/* affirmative response for yes/no queries */ | ||||||
|  | #define YESSTR YESSTR | ||||||
|  |   NOSTR,			/* negative response for yes/no queries */ | ||||||
|  | #define NOSTR NOSTR | ||||||
|  |  | ||||||
| #define	CRNCYSTR	56	/* currency symbol */ |   CRNCYSTR,			/* currency symbol */ | ||||||
|  | #define CRNCYSTR CRNCYSTR | ||||||
|  |  | ||||||
| #define	D_MD_ORDER	57	/* month/day order (local extension) */ |   D_MD_ORDER,			/* month/day order (BSD extension) */ | ||||||
|  | #define D_MD_ORDER D_MD_ORDER | ||||||
|  |  | ||||||
| #define _NL_CTYPE_TRANSLIT_TAB_SIZE 58 |   _NL_TIME_DATE_FMT = 84,	/* date fmt used by date(1) (GNU extension) */ | ||||||
| #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 |  | ||||||
| #define _DATE_FMT _NL_TIME_DATE_FMT | #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_OUTDIGITS9_WC, | ||||||
|  |  | ||||||
|  |   _NL_TIME_CODESET, | ||||||
|  |   _NL_TIME_WMON_1, | ||||||
|  |   _NL_TIME_WMON_2, | ||||||
|  |   _NL_TIME_WMON_3, | ||||||
|  |   _NL_TIME_WMON_4, | ||||||
|  |   _NL_TIME_WMON_5, | ||||||
|  |   _NL_TIME_WMON_6, | ||||||
|  |   _NL_TIME_WMON_7, | ||||||
|  |   _NL_TIME_WMON_8, | ||||||
|  |   _NL_TIME_WMON_9, | ||||||
|  |   _NL_TIME_WMON_10, | ||||||
|  |   _NL_TIME_WMON_11, | ||||||
|  |   _NL_TIME_WMON_12, | ||||||
|  |   _NL_TIME_WMONTH_1, | ||||||
|  |   _NL_TIME_WMONTH_2, | ||||||
|  |   _NL_TIME_WMONTH_3, | ||||||
|  |   _NL_TIME_WMONTH_4, | ||||||
|  |   _NL_TIME_WMONTH_5, | ||||||
|  |   _NL_TIME_WMONTH_6, | ||||||
|  |   _NL_TIME_WMONTH_7, | ||||||
|  |   _NL_TIME_WMONTH_8, | ||||||
|  |   _NL_TIME_WMONTH_9, | ||||||
|  |   _NL_TIME_WMONTH_10, | ||||||
|  |   _NL_TIME_WMONTH_11, | ||||||
|  |   _NL_TIME_WMONTH_12, | ||||||
|  |   _NL_TIME_WWDAY_1, | ||||||
|  |   _NL_TIME_WWDAY_2, | ||||||
|  |   _NL_TIME_WWDAY_3, | ||||||
|  |   _NL_TIME_WWDAY_4, | ||||||
|  |   _NL_TIME_WWDAY_5, | ||||||
|  |   _NL_TIME_WWDAY_6, | ||||||
|  |   _NL_TIME_WWDAY_7, | ||||||
|  |   _NL_TIME_WWEEKDAY_1, | ||||||
|  |   _NL_TIME_WWEEKDAY_2, | ||||||
|  |   _NL_TIME_WWEEKDAY_3, | ||||||
|  |   _NL_TIME_WWEEKDAY_4, | ||||||
|  |   _NL_TIME_WWEEKDAY_5, | ||||||
|  |   _NL_TIME_WWEEKDAY_6, | ||||||
|  |   _NL_TIME_WWEEKDAY_7, | ||||||
|  |   _NL_TIME_WT_FMT, | ||||||
|  |   _NL_TIME_WD_FMT, | ||||||
|  |   _NL_TIME_WD_T_FMT, | ||||||
|  |   _NL_TIME_WAM_STR, | ||||||
|  |   _NL_TIME_WPM_STR, | ||||||
|  |   _NL_TIME_WDATE_FMT, | ||||||
|  |   _NL_TIME_WT_FMT_AMPM, | ||||||
|  |   _NL_TIME_WERA, | ||||||
|  |   _NL_TIME_WERA_D_FMT, | ||||||
|  |   _NL_TIME_WERA_D_T_FMT, | ||||||
|  |   _NL_TIME_WERA_T_FMT, | ||||||
|  |   _NL_TIME_WALT_DIGITS, | ||||||
|  |  | ||||||
|  |   _NL_NUMERIC_CODESET, | ||||||
|  |   _NL_NUMERIC_GROUPING, | ||||||
|  |   _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 | __BEGIN_DECLS | ||||||
| char	*nl_langinfo(nl_item); | char	*nl_langinfo(nl_item); | ||||||
| __END_DECLS | __END_DECLS | ||||||
|   | |||||||
| @@ -55,9 +55,9 @@ typedef struct | |||||||
|  |  | ||||||
| #define RAND_MAX __RAND_MAX | #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))); | _VOID	_EXFUN(abort,(_VOID) _ATTRIBUTE ((noreturn))); | ||||||
| int	_EXFUN(abs,(int)); | int	_EXFUN(abs,(int)); | ||||||
|   | |||||||
| @@ -17,7 +17,8 @@ ELIX_SOURCES = \ | |||||||
| 	lnumeric.c \ | 	lnumeric.c \ | ||||||
| 	lmonetary.c \ | 	lmonetary.c \ | ||||||
| 	nl_langinfo.c \ | 	nl_langinfo.c \ | ||||||
| 	timelocal.c | 	timelocal.c \ | ||||||
|  | 	lctype.c | ||||||
| endif | endif | ||||||
|  |  | ||||||
| liblocale_la_LDFLAGS = -Xcompiler -nostdlib | liblocale_la_LDFLAGS = -Xcompiler -nostdlib | ||||||
|   | |||||||
| @@ -62,7 +62,8 @@ am__objects_1 = lib_a-locale.$(OBJEXT) | |||||||
| @ELIX_LEVEL_1_FALSE@	lib_a-lnumeric.$(OBJEXT) \ | @ELIX_LEVEL_1_FALSE@	lib_a-lnumeric.$(OBJEXT) \ | ||||||
| @ELIX_LEVEL_1_FALSE@	lib_a-lmonetary.$(OBJEXT) \ | @ELIX_LEVEL_1_FALSE@	lib_a-lmonetary.$(OBJEXT) \ | ||||||
| @ELIX_LEVEL_1_FALSE@	lib_a-nl_langinfo.$(OBJEXT) \ | @ELIX_LEVEL_1_FALSE@	lib_a-nl_langinfo.$(OBJEXT) \ | ||||||
| @ELIX_LEVEL_1_FALSE@	lib_a-timelocal.$(OBJEXT) | @ELIX_LEVEL_1_FALSE@	lib_a-timelocal.$(OBJEXT) \ | ||||||
|  | @ELIX_LEVEL_1_FALSE@	lib_a-lctype.$(OBJEXT) | ||||||
| @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \ | @USE_LIBTOOL_FALSE@am_lib_a_OBJECTS = $(am__objects_1) \ | ||||||
| @USE_LIBTOOL_FALSE@	$(am__objects_2) | @USE_LIBTOOL_FALSE@	$(am__objects_2) | ||||||
| lib_a_OBJECTS = $(am_lib_a_OBJECTS) | lib_a_OBJECTS = $(am_lib_a_OBJECTS) | ||||||
| @@ -71,7 +72,7 @@ liblocale_la_LIBADD = | |||||||
| am__objects_3 = locale.lo | am__objects_3 = locale.lo | ||||||
| @ELIX_LEVEL_1_FALSE@am__objects_4 = fix_grouping.lo ldpart.lo \ | @ELIX_LEVEL_1_FALSE@am__objects_4 = fix_grouping.lo ldpart.lo \ | ||||||
| @ELIX_LEVEL_1_FALSE@	lmessages.lo lnumeric.lo lmonetary.lo \ | @ELIX_LEVEL_1_FALSE@	lmessages.lo lnumeric.lo lmonetary.lo \ | ||||||
| @ELIX_LEVEL_1_FALSE@	nl_langinfo.lo timelocal.lo | @ELIX_LEVEL_1_FALSE@	nl_langinfo.lo timelocal.lo lctype.lo | ||||||
| @USE_LIBTOOL_TRUE@am_liblocale_la_OBJECTS = $(am__objects_3) \ | @USE_LIBTOOL_TRUE@am_liblocale_la_OBJECTS = $(am__objects_3) \ | ||||||
| @USE_LIBTOOL_TRUE@	$(am__objects_4) | @USE_LIBTOOL_TRUE@	$(am__objects_4) | ||||||
| liblocale_la_OBJECTS = $(am_liblocale_la_OBJECTS) | liblocale_la_OBJECTS = $(am_liblocale_la_OBJECTS) | ||||||
| @@ -168,6 +169,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ | |||||||
| PACKAGE_NAME = @PACKAGE_NAME@ | PACKAGE_NAME = @PACKAGE_NAME@ | ||||||
| PACKAGE_STRING = @PACKAGE_STRING@ | PACKAGE_STRING = @PACKAGE_STRING@ | ||||||
| PACKAGE_TARNAME = @PACKAGE_TARNAME@ | PACKAGE_TARNAME = @PACKAGE_TARNAME@ | ||||||
|  | PACKAGE_URL = @PACKAGE_URL@ | ||||||
| PACKAGE_VERSION = @PACKAGE_VERSION@ | PACKAGE_VERSION = @PACKAGE_VERSION@ | ||||||
| PATH_SEPARATOR = @PATH_SEPARATOR@ | PATH_SEPARATOR = @PATH_SEPARATOR@ | ||||||
| RANLIB = @RANLIB@ | RANLIB = @RANLIB@ | ||||||
| @@ -247,7 +249,8 @@ GENERAL_SOURCES = timelocal.h ldpart.h locale.c lnumeric.h lmonetary.h lmessages | |||||||
| @ELIX_LEVEL_1_FALSE@	lnumeric.c \ | @ELIX_LEVEL_1_FALSE@	lnumeric.c \ | ||||||
| @ELIX_LEVEL_1_FALSE@	lmonetary.c \ | @ELIX_LEVEL_1_FALSE@	lmonetary.c \ | ||||||
| @ELIX_LEVEL_1_FALSE@	nl_langinfo.c \ | @ELIX_LEVEL_1_FALSE@	nl_langinfo.c \ | ||||||
| @ELIX_LEVEL_1_FALSE@	timelocal.c | @ELIX_LEVEL_1_FALSE@	timelocal.c \ | ||||||
|  | @ELIX_LEVEL_1_FALSE@	lctype.c | ||||||
|  |  | ||||||
| @ELIX_LEVEL_1_TRUE@ELIX_SOURCES =  | @ELIX_LEVEL_1_TRUE@ELIX_SOURCES =  | ||||||
| liblocale_la_LDFLAGS = -Xcompiler -nostdlib | liblocale_la_LDFLAGS = -Xcompiler -nostdlib | ||||||
| @@ -379,6 +382,12 @@ lib_a-timelocal.o: timelocal.c | |||||||
| lib_a-timelocal.obj: timelocal.c | lib_a-timelocal.obj: timelocal.c | ||||||
| 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-timelocal.obj `if test -f 'timelocal.c'; then $(CYGPATH_W) 'timelocal.c'; else $(CYGPATH_W) '$(srcdir)/timelocal.c'; fi` | 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-timelocal.obj `if test -f 'timelocal.c'; then $(CYGPATH_W) 'timelocal.c'; else $(CYGPATH_W) '$(srcdir)/timelocal.c'; fi` | ||||||
|  |  | ||||||
|  | lib_a-lctype.o: lctype.c | ||||||
|  | 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lctype.o `test -f 'lctype.c' || echo '$(srcdir)/'`lctype.c | ||||||
|  |  | ||||||
|  | lib_a-lctype.obj: lctype.c | ||||||
|  | 	$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(lib_a_CFLAGS) $(CFLAGS) -c -o lib_a-lctype.obj `if test -f 'lctype.c'; then $(CYGPATH_W) 'lctype.c'; else $(CYGPATH_W) '$(srcdir)/lctype.c'; fi` | ||||||
|  |  | ||||||
| mostlyclean-libtool: | mostlyclean-libtool: | ||||||
| 	-rm -f *.lo | 	-rm -f *.lo | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										108
									
								
								newlib/libc/locale/lctype.c
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										108
									
								
								newlib/libc/locale/lctype.c
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,108 @@ | |||||||
|  | /* | ||||||
|  |  * 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. | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | #include <limits.h> | ||||||
|  | #include "lctype.h" | ||||||
|  | #include "ldpart.h" | ||||||
|  |  | ||||||
|  | #define LCCTYPE_SIZE (sizeof(struct lc_ctype_T) / sizeof(char *)) | ||||||
|  |  | ||||||
|  | static char	numone[] = { '\1', '\0'}; | ||||||
|  |  | ||||||
|  | static const struct lc_ctype_T _C_ctype_locale = { | ||||||
|  | 	"ASCII",			/* codeset */ | ||||||
|  | 	numone				/* mb_cur_max */ | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 	, "0", "1", "2", "3", "4",	/* outdigits */ | ||||||
|  | 	"5", "6", "7", "8", "9", | ||||||
|  | 	L"0", L"1", L"2", L"3", L"4",	/* woutdigits */ | ||||||
|  | 	L"5", L"6", L"7", L"8", L"9" | ||||||
|  | #endif | ||||||
|  | }; | ||||||
|  |  | ||||||
|  | static struct lc_ctype_T _ctype_locale; | ||||||
|  | static int	_ctype_using_locale; | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | static char	*_ctype_locale_buf; | ||||||
|  | #else | ||||||
|  | /* Max encoding_len + NUL byte + 1 byte mb_cur_max plus trailing NUL byte */ | ||||||
|  | #define _CTYPE_BUF_SIZE	(ENCODING_LEN + 3) | ||||||
|  | static char _ctype_locale_buf[_CTYPE_BUF_SIZE]; | ||||||
|  | #endif | ||||||
|  |  | ||||||
|  | int | ||||||
|  | __ctype_load_locale(const char *name, void *f_wctomb, const char *charset, | ||||||
|  | 		    int mb_cur_max) | ||||||
|  | { | ||||||
|  | 	int ret; | ||||||
|  |  | ||||||
|  | #ifdef __CYGWIN__ | ||||||
|  | 	extern int __set_lc_ctype_from_win (const char *, | ||||||
|  | 					    const struct lc_ctype_T *, | ||||||
|  | 					    struct lc_ctype_T *, char **, | ||||||
|  | 					    void *, const char *, int); | ||||||
|  | 	int old_ctype_using_locale = _ctype_using_locale; | ||||||
|  | 	_ctype_using_locale = 0; | ||||||
|  | 	ret = __set_lc_ctype_from_win (name, &_C_ctype_locale, &_ctype_locale, | ||||||
|  | 				       &_ctype_locale_buf, f_wctomb, charset, | ||||||
|  | 				       mb_cur_max); | ||||||
|  | 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | ||||||
|  | 	if (ret < 0) | ||||||
|  | 	  _ctype_using_locale = old_ctype_using_locale; | ||||||
|  | 	else | ||||||
|  | 	  { | ||||||
|  | 	    _ctype_using_locale = ret; | ||||||
|  | 	    ret = 0; | ||||||
|  | 	  } | ||||||
|  | #elif !defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|  | 	if (!strcmp (name, "C")) | ||||||
|  | 	  _ctype_using_locale = 0; | ||||||
|  | 	else | ||||||
|  | 	  { | ||||||
|  | 	    _ctype_locale.codeset = _ctype_locale_buf; | ||||||
|  | 	    _ctype_locale.mb_cur_max = _ctype_locale_buf + _CTYPE_BUF_SIZE - 2; | ||||||
|  | 	    strcpy (_ctype_locale.codeset, charset); | ||||||
|  | 	    _ctype_locale.mb_cur_max[0] = mb_cur_max; | ||||||
|  | 	    _ctype_locale.mb_cur_max[1] = '\0'; | ||||||
|  | 	    _ctype_using_locale = 1; | ||||||
|  | 	  } | ||||||
|  | 	ret = 0; | ||||||
|  | #else | ||||||
|  | 	ret = __part_load_locale(name, &_ctype_using_locale, | ||||||
|  | 		_ctype_locale_buf, "LC_CTYPE", | ||||||
|  | 		LCCTYPE_SIZE, LCCTYPE_SIZE, | ||||||
|  | 		(const char **)&_ctype_locale); | ||||||
|  | 	if (ret == 0 && _ctype_using_locale) | ||||||
|  | 		_ctype_locale.grouping = | ||||||
|  | 			__fix_locale_grouping_str(_ctype_locale.grouping); | ||||||
|  | #endif | ||||||
|  | 	return ret; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | struct lc_ctype_T * | ||||||
|  | __get_current_ctype_locale(void) { | ||||||
|  |  | ||||||
|  | 	return (_ctype_using_locale | ||||||
|  | 		? &_ctype_locale | ||||||
|  | 		: (struct lc_ctype_T *)&_C_ctype_locale); | ||||||
|  | } | ||||||
							
								
								
									
										47
									
								
								newlib/libc/locale/lctype.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										47
									
								
								newlib/libc/locale/lctype.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,47 @@ | |||||||
|  | /* | ||||||
|  |  * 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(const char *, void *, const char *, int); | ||||||
|  |  | ||||||
|  | __END_DECLS | ||||||
|  |  | ||||||
|  | #endif /* !_LCTYPE_H_ */ | ||||||
| @@ -42,6 +42,13 @@ static const struct lc_messages_T _C_messages_locale = { | |||||||
| 	"^[nN]" ,	/* noexpr */ | 	"^[nN]" ,	/* noexpr */ | ||||||
| 	"yes" , 	/* yesstr */ | 	"yes" , 	/* yesstr */ | ||||||
| 	"no"		/* nostr */ | 	"no"		/* nostr */ | ||||||
|  | 	"ASCII"		/* codeset */ | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 	, L"^[yY]" ,	/* wyesexpr */ | ||||||
|  | 	L"^[nN]" ,	/* wnoexpr */ | ||||||
|  | 	L"yes" , 	/* wyesstr */ | ||||||
|  | 	L"no"		/* wnostr */ | ||||||
|  | #endif | ||||||
| }; | }; | ||||||
|  |  | ||||||
| static struct lc_messages_T _messages_locale; | static struct lc_messages_T _messages_locale; | ||||||
| @@ -53,13 +60,15 @@ __messages_load_locale (const char *name, void *f_wctomb, const char *charset) | |||||||
| { | { | ||||||
| #ifdef __CYGWIN__ | #ifdef __CYGWIN__ | ||||||
| 	extern int __set_lc_messages_from_win (const char *, | 	extern int __set_lc_messages_from_win (const char *, | ||||||
|  | 					       const struct lc_messages_T *, | ||||||
| 					       struct lc_messages_T *, char **, | 					       struct lc_messages_T *, char **, | ||||||
| 					       void *, const char *); | 					       void *, const char *); | ||||||
| 	int ret; | 	int ret; | ||||||
|  |  | ||||||
| 	int old_messages_using_locale = _messages_using_locale; | 	int old_messages_using_locale = _messages_using_locale; | ||||||
| 	_messages_using_locale = 0; | 	_messages_using_locale = 0; | ||||||
| 	ret = __set_lc_messages_from_win (name, &_messages_locale, | 	ret = __set_lc_messages_from_win (name, &_C_messages_locale, | ||||||
|  | 					  &_messages_locale, | ||||||
| 					  &_messages_locale_buf, | 					  &_messages_locale_buf, | ||||||
| 					  f_wctomb, charset); | 					  f_wctomb, charset); | ||||||
| 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | ||||||
|   | |||||||
| @@ -29,7 +29,9 @@ | |||||||
| #ifndef _LMESSAGES_H_ | #ifndef _LMESSAGES_H_ | ||||||
| #define	_LMESSAGES_H_ | #define	_LMESSAGES_H_ | ||||||
|  |  | ||||||
|  | #include <_ansi.h> | ||||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||||
|  | #include <wchar.h> | ||||||
|  |  | ||||||
| __BEGIN_DECLS | __BEGIN_DECLS | ||||||
|  |  | ||||||
| @@ -38,6 +40,13 @@ struct	lc_messages_T { | |||||||
| 	const char	*noexpr; | 	const char	*noexpr; | ||||||
| 	const char	*yesstr; | 	const char	*yesstr; | ||||||
| 	const char	*nostr; | 	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); | struct lc_messages_T *__get_current_messages_locale(void); | ||||||
|   | |||||||
| @@ -38,6 +38,9 @@ extern const char * __fix_locale_grouping_str(const char *); | |||||||
|  |  | ||||||
| static char	empty[] = ""; | static char	empty[] = ""; | ||||||
| static char	numempty[] = { CHAR_MAX, '\0'}; | static char	numempty[] = { CHAR_MAX, '\0'}; | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | static wchar_t	wempty[] = L""; | ||||||
|  | #endif | ||||||
|  |  | ||||||
| static const struct lc_monetary_T _C_monetary_locale = { | static const struct lc_monetary_T _C_monetary_locale = { | ||||||
| 	empty,		/* int_curr_symbol */ | 	empty,		/* int_curr_symbol */ | ||||||
| @@ -55,6 +58,21 @@ static const struct lc_monetary_T _C_monetary_locale = { | |||||||
| 	numempty,	/* n_sep_by_space */ | 	numempty,	/* n_sep_by_space */ | ||||||
| 	numempty,	/* p_sign_posn */ | 	numempty,	/* p_sign_posn */ | ||||||
| 	numempty	/* n_sign_posn */ | 	numempty	/* n_sign_posn */ | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 	, numempty,	/* int_p_cs_precedes */ | ||||||
|  | 	numempty,	/* int_p_sep_by_space */ | ||||||
|  | 	numempty,	/* int_n_cs_precedes */ | ||||||
|  | 	numempty,	/* int_n_sep_by_space */ | ||||||
|  | 	numempty,	/* int_p_sign_posn */ | ||||||
|  | 	numempty,	/* int_n_sign_posn */ | ||||||
|  | 	"ASCII",	/* codeset */ | ||||||
|  | 	wempty,		/* wint_curr_symbol */ | ||||||
|  | 	wempty,		/* wcurrency_symbol */ | ||||||
|  | 	wempty,		/* wmon_decimal_point */ | ||||||
|  | 	wempty,		/* wmon_thousands_sep */ | ||||||
|  | 	wempty,		/* wpositive_sign */ | ||||||
|  | 	wempty		/* wnegative_sign */ | ||||||
|  | #endif | ||||||
| }; | }; | ||||||
|  |  | ||||||
| static struct lc_monetary_T _monetary_locale; | static struct lc_monetary_T _monetary_locale; | ||||||
| @@ -76,11 +94,13 @@ __monetary_load_locale(const char *name , void *f_wctomb, const char *charset) | |||||||
|  |  | ||||||
| #ifdef __CYGWIN__ | #ifdef __CYGWIN__ | ||||||
| 	extern int __set_lc_monetary_from_win (const char *, | 	extern int __set_lc_monetary_from_win (const char *, | ||||||
|  | 					       const struct lc_monetary_T *, | ||||||
| 					       struct lc_monetary_T *, char **, | 					       struct lc_monetary_T *, char **, | ||||||
| 					       void *, const char *); | 					       void *, const char *); | ||||||
| 	int old_monetary_using_locale = _monetary_using_locale; | 	int old_monetary_using_locale = _monetary_using_locale; | ||||||
| 	_monetary_using_locale = 0; | 	_monetary_using_locale = 0; | ||||||
| 	ret = __set_lc_monetary_from_win (name, &_monetary_locale, | 	ret = __set_lc_monetary_from_win (name, &_C_monetary_locale, | ||||||
|  | 					  &_monetary_locale, | ||||||
| 					  &_monetary_locale_buf, | 					  &_monetary_locale_buf, | ||||||
| 					  f_wctomb, charset); | 					  f_wctomb, charset); | ||||||
| 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | ||||||
|   | |||||||
| @@ -29,7 +29,9 @@ | |||||||
| #ifndef _LMONETARY_H_ | #ifndef _LMONETARY_H_ | ||||||
| #define	_LMONETARY_H_ | #define	_LMONETARY_H_ | ||||||
|  |  | ||||||
|  | #include <_ansi.h> | ||||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||||
|  | #include <wchar.h> | ||||||
|  |  | ||||||
| __BEGIN_DECLS | __BEGIN_DECLS | ||||||
|  |  | ||||||
| @@ -49,6 +51,21 @@ struct lc_monetary_T { | |||||||
| 	const char	*n_sep_by_space; | 	const char	*n_sep_by_space; | ||||||
| 	const char	*p_sign_posn; | 	const char	*p_sign_posn; | ||||||
| 	const char	*n_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); | struct lc_monetary_T *__get_current_monetary_locale(void); | ||||||
|   | |||||||
| @@ -24,8 +24,6 @@ | |||||||
|  * SUCH DAMAGE. |  * SUCH DAMAGE. | ||||||
|  */ |  */ | ||||||
|  |  | ||||||
| #include <sys/cdefs.h> |  | ||||||
|  |  | ||||||
| #include <limits.h> | #include <limits.h> | ||||||
| #include "lnumeric.h" | #include "lnumeric.h" | ||||||
| #include "ldpart.h" | #include "ldpart.h" | ||||||
| @@ -38,9 +36,14 @@ extern const char *__fix_locale_grouping_str(const char *); | |||||||
| static char	numempty[] = { CHAR_MAX, '\0' }; | static char	numempty[] = { CHAR_MAX, '\0' }; | ||||||
|  |  | ||||||
| static const struct lc_numeric_T _C_numeric_locale = { | static const struct lc_numeric_T _C_numeric_locale = { | ||||||
| 	".",     	/* decimal_point */ | 	".",     			/* decimal_point */ | ||||||
| 	"",     	/* thousands_sep */ | 	"",     			/* thousands_sep */ | ||||||
| 	numempty	/* grouping */ | 	numempty			/* grouping */ | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 	, "ASCII",			/* codeset */ | ||||||
|  | 	L".",				/* wdecimal_point */ | ||||||
|  | 	L"",				/* wthousands_sep */ | ||||||
|  | #endif | ||||||
| }; | }; | ||||||
|  |  | ||||||
| static struct lc_numeric_T _numeric_locale; | static struct lc_numeric_T _numeric_locale; | ||||||
| @@ -54,12 +57,13 @@ __numeric_load_locale(const char *name , void *f_wctomb, const char *charset) | |||||||
|  |  | ||||||
| #ifdef __CYGWIN__ | #ifdef __CYGWIN__ | ||||||
| 	extern int __set_lc_numeric_from_win (const char *, | 	extern int __set_lc_numeric_from_win (const char *, | ||||||
|  | 					      const struct lc_numeric_T *, | ||||||
| 					      struct lc_numeric_T *, char **, | 					      struct lc_numeric_T *, char **, | ||||||
| 					      void *, const char *); | 					      void *, const char *); | ||||||
| 	int old_numeric_using_locale = _numeric_using_locale; | 	int old_numeric_using_locale = _numeric_using_locale; | ||||||
| 	_numeric_using_locale = 0; | 	_numeric_using_locale = 0; | ||||||
| 	ret = __set_lc_numeric_from_win (name, &_numeric_locale, | 	ret = __set_lc_numeric_from_win (name, &_C_numeric_locale, | ||||||
| 					 &_numeric_locale_buf, | 					 &_numeric_locale, &_numeric_locale_buf, | ||||||
| 					 f_wctomb, charset); | 					 f_wctomb, charset); | ||||||
| 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | ||||||
| 	if (ret < 0) | 	if (ret < 0) | ||||||
|   | |||||||
| @@ -29,7 +29,9 @@ | |||||||
| #ifndef _LNUMERIC_H_ | #ifndef _LNUMERIC_H_ | ||||||
| #define	_LNUMERIC_H_ | #define	_LNUMERIC_H_ | ||||||
|  |  | ||||||
|  | #include <_ansi.h> | ||||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||||
|  | #include <wchar.h> | ||||||
|  |  | ||||||
| __BEGIN_DECLS | __BEGIN_DECLS | ||||||
|  |  | ||||||
| @@ -37,6 +39,11 @@ struct lc_numeric_T { | |||||||
| 	const char	*decimal_point; | 	const char	*decimal_point; | ||||||
| 	const char	*thousands_sep; | 	const char	*thousands_sep; | ||||||
| 	const char	*grouping; | 	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); | struct lc_numeric_T *__get_current_numeric_locale(void); | ||||||
|   | |||||||
| @@ -179,8 +179,10 @@ No supporting OS subroutines are required. | |||||||
| #include <reent.h> | #include <reent.h> | ||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <wchar.h> | #include <wchar.h> | ||||||
|  | #include "lmessages.h" | ||||||
| #include "lmonetary.h" | #include "lmonetary.h" | ||||||
| #include "lnumeric.h" | #include "lnumeric.h" | ||||||
|  | #include "lctype.h" | ||||||
| #include "../stdlib/local.h" | #include "../stdlib/local.h" | ||||||
|  |  | ||||||
| #define _LC_LAST      7 | #define _LC_LAST      7 | ||||||
| @@ -457,6 +459,11 @@ loadlocale(struct _reent *p, int category) | |||||||
|   int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t, |   int (*l_mbtowc) (struct _reent *, wchar_t *, const char *, size_t, | ||||||
| 		   const char *, mbstate_t *); | 		   const char *, mbstate_t *); | ||||||
|   int cjknarrow = 0; |   int cjknarrow = 0; | ||||||
|  |  | ||||||
|  |   /* Avoid doing everything twice if nothing has changed. */ | ||||||
|  |   if (!strcmp (new_categories[category], current_categories[category])) | ||||||
|  |     return current_categories[category]; | ||||||
|  |  | ||||||
| #ifdef __CYGWIN__ | #ifdef __CYGWIN__ | ||||||
|   /* This additional code handles the case that the incoming locale string |   /* 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, |      is not valid.  If so, it calls the function __set_locale_from_locale_alias, | ||||||
| @@ -830,8 +837,9 @@ restart: | |||||||
|     default: |     default: | ||||||
|       FAIL; |       FAIL; | ||||||
|     } |     } | ||||||
|   if (category == LC_CTYPE) |   switch (category) | ||||||
|     { |     { | ||||||
|  |     case LC_CTYPE: | ||||||
|       strcpy (lc_ctype_charset, charset); |       strcpy (lc_ctype_charset, charset); | ||||||
|       __mb_cur_max = mbc_max; |       __mb_cur_max = mbc_max; | ||||||
|       __wctomb = l_wctomb; |       __wctomb = l_wctomb; | ||||||
| @@ -847,27 +855,36 @@ restart: | |||||||
| 			  && ((strncmp (locale, "ja", 2) == 0 | 			  && ((strncmp (locale, "ja", 2) == 0 | ||||||
| 			      || strncmp (locale, "ko", 2) == 0 | 			      || strncmp (locale, "ko", 2) == 0 | ||||||
| 			      || strncmp (locale, "zh", 2) == 0)); | 			      || strncmp (locale, "zh", 2) == 0)); | ||||||
|     } | #ifdef __HAVE_LOCALE_INFO__ | ||||||
|   else if (category == LC_MESSAGES) |       ret = __ctype_load_locale (locale, (void *) l_wctomb, charset, mbc_max); | ||||||
|     { | #endif /* __HAVE_LOCALE_INFO__ */ | ||||||
|  |       break; | ||||||
|  |     case LC_MESSAGES: | ||||||
|  |       strcpy (lc_message_charset, charset); | ||||||
| #ifdef __HAVE_LOCALE_INFO__ | #ifdef __HAVE_LOCALE_INFO__ | ||||||
|       ret = __messages_load_locale (locale, (void *) l_wctomb, charset); |       ret = __messages_load_locale (locale, (void *) l_wctomb, charset); | ||||||
|       if (!ret) |       if (!ret) | ||||||
| #endif /* __HAVE_LOCALE_INFO__ */ | #endif /* __HAVE_LOCALE_INFO__ */ | ||||||
|       strcpy (lc_message_charset, charset); |       break; | ||||||
|     } |  | ||||||
| #ifdef __HAVE_LOCALE_INFO__ | #ifdef __HAVE_LOCALE_INFO__ | ||||||
| #ifdef __CYGWIN__ | #ifdef __CYGWIN__ | ||||||
|   /* Right now only Cygwin supports a __collate_load_locale function at all. */ |   /* Right now only Cygwin supports a __collate_load_locale function at all. */ | ||||||
|   else if (category == LC_COLLATE) |     case LC_COLLATE: | ||||||
|     ret = __collate_load_locale (locale, (void *) l_mbtowc, charset); |       ret = __collate_load_locale (locale, (void *) l_mbtowc, charset); | ||||||
|  |       break; | ||||||
| #endif | #endif | ||||||
|   else if (category == LC_MONETARY) |     case LC_MONETARY: | ||||||
|     ret = __monetary_load_locale (locale, (void *) l_wctomb, charset); |       ret = __monetary_load_locale (locale, (void *) l_wctomb, charset); | ||||||
|   else if (category == LC_NUMERIC) |       break; | ||||||
|     ret = __numeric_load_locale (locale, (void *) l_wctomb, charset); |     case LC_NUMERIC: | ||||||
|   else if (category == LC_TIME) |       ret = __numeric_load_locale (locale, (void *) l_wctomb, charset); | ||||||
|     ret = __time_load_locale (locale, (void *) l_wctomb, charset); |       break; | ||||||
|  |     case LC_TIME: | ||||||
|  |       ret = __time_load_locale (locale, (void *) l_wctomb, charset); | ||||||
|  |       break; | ||||||
|  |     default: | ||||||
|  |       break; | ||||||
|  |     } | ||||||
|   if (ret) |   if (ret) | ||||||
|     FAIL; |     FAIL; | ||||||
| #endif /* __HAVE_LOCALE_INFO__ */ | #endif /* __HAVE_LOCALE_INFO__ */ | ||||||
| @@ -901,13 +918,32 @@ __get_locale_env(struct _reent *p, int category) | |||||||
| char * | char * | ||||||
| _DEFUN_VOID(__locale_charset) | _DEFUN_VOID(__locale_charset) | ||||||
| { | { | ||||||
|  | #if 0//def __HAVE_LOCALE_INFO__ | ||||||
|  |   return __get_current_ctype_locale ()->codeset; | ||||||
|  | #else | ||||||
|   return lc_ctype_charset; |   return lc_ctype_charset; | ||||||
|  | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
|  | int | ||||||
|  | _DEFUN_VOID(__locale_mb_cur_max) | ||||||
|  | { | ||||||
|  | #if 0//def __HAVE_LOCALE_INFO__ | ||||||
|  |   return __get_current_ctype_locale ()->mb_cur_max[0]; | ||||||
|  | #else | ||||||
|  |   return __mb_cur_max; | ||||||
|  | #endif | ||||||
|  | } | ||||||
|  |  | ||||||
|  |  | ||||||
| char * | char * | ||||||
| _DEFUN_VOID(__locale_msgcharset) | _DEFUN_VOID(__locale_msgcharset) | ||||||
| { | { | ||||||
|  | #ifdef __HAVE_LOCALE_INFO__ | ||||||
|  |   return __get_current_messages_locale ()->codeset; | ||||||
|  | #else | ||||||
|   return lc_message_charset; |   return lc_message_charset; | ||||||
|  | #endif | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
| @@ -947,12 +983,21 @@ _DEFUN(_localeconv_r, (data), | |||||||
|       lconv.n_sep_by_space = m->n_sep_by_space[0]; |       lconv.n_sep_by_space = m->n_sep_by_space[0]; | ||||||
|       lconv.p_sign_posn = m->p_sign_posn[0]; |       lconv.p_sign_posn = m->p_sign_posn[0]; | ||||||
|       lconv.n_sign_posn = m->n_sign_posn[0]; |       lconv.n_sign_posn = m->n_sign_posn[0]; | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  |       lconv.int_p_cs_precedes = m->int_p_cs_precedes[0]; | ||||||
|  |       lconv.int_p_sep_by_space = m->int_p_sep_by_space[0]; | ||||||
|  |       lconv.int_n_cs_precedes = m->int_n_cs_precedes[0]; | ||||||
|  |       lconv.int_n_sep_by_space = m->int_n_sep_by_space[0]; | ||||||
|  |       lconv.int_n_sign_posn = m->int_n_sign_posn[0]; | ||||||
|  |       lconv.int_p_sign_posn = m->int_p_sign_posn[0]; | ||||||
|  | #else /* !__HAVE_LOCALE_INFO_EXTENDED__ */ | ||||||
|  |       lconv.int_p_cs_precedes = m->p_cs_precedes[0]; | ||||||
|  |       lconv.int_p_sep_by_space = m->p_sep_by_space[0]; | ||||||
|       lconv.int_n_cs_precedes = m->n_cs_precedes[0]; |       lconv.int_n_cs_precedes = m->n_cs_precedes[0]; | ||||||
|       lconv.int_n_sep_by_space = m->n_sep_by_space[0]; |       lconv.int_n_sep_by_space = m->n_sep_by_space[0]; | ||||||
|       lconv.int_n_sign_posn = m->n_sign_posn[0]; |       lconv.int_n_sign_posn = m->n_sign_posn[0]; | ||||||
|       lconv.int_p_cs_precedes = m->p_cs_precedes[0]; |  | ||||||
|       lconv.int_p_sep_by_space = m->p_sep_by_space[0]; |  | ||||||
|       lconv.int_p_sign_posn = m->p_sign_posn[0]; |       lconv.int_p_sign_posn = m->p_sign_posn[0]; | ||||||
|  | #endif /* !__HAVE_LOCALE_INFO_EXTENDED__ */ | ||||||
|       __mlocale_changed = 0; |       __mlocale_changed = 0; | ||||||
|     } |     } | ||||||
| #endif /* __HAVE_LOCALE_INFO__ */ | #endif /* __HAVE_LOCALE_INFO__ */ | ||||||
|   | |||||||
| @@ -32,6 +32,7 @@ | |||||||
| #include <stdlib.h> | #include <stdlib.h> | ||||||
| #include <string.h> | #include <string.h> | ||||||
|  |  | ||||||
|  | #include "lctype.h" | ||||||
| #include "timelocal.h" | #include "timelocal.h" | ||||||
| #include "lnumeric.h" | #include "lnumeric.h" | ||||||
| #include "lmonetary.h" | #include "lmonetary.h" | ||||||
| @@ -41,6 +42,138 @@ | |||||||
| #define TRANSITION_PERIOD_HACK | #define TRANSITION_PERIOD_HACK | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
|  | #undef offsetoff | ||||||
|  | #define _O(TYPE, MEMBER)  __builtin_offsetof (TYPE, MEMBER) | ||||||
|  |  | ||||||
|  | #define _NLITEM(cat,memb) { { cat:__get_current_##cat##_locale }, \ | ||||||
|  | 			      _O (struct lc_##cat##_T, memb) } | ||||||
|  |  | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 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); | ||||||
|  |     void *		   (*base)(void); | ||||||
|  |   }; | ||||||
|  |   _off_t offset; | ||||||
|  | } nl_ext[] = | ||||||
|  | { | ||||||
|  |   /* First element has an nl_item value of _NL_LOCALE_EXTENDED_FIRST_ENTRY */ | ||||||
|  |   _NLITEM (ctype, outdigits[0]), | ||||||
|  |   _NLITEM (ctype, outdigits[1]), | ||||||
|  |   _NLITEM (ctype, outdigits[2]), | ||||||
|  |   _NLITEM (ctype, outdigits[3]), | ||||||
|  |   _NLITEM (ctype, outdigits[4]), | ||||||
|  |   _NLITEM (ctype, outdigits[5]), | ||||||
|  |   _NLITEM (ctype, outdigits[6]), | ||||||
|  |   _NLITEM (ctype, outdigits[7]), | ||||||
|  |   _NLITEM (ctype, outdigits[8]), | ||||||
|  |   _NLITEM (ctype, outdigits[9]), | ||||||
|  |   _NLITEM (ctype, woutdigits[0]), | ||||||
|  |   _NLITEM (ctype, woutdigits[1]), | ||||||
|  |   _NLITEM (ctype, woutdigits[2]), | ||||||
|  |   _NLITEM (ctype, woutdigits[3]), | ||||||
|  |   _NLITEM (ctype, woutdigits[4]), | ||||||
|  |   _NLITEM (ctype, woutdigits[5]), | ||||||
|  |   _NLITEM (ctype, woutdigits[6]), | ||||||
|  |   _NLITEM (ctype, woutdigits[7]), | ||||||
|  |   _NLITEM (ctype, woutdigits[8]), | ||||||
|  |   _NLITEM (ctype, woutdigits[9]), | ||||||
|  |   _NLITEM (time, codeset), | ||||||
|  |   _NLITEM (time, wmon[1]), | ||||||
|  |   _NLITEM (time, wmon[2]), | ||||||
|  |   _NLITEM (time, wmon[3]), | ||||||
|  |   _NLITEM (time, wmon[4]), | ||||||
|  |   _NLITEM (time, wmon[5]), | ||||||
|  |   _NLITEM (time, wmon[6]), | ||||||
|  |   _NLITEM (time, wmon[7]), | ||||||
|  |   _NLITEM (time, wmon[8]), | ||||||
|  |   _NLITEM (time, wmon[9]), | ||||||
|  |   _NLITEM (time, wmon[10]), | ||||||
|  |   _NLITEM (time, wmon[11]), | ||||||
|  |   _NLITEM (time, wmon[12]), | ||||||
|  |   _NLITEM (time, wmonth[1]), | ||||||
|  |   _NLITEM (time, wmonth[2]), | ||||||
|  |   _NLITEM (time, wmonth[3]), | ||||||
|  |   _NLITEM (time, wmonth[4]), | ||||||
|  |   _NLITEM (time, wmonth[5]), | ||||||
|  |   _NLITEM (time, wmonth[6]), | ||||||
|  |   _NLITEM (time, wmonth[7]), | ||||||
|  |   _NLITEM (time, wmonth[8]), | ||||||
|  |   _NLITEM (time, wmonth[9]), | ||||||
|  |   _NLITEM (time, wmonth[10]), | ||||||
|  |   _NLITEM (time, wmonth[11]), | ||||||
|  |   _NLITEM (time, wmonth[12]), | ||||||
|  |   _NLITEM (time, wwday[1]), | ||||||
|  |   _NLITEM (time, wwday[2]), | ||||||
|  |   _NLITEM (time, wwday[3]), | ||||||
|  |   _NLITEM (time, wwday[4]), | ||||||
|  |   _NLITEM (time, wwday[5]), | ||||||
|  |   _NLITEM (time, wwday[6]), | ||||||
|  |   _NLITEM (time, wwday[7]), | ||||||
|  |   _NLITEM (time, wweekday[1]), | ||||||
|  |   _NLITEM (time, wweekday[2]), | ||||||
|  |   _NLITEM (time, wweekday[3]), | ||||||
|  |   _NLITEM (time, wweekday[4]), | ||||||
|  |   _NLITEM (time, wweekday[5]), | ||||||
|  |   _NLITEM (time, wweekday[6]), | ||||||
|  |   _NLITEM (time, wweekday[7]), | ||||||
|  |   _NLITEM (time, wX_fmt), | ||||||
|  |   _NLITEM (time, wx_fmt), | ||||||
|  |   _NLITEM (time, wc_fmt), | ||||||
|  |   _NLITEM (time, wam_pm[0]), | ||||||
|  |   _NLITEM (time, wam_pm[1]), | ||||||
|  |   _NLITEM (time, wdate_fmt), | ||||||
|  |   _NLITEM (time, wampm_fmt), | ||||||
|  |   _NLITEM (time, wera), | ||||||
|  |   _NLITEM (time, wera_d_fmt), | ||||||
|  |   _NLITEM (time, wera_d_t_fmt), | ||||||
|  |   _NLITEM (time, wera_t_fmt), | ||||||
|  |   _NLITEM (time, walt_digits), | ||||||
|  |   _NLITEM (numeric, codeset), | ||||||
|  |   _NLITEM (numeric, grouping), | ||||||
|  |   _NLITEM (numeric, wdecimal_point), | ||||||
|  |   _NLITEM (numeric, wthousands_sep), | ||||||
|  |   _NLITEM (monetary, int_curr_symbol), | ||||||
|  |   _NLITEM (monetary, currency_symbol), | ||||||
|  |   _NLITEM (monetary, mon_decimal_point), | ||||||
|  |   _NLITEM (monetary, mon_thousands_sep), | ||||||
|  |   _NLITEM (monetary, mon_grouping), | ||||||
|  |   _NLITEM (monetary, positive_sign), | ||||||
|  |   _NLITEM (monetary, negative_sign), | ||||||
|  |   _NLITEM (monetary, int_frac_digits), | ||||||
|  |   _NLITEM (monetary, frac_digits), | ||||||
|  |   _NLITEM (monetary, p_cs_precedes), | ||||||
|  |   _NLITEM (monetary, p_sep_by_space), | ||||||
|  |   _NLITEM (monetary, n_cs_precedes), | ||||||
|  |   _NLITEM (monetary, n_sep_by_space), | ||||||
|  |   _NLITEM (monetary, p_sign_posn), | ||||||
|  |   _NLITEM (monetary, n_sign_posn), | ||||||
|  |   _NLITEM (monetary, int_p_cs_precedes), | ||||||
|  |   _NLITEM (monetary, int_p_sep_by_space), | ||||||
|  |   _NLITEM (monetary, int_n_cs_precedes), | ||||||
|  |   _NLITEM (monetary, int_n_sep_by_space), | ||||||
|  |   _NLITEM (monetary, int_p_sign_posn), | ||||||
|  |   _NLITEM (monetary, int_n_sign_posn), | ||||||
|  |   _NLITEM (monetary, codeset), | ||||||
|  |   _NLITEM (monetary, wint_curr_symbol), | ||||||
|  |   _NLITEM (monetary, wcurrency_symbol), | ||||||
|  |   _NLITEM (monetary, wmon_decimal_point), | ||||||
|  |   _NLITEM (monetary, wmon_thousands_sep), | ||||||
|  |   _NLITEM (monetary, wpositive_sign), | ||||||
|  |   _NLITEM (monetary, wnegative_sign), | ||||||
|  |   _NLITEM (messages, codeset), | ||||||
|  |   _NLITEM (messages, wyesexpr), | ||||||
|  |   _NLITEM (messages, wnoexpr), | ||||||
|  |   _NLITEM (messages, wyesstr), | ||||||
|  |   _NLITEM (messages, wnostr), | ||||||
|  | }; | ||||||
|  | #endif /* __HAVE_LOCALE_INFO_EXTENDED__ */ | ||||||
|  |  | ||||||
| #define _REL(BASE) ((int)item-BASE) | #define _REL(BASE) ((int)item-BASE) | ||||||
|  |  | ||||||
| extern char *__locale_charset (); | extern char *__locale_charset (); | ||||||
| @@ -57,9 +190,36 @@ _DEFUN(nl_langinfo, (item), | |||||||
|    char *nptr; |    char *nptr; | ||||||
|  |  | ||||||
|    switch (item) { |    switch (item) { | ||||||
|  | #ifdef __HAVE_LOCALE_INFO__ | ||||||
|  | 	case _NL_MESSAGES_CODESET: | ||||||
|  | 	      	ret = (char *) __get_current_messages_locale ()->codeset; | ||||||
|  | 		goto do_codeset; | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 	case _NL_TIME_CODESET: | ||||||
|  | 	      	ret = (char *) __get_current_time_locale ()->codeset; | ||||||
|  | 		goto do_codeset; | ||||||
|  | 	case _NL_NUMERIC_CODESET: | ||||||
|  | 	      	ret = (char *) __get_current_numeric_locale ()->codeset; | ||||||
|  | 		goto do_codeset; | ||||||
|  | 	case _NL_MONETARY_CODESET: | ||||||
|  | 	      	ret = (char *) __get_current_monetary_locale ()->codeset; | ||||||
|  | 		goto do_codeset; | ||||||
|  | #ifdef __CYGWIN__ | ||||||
|  | 	case _NL_COLLATE_CODESET: | ||||||
|  | 		{ | ||||||
|  | 		  extern const char *__get_current_collate_codeset (void); | ||||||
|  | 		  ret = (char *) __get_current_collate_codeset (); | ||||||
|  | 		  goto do_codeset; | ||||||
|  | 		} | ||||||
|  | #endif /* __CYGWIN__ */ | ||||||
|  | #endif /* __HAVE_LOCALE_INFO_EXTENDED__ */ | ||||||
|  | #endif /* __HAVE_LOCALE_INFO__ */ | ||||||
| 	case CODESET: | 	case CODESET: | ||||||
| #ifdef __CYGWIN__ | #ifdef __CYGWIN__ | ||||||
| 		ret = __locale_charset (); | 		ret = __locale_charset (); | ||||||
|  | #endif | ||||||
|  | do_codeset: | ||||||
|  | #ifdef __CYGWIN__ | ||||||
| 		/* Convert charset to Linux compatible codeset string. */ | 		/* Convert charset to Linux compatible codeset string. */ | ||||||
| 		if (ret[0] == 'A'/*SCII*/) | 		if (ret[0] == 'A'/*SCII*/) | ||||||
| 		  ret = "ANSI_X3.4-1968"; | 		  ret = "ANSI_X3.4-1968"; | ||||||
| @@ -252,7 +412,18 @@ _DEFUN(nl_langinfo, (item), | |||||||
| 	case D_MD_ORDER:        /* local extension */ | 	case D_MD_ORDER:        /* local extension */ | ||||||
| 		ret = (char *) __get_current_time_locale()->md_order; | 		ret = (char *) __get_current_time_locale()->md_order; | ||||||
| 		break; | 		break; | ||||||
|  | 	case _NL_CTYPE_MB_CUR_MAX: | ||||||
|  | 		ret = (char *) __get_current_ctype_locale()->mb_cur_max; | ||||||
|  | 		break; | ||||||
| 	default: | 	default: | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 		if (item > _NL_LOCALE_EXTENDED_FIRST_ENTRY | ||||||
|  | 		    && item < _NL_LOCALE_EXTENDED_LAST_ENTRY) { | ||||||
|  | 			int idx = item - _NL_LOCALE_EXTENDED_FIRST_ENTRY - 1; | ||||||
|  | 			return *(char **) ((char *) (*nl_ext[idx].base)() | ||||||
|  | 					   + nl_ext[idx].offset); | ||||||
|  | 		} | ||||||
|  | #endif | ||||||
| 		ret = ""; | 		ret = ""; | ||||||
|    } |    } | ||||||
|    return (ret); |    return (ret); | ||||||
|   | |||||||
| @@ -119,6 +119,34 @@ static const struct lc_time_T	_C_time_locale = { | |||||||
| 	 * Alternate digits used if %O format prefix is specified | 	 * Alternate digits used if %O format prefix is specified | ||||||
| 	 */ | 	 */ | ||||||
| 	"" | 	"" | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 	, "ASCII",	/* codeset */ | ||||||
|  | 	{ | ||||||
|  | 		L"Jan", L"Feb", L"Mar", L"Apr", L"May", L"Jun", | ||||||
|  | 		L"Jul", L"Aug", L"Sep", L"Oct", L"Nov", L"Dec" | ||||||
|  | 	}, { | ||||||
|  | 		L"January", L"February", L"March", L"April", L"May", L"June", | ||||||
|  | 		L"July", L"August", L"September", L"October", L"November", | ||||||
|  | 		L"December" | ||||||
|  | 	}, { | ||||||
|  | 		L"Sun", L"Mon", L"Tue", L"Wed", | ||||||
|  | 		L"Thu", L"Fri", L"Sat" | ||||||
|  | 	}, { | ||||||
|  | 		L"Sunday", L"Monday", L"Tuesday", L"Wednesday", | ||||||
|  | 		L"Thursday", L"Friday", L"Saturday" | ||||||
|  | 	}, | ||||||
|  | 	L"%H:%M:%S", | ||||||
|  | 	L"%m/%d/%y", | ||||||
|  | 	L"%a %b %e %H:%M:%S %Y", | ||||||
|  | 	{ L"AM", L"PM" }, | ||||||
|  | 	L"%a %b %e %H:%M:%S %Z %Y", | ||||||
|  | 	L"%I:%M:%S %p", | ||||||
|  | 	L"", | ||||||
|  | 	L"", | ||||||
|  | 	L"", | ||||||
|  | 	L"", | ||||||
|  | 	L"" | ||||||
|  | #endif | ||||||
| }; | }; | ||||||
|  |  | ||||||
| struct lc_time_T * | struct lc_time_T * | ||||||
| @@ -134,12 +162,14 @@ __time_load_locale(const char *name, void *f_wctomb, const char *charset) { | |||||||
| 	int	ret; | 	int	ret; | ||||||
|  |  | ||||||
| #ifdef __CYGWIN__ | #ifdef __CYGWIN__ | ||||||
| 	extern int __set_lc_time_from_win (const char *, struct lc_time_T *, | 	extern int __set_lc_time_from_win (const char *, | ||||||
|  | 					   const struct lc_time_T *, | ||||||
|  | 					   struct lc_time_T *, | ||||||
| 					   char **, void *, const char *); | 					   char **, void *, const char *); | ||||||
| 	int old_time_using_locale = _time_using_locale; | 	int old_time_using_locale = _time_using_locale; | ||||||
| 	_time_using_locale = 0; | 	_time_using_locale = 0; | ||||||
| 	ret = __set_lc_time_from_win (name, &_time_locale, &time_locale_buf, | 	ret = __set_lc_time_from_win (name, &_C_time_locale, &_time_locale, | ||||||
| 				      f_wctomb, charset); | 				      &time_locale_buf, f_wctomb, charset); | ||||||
| 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | 	/* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ | ||||||
| 	if (ret < 0) | 	if (ret < 0) | ||||||
| 	  _time_using_locale = old_time_using_locale; | 	  _time_using_locale = old_time_using_locale; | ||||||
|   | |||||||
| @@ -29,7 +29,9 @@ | |||||||
| #ifndef _TIMELOCAL_H_ | #ifndef _TIMELOCAL_H_ | ||||||
| #define	_TIMELOCAL_H_ | #define	_TIMELOCAL_H_ | ||||||
|  |  | ||||||
|  | #include <_ansi.h> | ||||||
| #include <sys/cdefs.h> | #include <sys/cdefs.h> | ||||||
|  | #include <wchar.h> | ||||||
|  |  | ||||||
| __BEGIN_DECLS | __BEGIN_DECLS | ||||||
|  |  | ||||||
| @@ -47,7 +49,7 @@ struct lc_time_T { | |||||||
| 	const char	*c_fmt; | 	const char	*c_fmt; | ||||||
| 	const char	*am_pm[2]; | 	const char	*am_pm[2]; | ||||||
| 	const char	*date_fmt; | 	const char	*date_fmt; | ||||||
| 	const char	*alt_month[12]; | 	const char	*alt_month[12];	/* unused */ | ||||||
| 	const char	*md_order; | 	const char	*md_order; | ||||||
| 	const char	*ampm_fmt; | 	const char	*ampm_fmt; | ||||||
| 	const char	*era; | 	const char	*era; | ||||||
| @@ -55,6 +57,24 @@ struct lc_time_T { | |||||||
| 	const char	*era_d_t_fmt; | 	const char	*era_d_t_fmt; | ||||||
| 	const char	*era_t_fmt; | 	const char	*era_t_fmt; | ||||||
| 	const char	*alt_digits; | 	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); | struct lc_time_T *__get_current_time_locale(void); | ||||||
|   | |||||||
| @@ -130,6 +130,9 @@ SEEALSO | |||||||
| #include "local.h" | #include "local.h" | ||||||
| #include "fvwrite.h" | #include "fvwrite.h" | ||||||
| #include "vfieeefp.h" | #include "vfieeefp.h" | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | #include "../locale/lnumeric.h" | ||||||
|  | #endif | ||||||
|  |  | ||||||
| /* Currently a test is made to see if long double processing is warranted. | /* Currently a test is made to see if long double processing is warranted. | ||||||
|    This could be changed in the future should the _ldtoa_r code be |    This could be changed in the future should the _ldtoa_r code be | ||||||
| @@ -444,6 +447,9 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), | |||||||
|  |  | ||||||
| #ifdef FLOATING_POINT | #ifdef FLOATING_POINT | ||||||
| #ifdef _MB_CAPABLE | #ifdef _MB_CAPABLE | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 	decimal_point = *__get_current_numeric_locale ()->wdecimal_point; | ||||||
|  | #else | ||||||
| 	{ | 	{ | ||||||
| 	  size_t nconv; | 	  size_t nconv; | ||||||
|  |  | ||||||
| @@ -454,6 +460,7 @@ _DEFUN(_VFWPRINTF_R, (data, fp, fmt0, ap), | |||||||
| 	  if (nconv == (size_t) -1 || nconv == (size_t) -2) | 	  if (nconv == (size_t) -1 || nconv == (size_t) -2) | ||||||
| 	    decimal_point = L'.'; | 	    decimal_point = L'.'; | ||||||
| 	} | 	} | ||||||
|  | #endif | ||||||
| #else | #else | ||||||
| 	decimal_point = (wchar_t) *_localeconv_r (data)->decimal_point; | 	decimal_point = (wchar_t) *_localeconv_r (data)->decimal_point; | ||||||
| #endif | #endif | ||||||
| @@ -626,6 +633,9 @@ reswitch:	switch (ch) { | |||||||
| #ifdef _WANT_IO_C99_FORMATS | #ifdef _WANT_IO_C99_FORMATS | ||||||
| 		case L'\'': | 		case L'\'': | ||||||
| #ifdef _MB_CAPABLE | #ifdef _MB_CAPABLE | ||||||
|  | #ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|  | 		  thousands_sep = *__get_current_numeric_locale ()->wthousands_sep; | ||||||
|  | #else | ||||||
| 		  { | 		  { | ||||||
| 		    size_t nconv; | 		    size_t nconv; | ||||||
|  |  | ||||||
| @@ -636,6 +646,7 @@ reswitch:	switch (ch) { | |||||||
| 		    if (nconv == (size_t) -1 || nconv == (size_t) -2) | 		    if (nconv == (size_t) -1 || nconv == (size_t) -2) | ||||||
| 		      thousands_sep = L'\0'; | 		      thousands_sep = L'\0'; | ||||||
| 		  } | 		  } | ||||||
|  | #endif | ||||||
| #else | #else | ||||||
| 		  thousands_sep = (wchar_t) *_localeconv_r(data)->thousands_sep; | 		  thousands_sep = (wchar_t) *_localeconv_r(data)->thousands_sep; | ||||||
| #endif | #endif | ||||||
|   | |||||||
| @@ -260,6 +260,8 @@ BUGS | |||||||
| the "C" locale settings. | the "C" locale settings. | ||||||
| */ | */ | ||||||
|  |  | ||||||
|  | #include <newlib.h> | ||||||
|  | #include <sys/config.h> | ||||||
| #include <stddef.h> | #include <stddef.h> | ||||||
| #include <stdio.h> | #include <stdio.h> | ||||||
| #include <time.h> | #include <time.h> | ||||||
| @@ -300,18 +302,23 @@ the "C" locale settings. | |||||||
| #  define STRCHR(a,b)	wcschr((a),(b)) | #  define STRCHR(a,b)	wcschr((a),(b)) | ||||||
| #  define STRLEN(a)	wcslen(a) | #  define STRLEN(a)	wcslen(a) | ||||||
| #  define SFLG		"l"		/* %s flag (l for wide char) */ | #  define SFLG		"l"		/* %s flag (l for wide char) */ | ||||||
| #  define CTLOCBUFLEN   256		/* Arbitrary big buffer size */ | #  ifdef __HAVE_LOCALE_INFO_EXTENDED__ | ||||||
|    const wchar_t * | #   define _ctloc(x) (ctloclen = wcslen (ctloc = _CurrentTimeLocale->w##x), \ | ||||||
|    __ctloc (wchar_t *buf, const char *elem, size_t *len_ret) | 		      ctloc) | ||||||
|    { | #  else | ||||||
|      buf[CTLOCBUFLEN - 1] = L'\0'; | #   define CTLOCBUFLEN   256		/* Arbitrary big buffer size */ | ||||||
|      *len_ret = mbstowcs (buf, elem, CTLOCBUFLEN - 1); |     const wchar_t * | ||||||
|      if (*len_ret == (size_t) -1 ) |     __ctloc (wchar_t *buf, const char *elem, size_t *len_ret) | ||||||
|        *len_ret = 0; |     { | ||||||
|      return buf; |       buf[CTLOCBUFLEN - 1] = L'\0'; | ||||||
|    } |       *len_ret = mbstowcs (buf, elem, CTLOCBUFLEN - 1); | ||||||
| #  define _ctloc(x) (ctloc = __ctloc (ctlocbuf, _CurrentTimeLocale->x, \ |       if (*len_ret == (size_t) -1 ) | ||||||
| 		     &ctloclen)) | 	*len_ret = 0; | ||||||
|  |       return buf; | ||||||
|  |     } | ||||||
|  | #   define _ctloc(x) (ctloc = __ctloc (ctlocbuf, _CurrentTimeLocale->x, \ | ||||||
|  | 		      &ctloclen)) | ||||||
|  | #  endif | ||||||
| #endif  /* MAKE_WCSFTIME */ | #endif  /* MAKE_WCSFTIME */ | ||||||
|  |  | ||||||
| #define CHECK_LENGTH()	if (len < 0 || (count += len) >= maxsize) \ | #define CHECK_LENGTH()	if (len < 0 || (count += len) >= maxsize) \ | ||||||
| @@ -380,10 +387,25 @@ typedef struct { | |||||||
| } era_info_t; | } era_info_t; | ||||||
|  |  | ||||||
| static era_info_t * | static era_info_t * | ||||||
|  | #if defined (MAKE_WCSFTIME) && defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|  | get_era_info (const struct tm *tim_p, const wchar_t *era) | ||||||
|  | #else | ||||||
| get_era_info (const struct tm *tim_p, const char *era) | get_era_info (const struct tm *tim_p, const char *era) | ||||||
|  | #endif | ||||||
| { | { | ||||||
|  | #if defined (MAKE_WCSFTIME) && defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|  |   wchar_t *c; | ||||||
|  |   const wchar_t *dir; | ||||||
|  | # define ERA_STRCHR(a,b)	wcschr((a),(b)) | ||||||
|  | # define ERA_STRNCPY(a,b,c)	wcsncpy((a),(b),(c)) | ||||||
|  | # define ERA_STRTOL(a,b,c)	wcstol((a),(b),(c)) | ||||||
|  | #else | ||||||
|   char *c; |   char *c; | ||||||
|   const char *dir; |   const char *dir; | ||||||
|  | # define ERA_STRCHR(a,b)	strchr((a),(b)) | ||||||
|  | # define ERA_STRNCPY(a,b,c)	strncpy((a),(b),(c)) | ||||||
|  | # define ERA_STRTOL(a,b,c)	strtol((a),(b),(c)) | ||||||
|  | #endif | ||||||
|   long offset; |   long offset; | ||||||
|   struct tm stm, etm; |   struct tm stm, etm; | ||||||
|   era_info_t *ei; |   era_info_t *ei; | ||||||
| @@ -397,14 +419,14 @@ get_era_info (const struct tm *tim_p, const char *era) | |||||||
|     { |     { | ||||||
|       dir = era; |       dir = era; | ||||||
|       era += 2; |       era += 2; | ||||||
|       offset = strtol (era, &c, 10); |       offset = ERA_STRTOL (era, &c, 10); | ||||||
|       era = c + 1; |       era = c + 1; | ||||||
|       stm.tm_year = strtol (era, &c, 10) - YEAR_BASE; |       stm.tm_year = ERA_STRTOL (era, &c, 10) - YEAR_BASE; | ||||||
|       /* Adjust offset for negative gregorian dates. */ |       /* Adjust offset for negative gregorian dates. */ | ||||||
|       if (stm.tm_year <= -YEAR_BASE) |       if (stm.tm_year <= -YEAR_BASE) | ||||||
|       	++stm.tm_year; |       	++stm.tm_year; | ||||||
|       stm.tm_mon = strtol (c + 1, &c, 10); |       stm.tm_mon = ERA_STRTOL (c + 1, &c, 10); | ||||||
|       stm.tm_mday = strtol (c + 1, &c, 10); |       stm.tm_mday = ERA_STRTOL (c + 1, &c, 10); | ||||||
|       stm.tm_hour = stm.tm_min = stm.tm_sec = 0; |       stm.tm_hour = stm.tm_min = stm.tm_sec = 0; | ||||||
|       era = c + 1; |       era = c + 1; | ||||||
|       if (era[0] == '-' && era[1] == '*') |       if (era[0] == '-' && era[1] == '*') | ||||||
| @@ -425,12 +447,12 @@ get_era_info (const struct tm *tim_p, const char *era) | |||||||
| 	} | 	} | ||||||
|       else |       else | ||||||
|       	{ |       	{ | ||||||
| 	  etm.tm_year = strtol (era, &c, 10) - YEAR_BASE; | 	  etm.tm_year = ERA_STRTOL (era, &c, 10) - YEAR_BASE; | ||||||
| 	  /* Adjust offset for negative gregorian dates. */ | 	  /* Adjust offset for negative gregorian dates. */ | ||||||
| 	  if (etm.tm_year <= -YEAR_BASE) | 	  if (etm.tm_year <= -YEAR_BASE) | ||||||
| 	    ++etm.tm_year; | 	    ++etm.tm_year; | ||||||
| 	  etm.tm_mon = strtol (c + 1, &c, 10); | 	  etm.tm_mon = ERA_STRTOL (c + 1, &c, 10); | ||||||
| 	  etm.tm_mday = strtol (c + 1, &c, 10); | 	  etm.tm_mday = ERA_STRTOL (c + 1, &c, 10); | ||||||
| 	  etm.tm_mday = 31; | 	  etm.tm_mday = 31; | ||||||
| 	  etm.tm_hour = 23; | 	  etm.tm_hour = 23; | ||||||
| 	  etm.tm_min = etm.tm_sec = 59; | 	  etm.tm_min = etm.tm_sec = 59; | ||||||
| @@ -456,8 +478,8 @@ get_era_info (const struct tm *tim_p, const char *era) | |||||||
| 	  else | 	  else | ||||||
| 	    ei->year = etm.tm_year - tim_p->tm_year + offset; | 	    ei->year = etm.tm_year - tim_p->tm_year + offset; | ||||||
| 	  /* era_C */ | 	  /* era_C */ | ||||||
| 	  c = strchr (era, ':'); | 	  c = ERA_STRCHR (era, ':'); | ||||||
| #ifdef MAKE_WCSFTIME | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
| 	  len = mbsnrtowcs (NULL, &era, c - era, 0, NULL); | 	  len = mbsnrtowcs (NULL, &era, c - era, 0, NULL); | ||||||
| 	  if (len == (size_t) -1) | 	  if (len == (size_t) -1) | ||||||
| 	    { | 	    { | ||||||
| @@ -473,19 +495,19 @@ get_era_info (const struct tm *tim_p, const char *era) | |||||||
| 	      free (ei); | 	      free (ei); | ||||||
| 	      return NULL; | 	      return NULL; | ||||||
| 	    } | 	    } | ||||||
| #ifdef MAKE_WCSFTIME | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
| 	  len = mbsnrtowcs (ei->era_C, &era, c - era, len + 1, NULL); | 	  len = mbsnrtowcs (ei->era_C, &era, c - era, len + 1, NULL); | ||||||
| #else | #else | ||||||
| 	  strncpy (ei->era_C, era, len); | 	  ERA_STRNCPY (ei->era_C, era, len); | ||||||
| 	  era += len; | 	  era += len; | ||||||
| #endif | #endif | ||||||
| 	  ei->era_C[len] = CQ('\0'); | 	  ei->era_C[len] = CQ('\0'); | ||||||
| 	  /* era_Y */ | 	  /* era_Y */ | ||||||
| 	  ++era; | 	  ++era; | ||||||
| 	  c = strchr (era, ';'); | 	  c = ERA_STRCHR (era, ';'); | ||||||
| 	  if (!c) | 	  if (!c) | ||||||
| 	    c = strchr (era, '\0'); | 	    c = ERA_STRCHR (era, '\0'); | ||||||
| #ifdef MAKE_WCSFTIME | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
| 	  len = mbsnrtowcs (NULL, &era, c - era, 0, NULL); | 	  len = mbsnrtowcs (NULL, &era, c - era, 0, NULL); | ||||||
| 	  if (len == (size_t) -1) | 	  if (len == (size_t) -1) | ||||||
| 	    { | 	    { | ||||||
| @@ -503,17 +525,17 @@ get_era_info (const struct tm *tim_p, const char *era) | |||||||
| 	      free (ei); | 	      free (ei); | ||||||
| 	      return NULL; | 	      return NULL; | ||||||
| 	    } | 	    } | ||||||
| #ifdef MAKE_WCSFTIME | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
| 	  len = mbsnrtowcs (ei->era_Y, &era, c - era, len + 1, NULL); | 	  len = mbsnrtowcs (ei->era_Y, &era, c - era, len + 1, NULL); | ||||||
| #else | #else | ||||||
| 	  strncpy (ei->era_Y, era, len); | 	  ERA_STRNCPY (ei->era_Y, era, len); | ||||||
| 	  era += len; | 	  era += len; | ||||||
| #endif | #endif | ||||||
| 	  ei->era_Y[len] = CQ('\0'); | 	  ei->era_Y[len] = CQ('\0'); | ||||||
| 	  return ei; | 	  return ei; | ||||||
| 	} | 	} | ||||||
|       else |       else | ||||||
| 	era = strchr (era, ';'); | 	era = ERA_STRCHR (era, ';'); | ||||||
|       if (era) |       if (era) | ||||||
| 	++era; | 	++era; | ||||||
|     } |     } | ||||||
| @@ -535,10 +557,24 @@ typedef struct { | |||||||
| } alt_digits_t; | } alt_digits_t; | ||||||
|  |  | ||||||
| static alt_digits_t * | static alt_digits_t * | ||||||
|  | #if defined (MAKE_WCSFTIME) && defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|  | get_alt_digits (const wchar_t *alt_digits) | ||||||
|  | #else | ||||||
| get_alt_digits (const char *alt_digits) | get_alt_digits (const char *alt_digits) | ||||||
|  | #endif | ||||||
| { | { | ||||||
|   alt_digits_t *adi; |   alt_digits_t *adi; | ||||||
|  | #if defined (MAKE_WCSFTIME) && defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|  |   const wchar_t *a, *e; | ||||||
|  | # define ALT_STRCHR(a,b)	wcschr((a),(b)) | ||||||
|  | # define ALT_STRCPY(a,b)	wcscpy((a),(b)) | ||||||
|  | # define ALT_STRLEN(a)		wcslen(a) | ||||||
|  | #else | ||||||
|   const char *a, *e; |   const char *a, *e; | ||||||
|  | # define ALT_STRCHR(a,b)	strchr((a),(b)) | ||||||
|  | # define ALT_STRCPY(a,b)	strcpy((a),(b)) | ||||||
|  | # define ALT_STRLEN(a)		strlen(a) | ||||||
|  | #endif | ||||||
|   CHAR *aa, *ae; |   CHAR *aa, *ae; | ||||||
|   size_t len; |   size_t len; | ||||||
|  |  | ||||||
| @@ -548,7 +584,7 @@ get_alt_digits (const char *alt_digits) | |||||||
|  |  | ||||||
|   /* Compute number of alt_digits. */ |   /* Compute number of alt_digits. */ | ||||||
|   adi->num = 1; |   adi->num = 1; | ||||||
|   for (a = alt_digits; (e = strchr (a, ';')) != NULL; a = e + 1) |   for (a = alt_digits; (e = ALT_STRCHR (a, ';')) != NULL; a = e + 1) | ||||||
|       ++adi->num; |       ++adi->num; | ||||||
|   /* Allocate the `digit' array, which is an array of `num' pointers into |   /* Allocate the `digit' array, which is an array of `num' pointers into | ||||||
|      `buffer'. */ |      `buffer'. */ | ||||||
| @@ -559,7 +595,7 @@ get_alt_digits (const char *alt_digits) | |||||||
|       return NULL; |       return NULL; | ||||||
|     } |     } | ||||||
|   /* Compute memory required for `buffer'. */ |   /* Compute memory required for `buffer'. */ | ||||||
| #ifdef MAKE_WCSFTIME | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|   len = mbstowcs (NULL, alt_digits, 0); |   len = mbstowcs (NULL, alt_digits, 0); | ||||||
|   if (len == (size_t) -1) |   if (len == (size_t) -1) | ||||||
|     { |     { | ||||||
| @@ -568,7 +604,7 @@ get_alt_digits (const char *alt_digits) | |||||||
|       return NULL; |       return NULL; | ||||||
|     } |     } | ||||||
| #else | #else | ||||||
|   len = strlen (alt_digits); |   len = ALT_STRLEN (alt_digits); | ||||||
| #endif | #endif | ||||||
|   /* Allocate it. */ |   /* Allocate it. */ | ||||||
|   adi->buffer = (CHAR *) malloc ((len + 1) * sizeof (CHAR)); |   adi->buffer = (CHAR *) malloc ((len + 1) * sizeof (CHAR)); | ||||||
| @@ -579,10 +615,10 @@ get_alt_digits (const char *alt_digits) | |||||||
|       return NULL; |       return NULL; | ||||||
|     } |     } | ||||||
|   /* Store digits in it. */ |   /* Store digits in it. */ | ||||||
| #ifdef MAKE_WCSFTIME | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|   mbstowcs (adi->buffer, alt_digits, len + 1); |   mbstowcs (adi->buffer, alt_digits, len + 1); | ||||||
| #else | #else | ||||||
|   strcpy (adi->buffer, alt_digits); |   ALT_STRCPY (adi->buffer, alt_digits); | ||||||
| #endif | #endif | ||||||
|   /* Store the pointers into `buffer' into the appropriate `digit' slot. */ |   /* Store the pointers into `buffer' into the appropriate `digit' slot. */ | ||||||
|   for (len = 0, aa = adi->buffer; (ae = STRCHR (aa, CQ(';'))) != NULL; |   for (len = 0, aa = adi->buffer; (ae = STRCHR (aa, CQ(';'))) != NULL; | ||||||
| @@ -658,7 +694,7 @@ _DEFUN (strftime, (s, maxsize, format, tim_p), | |||||||
|   size_t count = 0; |   size_t count = 0; | ||||||
|   int i, len; |   int i, len; | ||||||
|   const CHAR *ctloc; |   const CHAR *ctloc; | ||||||
| #ifdef MAKE_WCSFTIME | #if defined (MAKE_WCSFTIME) && !defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|   CHAR ctlocbuf[CTLOCBUFLEN]; |   CHAR ctlocbuf[CTLOCBUFLEN]; | ||||||
| #endif | #endif | ||||||
|   size_t ctloclen; |   size_t ctloclen; | ||||||
| @@ -700,16 +736,26 @@ _DEFUN (strftime, (s, maxsize, format, tim_p), | |||||||
| 	{ | 	{ | ||||||
| 	  alt = *format++; | 	  alt = *format++; | ||||||
| #ifdef _WANT_C99_TIME_FORMATS       | #ifdef _WANT_C99_TIME_FORMATS       | ||||||
|  | #if defined (MAKE_WCSFTIME) && defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|  | 	  if (!*era_info && *_CurrentTimeLocale->wera) | ||||||
|  | 	    *era_info = get_era_info (tim_p, _CurrentTimeLocale->wera); | ||||||
|  | #else | ||||||
| 	  if (!*era_info && *_CurrentTimeLocale->era) | 	  if (!*era_info && *_CurrentTimeLocale->era) | ||||||
| 	    *era_info = get_era_info (tim_p, _CurrentTimeLocale->era); | 	    *era_info = get_era_info (tim_p, _CurrentTimeLocale->era); | ||||||
|  | #endif | ||||||
| #endif /* _WANT_C99_TIME_FORMATS */ | #endif /* _WANT_C99_TIME_FORMATS */ | ||||||
| 	} | 	} | ||||||
|       else if (*format == CQ('O')) |       else if (*format == CQ('O')) | ||||||
| 	{ | 	{ | ||||||
| 	  alt = *format++; | 	  alt = *format++; | ||||||
| #ifdef _WANT_C99_TIME_FORMATS       | #ifdef _WANT_C99_TIME_FORMATS       | ||||||
|  | #if defined (MAKE_WCSFTIME) && defined (__HAVE_LOCALE_INFO_EXTENDED__) | ||||||
|  | 	  if (!*alt_digits && *_CurrentTimeLocale->walt_digits) | ||||||
|  | 	    *alt_digits = get_alt_digits (_CurrentTimeLocale->walt_digits); | ||||||
|  | #else | ||||||
| 	  if (!*alt_digits && *_CurrentTimeLocale->alt_digits) | 	  if (!*alt_digits && *_CurrentTimeLocale->alt_digits) | ||||||
| 	    *alt_digits = get_alt_digits (_CurrentTimeLocale->alt_digits); | 	    *alt_digits = get_alt_digits (_CurrentTimeLocale->alt_digits); | ||||||
|  | #endif | ||||||
| #endif /* _WANT_C99_TIME_FORMATS */ | #endif /* _WANT_C99_TIME_FORMATS */ | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user