Martin Sebor wrote:
Seems reasonable. We should also guard the calls to the the wchar_t
specializations of the function with _RWSTD_NO_WCHAR_T.

On second thought, isn't there a more robust way of fixing this,
one that makes it work regardless of the order of the calls to
the function? E.g., have the function that needs the environment
variable defined always define it and the one that needs it
undefined always undefine it?


Martin


Farid Zaripov-2 wrote:
  The 22.locale.ctype.is.cpp test contains two functions: test_libc<>()
and test_libstd<>().

  If I understand correctly, the test_libc<>() designed to check the
system locales (it
iterates the all locales, returned by rw_locales()), and test_libstd<>()
designed to
check the "test-locale" locale (created by rw_create_locale()).

  First invoked test_libstd<char>(). From there invoked
rw_create_locale() function,
which set RWSTD_LOCALE_ROOT environment variable to the temporary
directory
with "test-locale" locale.

  Then invoked test_libc<char>(). It invokes rw_locales(), which uses
"locale -a" command.
But locale utility, if RWSTD_LOCALE_ROOT environment variable is
defined, returns
list of the library locales. In this case it returns "C" and
"test-locale". Also rw_locales()
checks the locale names by invoking std::setlocale(). Of course
std::setlocale(LC_ALL, "test-locale")
fails and as a result the rw_locales returns "C\0\0" string.

  The patch below resolves this situation by invoking first both
test_libc<char> and test_libc<wchar_t>
and then test_libstd<char> and test_libstd<wchar_t>.


  ChangeLog:
  * 22.locale.ctype.is.cpp (run_test<>): The compile time
  checks moved to test_libstd(); The function run_test<>()
  removed; The test_libstd() and test_libc() funtions are
  invoked from non-template run_test() to invoke them in
  the following order: test_libc<char>(), test_libc<wchar_t>(),
  test_libstd<char>(), test_libstd<wchar_t>().


Index: 22.locale.ctype.is.cpp
===================================================================
--- 22.locale.ctype.is.cpp      (revision 594578)
+++ 22.locale.ctype.is.cpp      (working copy)
@@ -840,6 +840,12 @@
 template <class charT>
 void test_libstd (charT, const char *cname)
 {
+    if (0) {
+        // do a compile time only test on use_facet and has_facet
+        _STD_HAS_FACET (std::ctype_byname<charT>, std::locale ());
+        _STD_USE_FACET (std::ctype_byname<charT>, std::locale ());
+    }
+
     const char cmap_1[] = {
         "<code_set_name> \"ANSI_X3.4-1968\"\n"
         "<mb_cur_max> 1\n"
@@ -1025,27 +1031,15 @@
/***********************************************************************
***/
-template <class charT>
-void run_test (charT, const char *cname)
-{
-    if (0) {
-        // do a compile time only test on use_facet and has_facet
-        _STD_HAS_FACET (std::ctype_byname<charT>, std::locale ());
-        _STD_USE_FACET (std::ctype_byname<charT>, std::locale ());
-    }
-
-    test_libstd (charT (), cname);
-    test_libc (charT (), cname);
-}
-
-/**********************************************************************
****/
-
 static int
 run_test (int, char**)
 {
-    run_test (char (), "char");
-    run_test (wchar_t (), "wchar_t");
+    test_libc (char (), "char");
+    test_libc (wchar_t (), "wchar_t");
+ test_libstd (char (), "char");
+    test_libstd (wchar_t (), "wchar_t");
+
     return 0;
 }
Farid.




Reply via email to