Author: faridz
Date: Wed Oct  3 10:34:31 2007
New Revision: 581667

URL: http://svn.apache.org/viewvc?rev=581667&view=rev
Log:
2007-10-03 Farid Zaripov <[EMAIL PROTECTED]>

        * 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/trunk/tests/localization/22.locale.moneypunct.cpp

Modified: incubator/stdcxx/trunk/tests/localization/22.locale.moneypunct.cpp
URL: 
http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/localization/22.locale.moneypunct.cpp?rev=581667&r1=581666&r2=581667&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/localization/22.locale.moneypunct.cpp 
(original)
+++ incubator/stdcxx/trunk/tests/localization/22.locale.moneypunct.cpp Wed Oct  
3 10:34:31 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;
 }


Reply via email to