Author: faridz
Date: Tue Oct 30 10:45:54 2007
New Revision: 590185
URL: http://svn.apache.org/viewvc?rev=590185&view=rev
Log:
2007-10-30 Farid Zaripov <[EMAIL PROTECTED]>
Merged r581667 from trunk
* 22.locale.moneypunct.cpp (convert): Save the name of the
original locale using std::string object. Use return instead
of break to avoid restoring the original locale twice.
Modified:
incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.cpp
Modified:
incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.cpp
URL:
http://svn.apache.org/viewvc/incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.cpp?rev=590185&r1=590184&r2=590185&view=diff
==============================================================================
--- incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.cpp
(original)
+++ incubator/stdcxx/branches/4.2.x/tests/localization/22.locale.moneypunct.cpp
Tue Oct 30 10:45:54 2007
@@ -279,7 +279,10 @@
convert (const char *locname, const char *s, const wchar_t*)
{
// save the name of the original locale
- const char *savename = std::setlocale (LC_ALL, 0);
+ std::string saved_loc;
+
+ if (const char *savename = std::setlocale (LC_ALL, 0))
+ saved_loc = savename;
// switch to (named) locale
const char *loc = std::setlocale (LC_ALL, locname);
@@ -305,14 +308,15 @@
// restore the original locale before printing out
// the error message (we don't want it localized)
- std::setlocale (LC_ALL, savename);
+ std::setlocale (LC_ALL, saved_loc.c_str ());
rw_fprintf (rw_stderr,
"%s:%d: mbstowcs(..., %#s, %zu) "
"= -1: %m\n", __FILE__, __LINE__,
s, res.capacity ());
res = std::wstring (); // mbstowcs() error
- break;
+
+ return res;
}
else {
// shrink if necessary
@@ -322,7 +326,7 @@
}
// restore original locale
- std::setlocale (LC_ALL, savename);
+ std::setlocale (LC_ALL, saved_loc.c_str ());
return res;
}