This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Use __uselocale in monetary_members.cc


On Fri, Aug 30, 2002 at 12:38:28PM +0200, Jakub Jelinek wrote:
> The following patch fixes libstdc++-v3 compilation and use on GLIBC 2.2.9x+.
> It passed libstdc++-v3 make check with 24 XPASSes and 1 FAIL - the remaining
> 2 missing XPASSes (ie. the only 2 XFAILs) are:
> XFAIL: 22_locale/messages_byname.cc execution test
> XFAIL: 22_locale/messages_members_char.cc execution test
> which fail because of a glibc bug Roland is working on.

Follow up patch - monetary_members.cc was still using setlocale.
With current CVS glibc plus a one-liner fix for locale-archive support
I now get back the expected 1 FAIL and 26 XPASSes on i386-redhat-linux,
both when using locale-archive and when forcing to not use
it (export LOCPATH=/usr/lib/locale).

Ok to commit?

2002-09-01  Jakub Jelinek  <jakub@redhat.com>

	* config/locale/gnu/monetary_members.cc
	(moneypunct<wchar_t, true>::_M_initialize_moneypunct,
	moneypunct<wchar_t, false>::_M_initialize_moneypunct): Use
	__uselocale instead of setlocale for glibc 2.3+.

--- libstdc++-v3/config/locale/gnu/monetary_members.cc.jj	2002-08-30 12:09:12.000000000 +0200
+++ libstdc++-v3/config/locale/gnu/monetary_members.cc	2002-08-31 23:41:51.000000000 +0200
@@ -335,9 +335,13 @@ namespace std
       else
 	{
 	  // Named locale.
-	  // XXX Fix me. Switch to named locale so that mbsrtowcs will work.
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
+	  __c_locale __old = __uselocale(__cloc);
+#else
+	  // Switch to named locale so that mbsrtowcs will work.
 	  char* __old = strdup(setlocale(LC_ALL, NULL));
 	  setlocale(LC_ALL, __name);
+#endif
 
 	  _M_decimal_point = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w);
 
@@ -400,9 +404,12 @@ namespace std
 	  char __nspace = *(__nl_langinfo_l(__INT_N_SEP_BY_SPACE, __cloc));
 	  _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn);
 
-	  // XXX
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
+	  __uselocale(__old);
+#else
 	  setlocale(LC_ALL, __old);
 	  free(__old);
+#endif
 	}
     }
 
@@ -427,9 +434,13 @@ namespace std
       else
 	{
 	  // Named locale.
-	  // XXX Fix me. Switch to named locale so that mbsrtowcs will work.
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
+	  __c_locale __old = __uselocale(__cloc);
+#else
+	  // Switch to named locale so that mbsrtowcs will work.
 	  char* __old = strdup(setlocale(LC_ALL, NULL));
 	  setlocale(LC_ALL, __name);
+#endif
 
 	  _M_decimal_point = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_DECIMAL_POINT_WC, __cloc)}).__w);
 	  _M_thousands_sep = static_cast<wchar_t>(((union { const char *__s; unsigned int __w; }){ __s: __nl_langinfo_l(_NL_NUMERIC_THOUSANDS_SEP_WC, __cloc)}).__w);
@@ -491,9 +502,12 @@ namespace std
 	  char __nspace = *(__nl_langinfo_l(__N_SEP_BY_SPACE, __cloc));
 	  _M_neg_format = _S_construct_pattern(__nprecedes, __nspace, __nposn);
 
-	  // XXX
+#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 2)
+	  __uselocale(__old);
+#else
 	  setlocale(LC_ALL, __old);
 	  free(__old);
+#endif
 	}
     }
 


	Jakub


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]