[Patch] Clean up and reformat to config/numeric and time

Martin Sebor sebor@roguewave.com
Thu Jun 17 20:41:00 GMT 2004


Paolo Carlini wrote:

> Hi,
> 
> the second half of the patch is straightforward: it uses an union
> (consistently with numeric) instead of reinterpret_cast in order to
> avoid *a lot* of overlong lines.
> 
> The first hunk is slighlty less trivial, I would appreciate a look
> over it. We had:
> 
>  union __s_and_w { const char *__s; unsigned int __w; } __u;
>  __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
>  _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w);
> 
> I changed it to:
> 
>  union { char *__s; wchar_t __w; } __u;
>  __u.__s = __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc);
>  _M_data->_M_decimal_point = __u.__w;

Interesting. This is quite similar to our own implementation (we
also store the wchar_t representation internally, just as glibc
appears to, but we store it in int32_t for better portability).

Just a quick observation (it may or may not be relevant): the
cast might be important if wchar_t is not the same size as int,
e.g., with -fshort-wchar. But if this code is tied to glibc
where wchar_t is always the same size as int (and if libstdc++
doesn't allow -fshort-wchar) it should be safe.

Martin



More information about the Libstdc++ mailing list