diff --git a/newlib/ChangeLog b/newlib/ChangeLog index c973c6517..b5be19c24 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,19 @@ +2010-02-09 Corinna Vinschen + + * libc/locale/lmessages.c (__messages_load_locale): Take additional + parameters for wide char to multibyte conversion. Call + __set_lc_messages_from_win on Cygwin. + * libc/locale/lmessages.h: Make C++-safe. + (__messages_load_locale): Change declaration. + * libc/locale/lmonetary.c (__monetary_load_locale): Use + _monetary_locale_buf as buffer pointer. + * libc/locale/lnumeric.c (__numeric_load_locale): Use + _numeric_locale_buf as buffer pointer. + * libc/locale/timelocal.c (__time_load_locale): Use time_locale_buf + as buffer pointer. + * libc/locale/locale.c (loadlocale): Enable loading LC_MESSAGES data + on Cygwin. + 2010-02-08 Josef Wolf * libc/machine/m68k/memcpy.S: MISALIGEND_OK should not be set for diff --git a/newlib/libc/locale/lmessages.c b/newlib/libc/locale/lmessages.c index 9a4bb799a..24e4858d5 100644 --- a/newlib/libc/locale/lmessages.c +++ b/newlib/libc/locale/lmessages.c @@ -49,8 +49,29 @@ static int _messages_using_locale; static char *_messages_locale_buf; int -__messages_load_locale(const char *name) { +__messages_load_locale (const char *name, void *f_wctomb, const char *charset) +{ +#ifdef __CYGWIN__ + extern int __set_lc_messages_from_win (const char *, + struct lc_messages_T *, char **, + void *, const char *); + int ret; + int old_messages_using_locale = _messages_using_locale; + _messages_using_locale = 0; + ret = __set_lc_messages_from_win (name, &_messages_locale, + &_messages_locale_buf, + f_wctomb, charset); + /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ + if (ret < 0) + _messages_using_locale = old_messages_using_locale; + else + { + _messages_using_locale = ret; + ret = 0; + } + return ret; +#else /* * Propose that we can have incomplete locale file (w/o "{yes,no}str"). * Initialize them before loading. In case of complete locale, they'll @@ -63,6 +84,7 @@ __messages_load_locale(const char *name) { _messages_locale_buf, "LC_MESSAGES", LCMESSAGES_SIZE_FULL, LCMESSAGES_SIZE_MIN, (const char **)&_messages_locale); +#endif } struct lc_messages_T * diff --git a/newlib/libc/locale/lmessages.h b/newlib/libc/locale/lmessages.h index ee690ae7c..b1e14b7c9 100644 --- a/newlib/libc/locale/lmessages.h +++ b/newlib/libc/locale/lmessages.h @@ -29,6 +29,10 @@ #ifndef _LMESSAGES_H_ #define _LMESSAGES_H_ +#include + +__BEGIN_DECLS + struct lc_messages_T { const char *yesexpr; const char *noexpr; @@ -37,6 +41,8 @@ struct lc_messages_T { }; struct lc_messages_T *__get_current_messages_locale(void); -int __messages_load_locale(const char *); +int __numeric_load_locale(const char *, void *, const char *); + +__END_DECLS #endif /* !_LMESSAGES_H_ */ diff --git a/newlib/libc/locale/lmonetary.c b/newlib/libc/locale/lmonetary.c index 745ade517..c96d74802 100644 --- a/newlib/libc/locale/lmonetary.c +++ b/newlib/libc/locale/lmonetary.c @@ -76,11 +76,12 @@ __monetary_load_locale(const char *name , void *f_wctomb, const char *charset) #ifdef __CYGWIN__ extern int __set_lc_monetary_from_win (const char *, - struct lc_monetary_T *, + struct lc_monetary_T *, char **, void *, const char *); int old_monetary_using_locale = _monetary_using_locale; _monetary_using_locale = 0; ret = __set_lc_monetary_from_win (name, &_monetary_locale, + &_monetary_locale_buf, f_wctomb, charset); /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ if (ret < 0) diff --git a/newlib/libc/locale/lnumeric.c b/newlib/libc/locale/lnumeric.c index 5bf0a7d11..81c0061ff 100644 --- a/newlib/libc/locale/lnumeric.c +++ b/newlib/libc/locale/lnumeric.c @@ -54,11 +54,12 @@ __numeric_load_locale(const char *name , void *f_wctomb, const char *charset) #ifdef __CYGWIN__ extern int __set_lc_numeric_from_win (const char *, - struct lc_numeric_T *, + struct lc_numeric_T *, char **, void *, const char *); int old_numeric_using_locale = _numeric_using_locale; _numeric_using_locale = 0; ret = __set_lc_numeric_from_win (name, &_numeric_locale, + &_numeric_locale_buf, f_wctomb, charset); /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ if (ret < 0) diff --git a/newlib/libc/locale/locale.c b/newlib/libc/locale/locale.c index 2b1f6dd33..8444be961 100644 --- a/newlib/libc/locale/locale.c +++ b/newlib/libc/locale/locale.c @@ -817,7 +817,13 @@ restart: || strncmp (locale, "zh", 2) == 0)); } else if (category == LC_MESSAGES) - strcpy (lc_message_charset, charset); + { +#ifdef __CYGWIN__ + ret = __messages_load_locale (locale, (void *) l_wctomb, charset); + if (!ret) +#endif + strcpy (lc_message_charset, charset); + } #ifdef __CYGWIN__ else if (category == LC_COLLATE) ret = __collate_load_locale (locale, (void *) l_mbtowc, charset); diff --git a/newlib/libc/locale/timelocal.c b/newlib/libc/locale/timelocal.c index 0fe53bf42..17b9a2350 100644 --- a/newlib/libc/locale/timelocal.c +++ b/newlib/libc/locale/timelocal.c @@ -109,10 +109,11 @@ __time_load_locale(const char *name, void *f_wctomb, const char *charset) { #ifdef __CYGWIN__ extern int __set_lc_time_from_win (const char *, struct lc_time_T *, - void *, const char *); + char **, void *, const char *); int old_time_using_locale = _time_using_locale; _time_using_locale = 0; - ret = __set_lc_time_from_win (name, &_time_locale, f_wctomb, charset); + ret = __set_lc_time_from_win (name, &_time_locale, &time_locale_buf, + f_wctomb, charset); /* ret == -1: error, ret == 0: C/POSIX, ret > 0: valid */ if (ret < 0) _time_using_locale = old_time_using_locale;