libstc++ and locale issue
Denys Vlasenko
vda.linux at googlemail.com
Sun Feb 15 15:14:01 UTC 2009
On Friday 13 February 2009 11:54, Carmelo AMOROSO wrote:
> rhabarber1848 wrote:
> > Denys Vlasenko wrote:
> >
> >> But if "anyone" is a patched version of gcc and patch
> >> simply uses uclibc internals (which were leaking through
> >> non-sanitized headers) instead of using public interface,
> >> that is a badly written patch.
> >
> > Hi,
> >
> > we already had the same discussion on the bug tracker:
> > https://bugs.busybox.net/show_bug.cgi?id=53#c7
> >
> > I also need to have libstdc++ support from gcc, in my case even gcc-3.4.6,
> > where the above mentioned patches where backported to:
> > http://cvs.tuxbox.org/cgi-bin/viewcvs.cgi/tuxbox/cdk/Patches/gcc-uclibc.diff?view=markup
> >
> > To "fix" the problem I copied libc/sysdeps/linux/common/bits/uClibc_locale.h
> > from the uClibc distribution to /include/bits in the target dir after
> > installing uClibc, I know its a hack but it works ;)
> >
> > I would be happy to see a real solution to this problem, but unfortunately I
> > can not help coding here.
> >
> > Greetings, rhabarber1848
> >
> My working proposal if for removing _LIBC from within uclibc_locale.h.
> Ready to commit. Let me know.
I do not like the idea.
How about rewriting offending patch?
http://cvs.tuxbox.org/cgi-bin/viewcvs.cgi/tuxbox/cdk/Patches/gcc-uclibc.diff?view=markup
The problem seems to be here:
+#ifdef __UCLIBC__
+# ifdef __UCLIBC_HAS_XLOCALE__
+ _M_data->_M_decimal_point = __cloc->decimal_point_wc;
+ _M_data->_M_thousands_sep = __cloc->thousands_sep_wc;
+# else
+ _M_data->_M_decimal_point = __global_locale->decimal_point_wc;
+ _M_data->_M_thousands_sep = __global_locale->thousands_sep_wc;
+# endif
+#else
+ union __s_and_w { const char *__s; unsigned int __w; } __u;
+ __u.__s = __nl_langinfo_l(_NL_MONETARY_DECIMAL_POINT_WC, __cloc);
+ _M_data->_M_decimal_point = static_cast<wchar_t>(__u.__w);
+
+ __u.__s = __nl_langinfo_l(_NL_MONETARY_THOUSANDS_SEP_WC, __cloc);
+ _M_data->_M_thousands_sep = static_cast<wchar_t>(__u.__w);
+#endif
Notice that it has "if not defined __UCLIBC__" branch
which is (supposedly) working, and uses only nl_langinfo_l,
which is a public interface.
(a) does it compile if the entire #if is reduced to its #else branch?
(b) does it work correctly? (and do we really care that much?)
If nl_langinfo_l is not available with !__UCLIBC_HAS_XLOCALE__,
then there is localeconv() ("man 7 localeconv").
--
vda
More information about the uClibc
mailing list