This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Does --enable-clocale=gnu work on Linux/ia64?
On Mon, Nov 26, 2001 at 10:43:57AM +0100, Jakub Jelinek wrote:
>
> Whatever cast you use, this is wrong.
> categories.def:
> DEFINE_ELEMENT (_NL_NUMERIC_DECIMAL_POINT_WC, "numeric-decimal-point-wc", std, word)
> DEFINE_ELEMENT (_NL_NUMERIC_THOUSANDS_SEP_WC, "numeric-thousands-sep-wc", std, word)
> localeinfo.h:
> union locale_data_value
> {
> const uint32_t *wstr;
> const char *string;
> unsigned int word;
> }
> values __flexarr; /* Items, usually pointers into `filedata'. */
> nl_langinfo.c:
> /* Return the string for the specified item. */
> return (char *) data->values[index].string;
>
> So, what you need to do is:
>
> union { const char *string; unsigned int word; } __tmp;
> __tmp.string = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
> _M_decimal_point = static_cast<wchar_t>(ch);
>
> resp:
> _M_decimal_point = static_cast<wchar_t>(((union { const char *s; unsinged int w; }){ s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).w)
> Otherwise, big endian looses.
>
I am testing this on x86 and ia64. It ha passed those locale tests in
libstdc++-v3.
H.J.
----
2001-11-26 H.J. Lu <hjl@gnu.org>
Jakub Jelinek <jakub@redhat.com>
* config/locale/moneypunct_members_gnu.cc
(_M_initialize_moneypunct): Properly handle
_NL_NUMERIC_DECIMAL_POINT_WC and _NL_NUMERIC_THOUSANDS_SEP_WC.
* config/locale/numpunct_members_gnu.cc
(_M_initialize_numpunct): Likewise.
--- libstdc++-v3/config/locale/moneypunct_members_gnu.cc.gnu Sat Nov 24 11:48:05 2001
+++ libstdc++-v3/config/locale/moneypunct_members_gnu.cc Mon Nov 26 11:30:18 2001
@@ -319,8 +319,11 @@ namespace std
else
{
// Named locale.
- _M_decimal_point = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
- _M_thousands_sep = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+ union { const char *string; unsigned int word; } __tmp;
+ __tmp.string = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
+ _M_decimal_point = static_cast<wchar_t>(__tmp.word);
+ __tmp.string = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc);
+ _M_thousands_sep = static_cast<wchar_t>(__tmp.word);
_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
mbstate_t __state;
@@ -398,8 +401,11 @@ namespace std
else
{
// Named locale.
- _M_decimal_point = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
- _M_thousands_sep = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+ union { const char *string; unsigned int word; } __tmp;
+ __tmp.string = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
+ _M_decimal_point = static_cast<wchar_t>(__tmp.word);
+ __tmp.string = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc);
+ _M_thousands_sep = static_cast<wchar_t>(__tmp.word);
_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
mbstate_t __state;
--- libstdc++-v3/config/locale/numpunct_members_gnu.cc.gnu Mon Aug 27 23:19:33 2001
+++ libstdc++-v3/config/locale/numpunct_members_gnu.cc Mon Nov 26 11:29:53 2001
@@ -77,8 +77,11 @@ namespace std
else
{
// Named locale.
- _M_decimal_point = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc));
- _M_thousands_sep = reinterpret_cast<wchar_t>(__nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc));
+ union { const char *string; unsigned int word; } __tmp;
+ __tmp.string = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
+ _M_decimal_point = static_cast<wchar_t>(__tmp.word);
+ __tmp.string = __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC,__cloc);
+ _M_thousands_sep = static_cast<wchar_t>(__tmp.word);
_M_grouping = __nl_langinfo_l(GROUPING, __cloc);
}
// NB: There is no way to extact this info from posix locales.