You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by fa...@apache.org on 2008/04/16 19:02:30 UTC
svn commit: r648752 [4/5] - in /stdcxx/branches/4.2.x: doc/stdlibref/
etc/config/ etc/config/src/ etc/config/windows/ etc/nls/ examples/manual/
examples/tutorial/ include/ include/ansi/ include/loc/ include/rw/ src/
src/ia64/ tests/algorithms/ tests/co...
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.cpp Wed Apr 16 10:01:56 2008
@@ -22,18 +22,18 @@
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
- * Copyright 2002-2006 Rogue Wave Software.
+ * Copyright 2002-2008 Rogue Wave Software, Inc.
*
**************************************************************************/
#include <ios> // for basic_ios
#include <locale> // for locale, time_put
-#include <climits> // for INT_MAX, INT_MIN
+#include <climits> // for INT_MAX, INT_MIN, TZNAME_MAX
#include <cstdio> // for fprintf(), ...
#include <cstdlib> // for mbstowcs(), wcstombs()
-#include <cstring> // for memcpy(), strlen()
-#include <ctime> // for tm
+#include <cstring> // for memset(), memcpy(), strlen(), strcat()
+#include <ctime> // for tm, tzset()
#include <cwchar> // for wcsftime(), wcslen()
#include <cassert> // for assert()
@@ -56,6 +56,20 @@
// set in main() instead of here to avoid Solaris 7 putenv() bug (PR #30017)
const char* locale_root;
+#if defined (_RWSTD_NO_TZSET) && !defined (_RWSTD_NO_TZSET_IN_LIBC)
+# undef _RWSTD_NO_TZSET
+extern "C" _RWSTD_DLLIMPORT void tzset () _LIBC_THROWS();
+#endif // _RWSTD_NO_TZSET && !_RWSTD_NO_TZSET_IN_LIBC
+
+inline void set_TZ (const char* str)
+{
+ rw_putenv (str);
+
+#ifndef _RWSTD_NO_TZSET
+ tzset ();
+#endif
+}
+
/**************************************************************************/
const char* narrow (char *dst, const char *src)
@@ -583,7 +597,7 @@
char segment [256];
- std::sprintf (segment, "%c:%u:%04d/%02d/%02d:",
+ std::sprintf (segment, "%c:%d:%04d/%02d/%02d:",
td->era [i].offset < 0 ? '-' : '+',
td->era [i].offset < 0 ? -td->era [i].offset
: td->era [i].offset,
@@ -636,7 +650,10 @@
const char* const locname =
rw_localedef ("", srcfname, cmfname, "test-locale");
- if (locname && (strlen(locname) < sizeof locnamebuf))
+ // avoid copying into buffer if it's not big enough: this
+ // this affect the efficiency of the function but not its
+ // behavior
+ if (locname && std::strlen (locname) < sizeof locnamebuf)
std::strcpy (locnamebuf, locname);
// remove temporary files
@@ -1501,89 +1518,89 @@
// the tznames global variable by tzset())
// unset TZ -- expect no output
- rw_putenv ("TZ=");
+ set_TZ ("TZ=");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, +1), "%z", 0, 0, ' ', "");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1), "%z", 0, 0, ' ', "");
// set TZ to GMT (UTC) plus zero hours, no DST
- rw_putenv ("TZ=std0");
+ set_TZ ("TZ=std0");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0000");
// no DST specified, zone info not applicable
// TEST (T (0, 0, 1, 0, 0, 0, 0, 0, +1), "%z", 0, 0, ' ', "+0000");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1), "%z", 0, 0, ' ', "");
// set TZ to GMT+7 hours, no DST
- rw_putenv ("TZ=foo+7");
+ set_TZ ("TZ=foo+7");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0700");
// no DST specified, zone info not applicable
// TEST (T (0, 0, 1, 0, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0700");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1), "%z", 0, 0, ' ', "");
// set TZ to GMT+1 hours and DST to GMT+2 hours
- rw_putenv ("TZ=abc1def2");
+ set_TZ ("TZ=abc1def2");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0100");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0200");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1), "%z", 0, 0, ' ', "");
// set TZ to GMT+2 hours and DST to GMT+4 hours
- rw_putenv ("TZ=abc2def4");
+ set_TZ ("TZ=abc2def4");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0200");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0400");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1), "%z", 0, 0, ' ', "");
// set TZ to GMT+3 hours and DST to GMT+4 hours
- rw_putenv ("TZ=abc3:00def4:00");
+ set_TZ ("TZ=abc3:00def4:00");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0300");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0400");
// set TZ to GMT+11:30 hours and DST to GMT+11:45 hours
- rw_putenv ("TZ=abc11:30:00def11:45");
+ set_TZ ("TZ=abc11:30:00def11:45");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+1130");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+1145");
// TZ: STD=GMT+12:34, empty DST
// According to POSIX, when no offset follows DST, the alternative
// time is assumed to be one hour ahead of standard time.
- rw_putenv ("TZ=bcd12:34efg");
+ set_TZ ("TZ=bcd12:34efg");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+1234");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+1334");
// TZ: STD=GMT+23:01, empty DST
- rw_putenv ("TZ=cde23:01fgh");
+ set_TZ ("TZ=cde23:01fgh");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+2301");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0001");
// TZ: STD=GMT+23:59, empty DST
- rw_putenv ("TZ=def23:59ghi");
+ set_TZ ("TZ=def23:59ghi");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+2359");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0059");
- rw_putenv ("TZ=EST03:00<EDT1>04:00");
+ set_TZ ("TZ=EST03:00<EDT1>04:00");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0300");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0400");
# if 0 // disabled tests of funky std/dst strings
- rw_putenv ("TZ=<EST+2>03:21EDT04:32");
+ set_TZ ("TZ=<EST+2>03:21EDT04:32");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0321");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0432");
- rw_putenv ("TZ=EST04:32:10<EDT+03>05:43:21");
+ set_TZ ("TZ=EST04:32:10<EDT+03>05:43:21");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0432");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0543");
# endif // 0/1
- rw_putenv ("TZ=EST-4EDT-5");
+ set_TZ ("TZ=EST-4EDT-5");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "-0400");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "-0500");
- rw_putenv ("TZ=EST-5:00EDT-6:00");
+ set_TZ ("TZ=EST-5:00EDT-6:00");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "-0500");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "-0600");
- rw_putenv ("TZ=EST-5:43EDT-6:54");
+ set_TZ ("TZ=EST-5:43EDT-6:54");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "-0543");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "-0654");
@@ -1598,14 +1615,14 @@
// likely expects it to take effect; otherwise POSIX-compliant
// behavior is assumed to be expected
- rw_putenv ("TZ"); // unset
+ set_TZ ("TZ"); // unset
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0, 60), "%z", 0, 0, ' ', "+0001");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1, 120), "%z", 0, 0, ' ', "+0002");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1, 180), "%z", 0, 0, ' ', "");
// setting TZ to an arbitrary value should have no effect
// regardless of the value of the tm_isdst flag
- rw_putenv ("TZ=PST8");
+ set_TZ ("TZ=PST8");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0, 3600), "%z", 0, 0, ' ', "+0100");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1, -7260), "%z", 0, 0, ' ', "-0201");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1, 1234), "%z", 0, 0, ' ', "");
@@ -1625,19 +1642,19 @@
rw_info (0, 0, __LINE__, "%%z: SunOS UZ/zone format [platform-specific]");
- rw_putenv ("TZ=US/Eastern");
+ set_TZ ("TZ=US/Eastern");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0500");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0600");
- rw_putenv ("TZ=US/Central");
+ set_TZ ("TZ=US/Central");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0600");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0700");
- rw_putenv ("TZ=US/Mountain");
+ set_TZ ("TZ=US/Mountain");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0700");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0800");
- rw_putenv ("TZ=US/Pacific");
+ set_TZ ("TZ=US/Pacific");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%z", 0, 0, ' ', "+0800");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%z", 0, 0, ' ', "+0900");
@@ -1649,7 +1666,7 @@
rw_info (0, 0, __LINE__,
"%%Z: the locale's time zone name or abbreviation");
- rw_putenv ("TZ=foo0bar1");
+ set_TZ ("TZ=foo0bar1");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%Z", 0, 0, ' ', "foo");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%Z", 0, 0, ' ', "bar");
@@ -1657,7 +1674,7 @@
// is undefined, avoid exercising it
// TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1), "%Z", 0, 0, ' ', "bar");
- rw_putenv ("TZ=EST1EDT2");
+ set_TZ ("TZ=EST1EDT2");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%Z", 0, 0, ' ', "EST");
TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%Z", 0, 0, ' ', "EDT");
@@ -1666,9 +1683,34 @@
// TEST (T (0, 0, 0, 1, 0, 0, 0, 0, -1), "%Z", 0, 0, ' ', "EDT");
// exercise two-digit hour
- rw_putenv ("TZ=ABCD01DEFG02");
- TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%Z", 0, 0, ' ', "ABCD");
- TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%Z", 0, 0, ' ', "DEFG");
+ set_TZ ("TZ=ABC01DEF02");
+ TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%Z", 0, 0, ' ', "ABC");
+ TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%Z", 0, 0, ' ', "DEF");
+
+ // exercise time zone name of maximum length
+#if defined (TZNAME_MAX) && !defined (_MSC_VER)
+ // MSVC may define TZNAME_MAX (if _POSIX_ is defined),
+ // but tzset() uses hardcoded value equal to 3 instead
+
+ char std_name [TZNAME_MAX + 1];
+ std::memset (std_name, 'A', TZNAME_MAX);
+ std_name [TZNAME_MAX] = '\0';
+
+ char dst_name [TZNAME_MAX + 1];
+ std::memset (dst_name, 'B', TZNAME_MAX);
+ dst_name [TZNAME_MAX] = '\0';
+
+ char tz_buf [2 * TZNAME_MAX + 8] = "TZ=";
+ std::strcat (tz_buf, std_name);
+ std::strcat (tz_buf, "01");
+ std::strcat (tz_buf, dst_name);
+ std::strcat (tz_buf, "02");
+
+ set_TZ (tz_buf);
+
+ TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 0), "%Z", 0, 0, ' ', std_name);
+ TEST (T (0, 0, 0, 1, 0, 0, 0, 0, 1), "%Z", 0, 0, ' ', dst_name);
+#endif // TZNAME_MAX && !_MSC_VER
//////////////////////////////////////////////////////////////////
// %%: replaced by %
Modified: stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp (original)
+++ stdcxx/branches/4.2.x/tests/localization/22.locale.time.put.mt.cpp Wed Apr 16 10:01:56 2008
@@ -45,17 +45,27 @@
// default number of threads (will be adjusted to the number
// of processors/cores later)
-int rw_opt_nthreads = 1;
+int opt_nthreads = 1;
// the number of times each thread should iterate
-int rw_opt_nloops = MAX_LOOPS;
+int opt_nloops = MAX_LOOPS;
+
+#if !defined (_RWSTD_OS_HP_UX) || defined (_ILP32)
// number of locales to use
-int rw_opt_nlocales = MAX_THREADS;
+int opt_nlocales = MAX_THREADS;
+
+#else // HP-UX in LP64 mode
+
+// work around an inefficiency (small cache size?) on HP-UX
+// in LP64 mode (see STDCXX-812)
+int opt_nlocales = 10;
+
+#endif // HP-UX 32/64 bit mode
// should all threads share the same set of locale objects instead
// of creating their own?
-int rw_opt_shared_locale;
+int opt_shared_locale;
/**************************************************************************/
@@ -145,7 +155,7 @@
wio.rdbuf (&wsb);
#endif // _RWSTD_NO_WCHAR_T
- for (int i = 0; i != rw_opt_nloops; ++i) {
+ for (int i = 0; i != opt_nloops; ++i) {
// save the name of the locale
const MyTimeData& data = my_time_data [i % nlocales];
@@ -154,7 +164,7 @@
// facet from it and use it to format a random time value
// using a random conversion specifier
const std::locale loc =
- rw_opt_shared_locale ? data.locale_
+ opt_shared_locale ? data.locale_
: std::locale (data.locale_name_);
if (test_char) {
@@ -288,7 +298,7 @@
#endif // _RWSTD_NO_WCHAR_T
- if (rw_opt_shared_locale)
+ if (opt_shared_locale)
data.locale_ = loc;
nlocales += 1;
@@ -299,7 +309,7 @@
"failed to create locale(%#s)", name);
}
- if (nlocales == maxinx || nlocales == std::size_t (rw_opt_nlocales))
+ if (nlocales == maxinx || nlocales == std::size_t (opt_nlocales))
break;
}
@@ -309,9 +319,9 @@
rw_info (0, 0, 0,
"testing std::time_put<charT> with %d thread%{?}s%{;}, "
- "%zu iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
- rw_opt_nthreads, 1 != rw_opt_nthreads,
- rw_opt_nloops, 1 != rw_opt_nloops,
+ "%d iteration%{?}s%{;} each, in %zu locales { %{ .*A@} }",
+ opt_nthreads, 1 != opt_nthreads,
+ opt_nloops, 1 != opt_nloops,
nlocales, int (nlocales), "%#s", locales);
rw_info (0, 0, 0, "exercising std::time_put<char>");
@@ -321,11 +331,11 @@
// create and start a pool of threads and wait for them to finish
int result =
- rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+ rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
- rw_opt_nthreads, thread_func);
+ opt_nthreads, thread_func);
#ifndef _RWSTD_NO_WCHAR_T
@@ -336,11 +346,11 @@
// start a pool of threads to exercise wstring thread safety
result =
- rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+ rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
- rw_opt_nthreads, thread_func);
+ opt_nthreads, thread_func);
// exercise both the char and the wchar_t specializations
// at the same time
@@ -353,11 +363,11 @@
// start a pool of threads to exercise wstring thread safety
result =
- rw_thread_pool (0, std::size_t (rw_opt_nthreads), 0, thread_func, 0);
+ rw_thread_pool (0, std::size_t (opt_nthreads), 0, thread_func, 0);
rw_error (result == 0, 0, __LINE__,
"rw_thread_pool(0, %d, 0, %{#f}, 0) failed",
- rw_opt_nthreads, thread_func);
+ opt_nthreads, thread_func);
#endif // _RWSTD_NO_WCHAR_T
@@ -372,9 +382,9 @@
// set nthreads to the greater of the number of processors
// and 2 (for uniprocessor systems) by default
- rw_opt_nthreads = rw_get_cpus ();
- if (rw_opt_nthreads < 2)
- rw_opt_nthreads = 2;
+ opt_nthreads = rw_get_cpus ();
+ if (opt_nthreads < 2)
+ opt_nthreads = 2;
#endif // _RWSTD_REENTRANT
@@ -386,10 +396,10 @@
"|-nlocales#0 " // arg must be non-negative
"|-locales= " // must be provided
"|-shared-locale# ",
- &rw_opt_nloops,
+ &opt_nloops,
int (MAX_THREADS),
- &rw_opt_nthreads,
- &rw_opt_nlocales,
+ &opt_nthreads,
+ &opt_nlocales,
&rw_opt_setlocales,
- &rw_opt_shared_locale);
+ &opt_shared_locale);
}
Modified: stdcxx/branches/4.2.x/tests/numerics/26.c.math.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/numerics/26.c.math.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/numerics/26.c.math.cpp (original)
+++ stdcxx/branches/4.2.x/tests/numerics/26.c.math.cpp Wed Apr 16 10:01:56 2008
@@ -53,7 +53,7 @@
#define FUN_1(name) \
template <class T> \
T name (T) { \
- static const char* const tname = rw_any (T ()).type_name (); \
+ static const char* const tname = rw_any_t (T ()).type_name (); \
rw_assert (0, 0, __LINE__, "std::%s(%s) not declared\n", \
#name, tname); \
return T (); \
@@ -62,7 +62,7 @@
#define FUN_2(name) \
template <class T> \
T name (T, T) { \
- static const char* const tname = rw_any (T ()).type_name (); \
+ static const char* const tname = rw_any_t (T ()).type_name (); \
rw_assert (0, 0, __LINE__, "std::%s (%s, %s) not declared\n", \
#name, tname, tname); \
return T (); \
@@ -71,7 +71,7 @@
#define FUN_2_PTR(name) \
template <class T> \
T name (T, T*) { \
- static const char* const tname = rw_any (T ()).type_name (); \
+ static const char* const tname = rw_any_t (T ()).type_name (); \
rw_assert (0, 0, __LINE__, "std::%s (%s, %s*) not declared\n", \
#name, tname, tname); \
return T (); \
@@ -80,7 +80,7 @@
#define FUN_2_INT(name) \
template <class T> \
T name (T, int) { \
- static const char* const tname = rw_any (T ()).type_name (); \
+ static const char* const tname = rw_any_t (T ()).type_name (); \
rw_assert (0, 0, __LINE__, "std::%s (%s, int) not declared\n", \
#name, tname); \
return T (); \
@@ -89,7 +89,7 @@
#define FUN_2_PINT(name) \
template <class T> \
T name (T, int*) { \
- static const char* const tname = rw_any (T ()).type_name (); \
+ static const char* const tname = rw_any_t (T ()).type_name (); \
rw_assert (0, 0, __LINE__, "std::%s (%s, int*) not declared\n", \
#name, tname); \
return T (); \
Modified: stdcxx/branches/4.2.x/tests/numerics/26.class.gslice.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/numerics/26.class.gslice.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/numerics/26.class.gslice.cpp (original)
+++ stdcxx/branches/4.2.x/tests/numerics/26.class.gslice.cpp Wed Apr 16 10:01:56 2008
@@ -93,7 +93,7 @@
}
while (inx && factors [inx - 1] == asizes [inx - 1] - 1)
- --inx;
+ --inx;
if (0 == inx) {
factors = 0;
Modified: stdcxx/branches/4.2.x/tests/regress/21.string.stdcxx-162.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/regress/21.string.stdcxx-162.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/regress/21.string.stdcxx-162.cpp (original)
+++ stdcxx/branches/4.2.x/tests/regress/21.string.stdcxx-162.cpp Wed Apr 16 10:01:56 2008
@@ -34,7 +34,7 @@
# define MUTEX pthread_mutex_t
#elif _RWSTD_SOLARIS_THREADS
# include <thread.h>
-# define MUTEX thr_mutex_t
+# define MUTEX mutex_t
#endif // _RWSTD_POSIX_THREADS
int main ()
Modified: stdcxx/branches/4.2.x/tests/regress/22.locale.stdcxx-554.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/regress/22.locale.stdcxx-554.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/regress/22.locale.stdcxx-554.cpp (original)
+++ stdcxx/branches/4.2.x/tests/regress/22.locale.stdcxx-554.cpp Wed Apr 16 10:01:56 2008
@@ -29,19 +29,24 @@
#include <locale> // for std::moneypunct, std::messages
+enum { fill = '\xdc' };
+
template <class charT>
void test_moneypunct (charT)
{
typedef std::moneypunct <charT> PunctT;
- const char fill = '\xdc';
+ // Use a pointer to properly align buffer for placment new.
+ union {
+ void* ptr;
+ char buf [sizeof (PunctT) + 1];
+ } u;
- char buf [sizeof (PunctT) + 1];
- std::memset (buf, fill, sizeof (buf));
+ std::memset (u.buf, fill, sizeof (u.buf));
- PunctT* p = new (buf) PunctT ();
+ PunctT* p = new (u.buf) PunctT ();
- assert (fill == buf [sizeof (PunctT)]);
+ assert (fill == u.buf [sizeof (PunctT)]);
p->~PunctT ();
}
@@ -51,14 +56,16 @@
{
typedef std::messages <charT> MessagesT;
- const char fill = '\xdc';
+ union {
+ void* ptr;
+ char buf [sizeof (MessagesT) + 1];
+ } u;
- char buf [sizeof (MessagesT) + 1];
- std::memset (buf, fill, sizeof (buf));
+ std::memset (u.buf, fill, sizeof (u.buf));
- MessagesT* p = new (buf) MessagesT ();
+ MessagesT* p = new (u.buf) MessagesT ();
- assert (fill == buf [sizeof (MessagesT)]);
+ assert (fill == u.buf [sizeof (MessagesT)]);
p->~MessagesT ();
}
Modified: stdcxx/branches/4.2.x/tests/self/0.char.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/self/0.char.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/self/0.char.cpp (original)
+++ stdcxx/branches/4.2.x/tests/self/0.char.cpp Wed Apr 16 10:01:56 2008
@@ -467,6 +467,8 @@
{ 0, '\0' }
};
+ typedef UserTraits<UserChar> Traits;
+
UserChar udst [nsrc + 1];
for (size_t i = 0; i != nsrc + 1; ++i) {
@@ -480,7 +482,7 @@
"rw_widen(UserChar*, %{#s}%{?}, %zu%{;})",
src, i < nsrc, i);
- rw_assert ( 0 == memcmp (udst, usrc, i * sizeof *udst)
+ rw_assert ( 0 == Traits::compare (udst, usrc, i)
&& 0 == udst [i].f && 0 == udst [i].c,
0, __LINE__,
"rw_widen(UserChar*, %{#s}%{?}, %zu%{;})",
@@ -490,7 +492,7 @@
memset (udst, 1, sizeof udst);
rw_widen (udst, 0, sizeof udst / sizeof *udst);
- rw_assert (0 == memcmp (udst, unull, sizeof udst), 0, __LINE__,
+ rw_assert (0 == Traits::compare (udst, unull, nsrc + 1), 0, __LINE__,
"rw_widen(UserChar*, %{#s}, %zu)",
0, sizeof udst, int (sizeof udst), wnull);
}
Modified: stdcxx/branches/4.2.x/tests/self/0.printf.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/self/0.printf.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/self/0.printf.cpp (original)
+++ stdcxx/branches/4.2.x/tests/self/0.printf.cpp Wed Apr 16 10:01:56 2008
@@ -22,7 +22,7 @@
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
- * Copyright 2005-2007 Rogue Wave Software, Inc.
+ * Copyright 2005-2008 Rogue Wave Software, Inc.
*
**************************************************************************/
@@ -35,8 +35,9 @@
#include <environ.h> // for rw_putenv()
#include <bitset> // for bitset
-#include <ios> // for ios::openmode, ios::seekdir
+#include <ios> // for ios::iostate, ios::openmode, ios::seekdir
#include <string> // for string
+#include <locale> // for locale::all, ...
#include <assert.h> // for assert()
#include <ctype.h> // for isdigit()
@@ -48,6 +49,7 @@
#include <string.h> // for strcpy()
#include <stdarg.h> // for va_arg, ...
#include <time.h> // for struct tm
+#include <locale.h> // for LC_ALL, ...
// disable tests for function name in "%{lF}"
@@ -806,6 +808,29 @@
test_ios_bitmasks ()
{
//////////////////////////////////////////////////////////////////
+ printf ("%s\n", "extension: \"%{Is}\": std::ios_base::iostate");
+
+ const int bad = std::ios_base::badbit;
+ const int eof = std::ios_base::eofbit;
+ const int fail = std::ios_base::failbit;
+ const int good = std::ios_base::goodbit;
+
+ TEST ("[%{Is}]", 0, 0, 0, "[goodbit]");
+ TEST ("[%{Is}]", bad, 0, 0, "[badbit]");
+ TEST ("[%{Is}]", eof, 0, 0, "[eofbit]");
+ TEST ("[%{Is}]", fail, 0, 0, "[failbit]");
+
+ TEST ("[%{#Is}]", 0, 0, 0, "[std::ios::goodbit]");
+ TEST ("[%{#Is}]", bad, 0, 0, "[std::ios::badbit]");
+ TEST ("[%{#Is}]", eof, 0, 0, "[std::ios::eofbit]");
+ TEST ("[%{#Is}]", fail, 0, 0, "[std::ios::failbit]");
+
+ TEST ("[%{Is}]", bad | eof, 0, 0, "[badbit | eofbit]");
+ TEST ("[%{Is}]", bad | fail, 0, 0, "[badbit | failbit]");
+ TEST ("[%{Is}]", eof | fail, 0, 0, "[eofbit | failbit]");
+ TEST ("[%{Is}]", bad | eof | fail, 0, 0, "[badbit | eofbit | failbit]");
+
+ //////////////////////////////////////////////////////////////////
printf ("%s\n", "extension: \"%{Io}\": std::ios_base::opemode");
const int in = std::ios_base::in;
@@ -841,6 +866,240 @@
TEST ("[%{#Iw}]", std::ios::beg, 0, 0, "[std::ios::beg]");
TEST ("[%{#Iw}]", std::ios::cur, 0, 0, "[std::ios::cur]");
TEST ("[%{#Iw}]", std::ios::end, 0, 0, "[std::ios::end]");
+
+ //////////////////////////////////////////////////////////////////
+ printf ("%s\n", "extension: \"%{If}\": std::ios_base::fmtflags");
+
+#define BASE(n) ((n) << _RWSTD_IOS_BASEOFF)
+
+ TEST ("[%{If}]", 0, 0, 0, "[fmtflags(0)]");
+ TEST ("[%{If}]", std::ios::adjustfield, 0, 0, "[adjustfield]");
+ TEST ("[%{If}]", std::ios::basefield, 0, 0, "[basefield]");
+ TEST ("[%{If}]", std::ios::boolalpha, 0, 0, "[boolalpha]");
+ TEST ("[%{If}]", std::ios::dec, 0, 0, "[dec]");
+ TEST ("[%{If}]", std::ios::fixed, 0, 0, "[fixed]");
+ TEST ("[%{If}]", std::ios::hex, 0, 0, "[hex]");
+ TEST ("[%{If}]", std::ios::internal, 0, 0, "[internal]");
+ TEST ("[%{If}]", std::ios::left, 0, 0, "[left]");
+ TEST ("[%{If}]", std::ios::oct, 0, 0, "[oct]");
+ TEST ("[%{If}]", std::ios::right, 0, 0, "[right]");
+ TEST ("[%{If}]", std::ios::scientific, 0, 0, "[scientific]");
+ TEST ("[%{If}]", std::ios::showbase, 0, 0, "[showbase]");
+ TEST ("[%{If}]", std::ios::showpoint, 0, 0, "[showpoint]");
+ TEST ("[%{If}]", std::ios::showpos, 0, 0, "[showpos]");
+ TEST ("[%{If}]", std::ios::skipws, 0, 0, "[skipws]");
+ TEST ("[%{If}]", std::ios::unitbuf, 0, 0, "[unitbuf]");
+ TEST ("[%{If}]", std::ios::uppercase, 0, 0, "[uppercase]");
+#ifndef _RWSTD_NO_EXT_BIN_IO
+ TEST ("[%{If}]", std::ios::bin, 0, 0, "[bin]");
+#endif // _RWSTD_NO_EXT_BIN_IO
+#ifndef _RWSTD_NO_EXT_REENTRANT_IO
+ TEST ("[%{If}]", std::ios::nolock, 0, 0, "[nolock]");
+ TEST ("[%{If}]", std::ios::nolockbuf, 0, 0, "[nolockbuf]");
+#endif // _RWSTD_NO_EXT_REENTRANT_IO
+
+ TEST ("[%{If}]", BASE (1), 0, 0, "[fmtflags(0) | base(1)]");
+ TEST ("[%{If}]", BASE (2), 0, 0, "[fmtflags(0) | base(2)]");
+ TEST ("[%{If}]", BASE (3), 0, 0, "[fmtflags(0) | base(3)]");
+ TEST ("[%{If}]", BASE (4), 0, 0, "[fmtflags(0) | base(4)]");
+ TEST ("[%{If}]", BASE (5), 0, 0, "[fmtflags(0) | base(5)]");
+ TEST ("[%{If}]", BASE (6), 0, 0, "[fmtflags(0) | base(6)]");
+ TEST ("[%{If}]", BASE (7), 0, 0, "[fmtflags(0) | base(7)]");
+ TEST ("[%{If}]", BASE (8), 0, 0, "[fmtflags(0)]");
+ TEST ("[%{If}]", BASE (9), 0, 0, "[fmtflags(0) | base(9)]");
+ TEST ("[%{If}]", BASE (10), 0, 0, "[fmtflags(0)]");
+ TEST ("[%{If}]", BASE (11), 0, 0, "[fmtflags(0) | base(11)]");
+ TEST ("[%{If}]", BASE (12), 0, 0, "[fmtflags(0) | base(12)]");
+ TEST ("[%{If}]", BASE (13), 0, 0, "[fmtflags(0) | base(13)]");
+ TEST ("[%{If}]", BASE (14), 0, 0, "[fmtflags(0) | base(14)]");
+ TEST ("[%{If}]", BASE (15), 0, 0, "[fmtflags(0) | base(15)]");
+ TEST ("[%{If}]", BASE (16), 0, 0, "[fmtflags(0)]");
+ TEST ("[%{If}]", BASE (17), 0, 0, "[fmtflags(0) | base(17)]");
+ TEST ("[%{If}]", BASE (18), 0, 0, "[fmtflags(0) | base(18)]");
+ TEST ("[%{If}]", BASE (19), 0, 0, "[fmtflags(0) | base(19)]");
+ TEST ("[%{If}]", BASE (20), 0, 0, "[fmtflags(0) | base(20)]");
+ TEST ("[%{If}]", BASE (21), 0, 0, "[fmtflags(0) | base(21)]");
+ TEST ("[%{If}]", BASE (22), 0, 0, "[fmtflags(0) | base(22)]");
+ TEST ("[%{If}]", BASE (23), 0, 0, "[fmtflags(0) | base(23)]");
+ TEST ("[%{If}]", BASE (24), 0, 0, "[fmtflags(0) | base(24)]");
+ TEST ("[%{If}]", BASE (25), 0, 0, "[fmtflags(0) | base(25)]");
+ TEST ("[%{If}]", BASE (26), 0, 0, "[fmtflags(0) | base(26)]");
+ TEST ("[%{If}]", BASE (27), 0, 0, "[fmtflags(0) | base(27)]");
+ TEST ("[%{If}]", BASE (28), 0, 0, "[fmtflags(0) | base(28)]");
+ TEST ("[%{If}]", BASE (29), 0, 0, "[fmtflags(0) | base(29)]");
+ TEST ("[%{If}]", BASE (30), 0, 0, "[fmtflags(0) | base(30)]");
+ TEST ("[%{If}]", BASE (31), 0, 0, "[fmtflags(0) | base(31)]");
+ TEST ("[%{If}]", BASE (32), 0, 0, "[fmtflags(0) | base(32)]");
+ TEST ("[%{If}]", BASE (33), 0, 0, "[fmtflags(0) | base(33)]");
+ TEST ("[%{If}]", BASE (34), 0, 0, "[fmtflags(0) | base(34)]");
+ TEST ("[%{If}]", BASE (35), 0, 0, "[fmtflags(0) | base(35)]");
+ TEST ("[%{If}]", BASE (36), 0, 0, "[fmtflags(0) | base(36)]");
+
+ TEST ("[%{#If}]", 0, 0, 0, "[std::ios::fmtflags(0)]");
+ TEST ("[%{#If}]", std::ios::adjustfield, 0, 0, "[std::ios::adjustfield]");
+ TEST ("[%{#If}]", std::ios::basefield, 0, 0, "[std::ios::basefield]");
+ TEST ("[%{#If}]", std::ios::boolalpha, 0, 0, "[std::ios::boolalpha]");
+ TEST ("[%{#If}]", std::ios::dec, 0, 0, "[std::ios::dec]");
+ TEST ("[%{#If}]", std::ios::fixed, 0, 0, "[std::ios::fixed]");
+ TEST ("[%{#If}]", std::ios::hex, 0, 0, "[std::ios::hex]");
+ TEST ("[%{#If}]", std::ios::internal, 0, 0, "[std::ios::internal]");
+ TEST ("[%{#If}]", std::ios::left, 0, 0, "[std::ios::left]");
+ TEST ("[%{#If}]", std::ios::oct, 0, 0, "[std::ios::oct]");
+ TEST ("[%{#If}]", std::ios::right, 0, 0, "[std::ios::right]");
+ TEST ("[%{#If}]", std::ios::scientific, 0, 0, "[std::ios::scientific]");
+ TEST ("[%{#If}]", std::ios::showbase, 0, 0, "[std::ios::showbase]");
+ TEST ("[%{#If}]", std::ios::showpoint, 0, 0, "[std::ios::showpoint]");
+ TEST ("[%{#If}]", std::ios::showpos, 0, 0, "[std::ios::showpos]");
+ TEST ("[%{#If}]", std::ios::skipws, 0, 0, "[std::ios::skipws]");
+ TEST ("[%{#If}]", std::ios::unitbuf, 0, 0, "[std::ios::unitbuf]");
+ TEST ("[%{#If}]", std::ios::uppercase, 0, 0, "[std::ios::uppercase]");
+#ifndef _RWSTD_NO_EXT_BIN_IO
+ TEST ("[%{#If}]", std::ios::bin, 0, 0, "[std::ios::bin]");
+#endif // _RWSTD_NO_EXT_BIN_IO
+#ifndef _RWSTD_NO_EXT_REENTRANT_IO
+ TEST ("[%{#If}]", std::ios::nolock, 0, 0, "[std::ios::nolock]");
+ TEST ("[%{#If}]", std::ios::nolockbuf, 0, 0, "[std::ios::nolockbuf]");
+#endif // _RWSTD_NO_EXT_REENTRANT_IO
+
+ TEST ("[%{#If}]", BASE (1), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(1)]");
+ TEST ("[%{#If}]", BASE (2), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(2)]");
+ TEST ("[%{#If}]", BASE (3), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(3)]");
+ TEST ("[%{#If}]", BASE (4), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(4)]");
+ TEST ("[%{#If}]", BASE (5), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(5)]");
+ TEST ("[%{#If}]", BASE (6), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(6)]");
+ TEST ("[%{#If}]", BASE (7), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(7)]");
+ TEST ("[%{#If}]", BASE (8), 0, 0,
+ "[std::ios::fmtflags(0)]");
+ TEST ("[%{#If}]", BASE (9), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(9)]");
+ TEST ("[%{#If}]", BASE (10), 0, 0,
+ "[std::ios::fmtflags(0)]");
+ TEST ("[%{#If}]", BASE (11), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(11)]");
+ TEST ("[%{#If}]", BASE (12), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(12)]");
+ TEST ("[%{#If}]", BASE (13), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(13)]");
+ TEST ("[%{#If}]", BASE (14), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(14)]");
+ TEST ("[%{#If}]", BASE (15), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(15)]");
+ TEST ("[%{#If}]", BASE (16), 0, 0,
+ "[std::ios::fmtflags(0)]");
+ TEST ("[%{#If}]", BASE (17), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(17)]");
+ TEST ("[%{#If}]", BASE (18), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(18)]");
+ TEST ("[%{#If}]", BASE (19), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(19)]");
+ TEST ("[%{#If}]", BASE (20), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(20)]");
+ TEST ("[%{#If}]", BASE (21), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(21)]");
+ TEST ("[%{#If}]", BASE (22), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(22)]");
+ TEST ("[%{#If}]", BASE (23), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(23)]");
+ TEST ("[%{#If}]", BASE (24), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(24)]");
+ TEST ("[%{#If}]", BASE (25), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(25)]");
+ TEST ("[%{#If}]", BASE (26), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(26)]");
+ TEST ("[%{#If}]", BASE (27), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(27)]");
+ TEST ("[%{#If}]", BASE (28), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(28)]");
+ TEST ("[%{#If}]", BASE (29), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(29)]");
+ TEST ("[%{#If}]", BASE (30), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(30)]");
+ TEST ("[%{#If}]", BASE (31), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(31)]");
+ TEST ("[%{#If}]", BASE (32), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(32)]");
+ TEST ("[%{#If}]", BASE (33), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(33)]");
+ TEST ("[%{#If}]", BASE (34), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(34)]");
+ TEST ("[%{#If}]", BASE (35), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(35)]");
+ TEST ("[%{#If}]", BASE (36), 0, 0,
+ "[std::ios::fmtflags(0) | std::ios::base(36)]");
+
+ //////////////////////////////////////////////////////////////////
+ printf ("%s\n", "extension: \"%{Ie}\": std::ios_base::event");
+
+ TEST ("[%{Ie}]", std::ios::erase_event, 0, 0, "[erase_event]");
+ TEST ("[%{Ie}]", std::ios::imbue_event, 0, 0, "[imbue_event]");
+ TEST ("[%{Ie}]", std::ios::copyfmt_event, 0, 0, "[copyfmt_event]");
+ TEST ("[%{Ie}]", 3, 0, 0, "[event(3)]");
+ TEST ("[%{Ie}]", 10, 0, 0, "[event(10)]");
+
+ TEST ("[%{#Ie}]", std::ios::erase_event, 0, 0,
+ "[std::ios::erase_event]");
+ TEST ("[%{#Ie}]", std::ios::imbue_event, 0, 0,
+ "[std::ios::imbue_event]");
+ TEST ("[%{#Ie}]", std::ios::copyfmt_event, 0, 0,
+ "[std::ios::copyfmt_event]");
+ TEST ("[%{#Ie}]", 3, 0, 0,
+ "[std::ios::event(3)]");
+ TEST ("[%{#Ie}]", 10, 0, 0,
+ "[std::ios::event(10)]");
+}
+
+/***********************************************************************/
+
+static void
+test_locale_category ()
+{
+ //////////////////////////////////////////////////////////////////
+ printf ("%s\n", "extension: \"%{Lc}\": locale category");
+
+ TEST ("[%{Lc}]", LC_ALL, 0, 0, "[LC_ALL]");
+ TEST ("[%{Lc}]", LC_COLLATE, 0, 0, "[LC_COLLATE]");
+ TEST ("[%{Lc}]", LC_CTYPE, 0, 0, "[LC_CTYPE]");
+ TEST ("[%{Lc}]", LC_MONETARY, 0, 0, "[LC_MONETARY]");
+ TEST ("[%{Lc}]", LC_NUMERIC, 0, 0, "[LC_NUMERIC]");
+ TEST ("[%{Lc}]", LC_TIME, 0, 0, "[LC_TIME]");
+#ifdef LC_MESSAGES
+ TEST ("[%{Lc}]", LC_MESSAGES, 0, 0, "[LC_MESSAGES]");
+#endif // LC_MESSAGES
+
+ TEST ("[%{Lc}]", std::locale::all, 0, 0, "[all]");
+ TEST ("[%{Lc}]", std::locale::none, 0, 0, "[none]");
+ TEST ("[%{Lc}]", std::locale::collate, 0, 0, "[collate]");
+ TEST ("[%{Lc}]", std::locale::ctype, 0, 0, "[ctype]");
+ TEST ("[%{Lc}]", std::locale::monetary, 0, 0, "[monetary]");
+ TEST ("[%{Lc}]", std::locale::numeric, 0, 0, "[numeric]");
+ TEST ("[%{Lc}]", std::locale::messages, 0, 0, "[messages]");
+ TEST ("[%{Lc}]", std::locale::time, 0, 0, "[time]");
+
+ TEST ("[%{#Lc}]", LC_ALL, 0, 0, "[LC_ALL]");
+ TEST ("[%{#Lc}]", LC_COLLATE, 0, 0, "[LC_COLLATE]");
+ TEST ("[%{#Lc}]", LC_CTYPE, 0, 0, "[LC_CTYPE]");
+ TEST ("[%{#Lc}]", LC_MONETARY, 0, 0, "[LC_MONETARY]");
+ TEST ("[%{#Lc}]", LC_NUMERIC, 0, 0, "[LC_NUMERIC]");
+ TEST ("[%{#Lc}]", LC_TIME, 0, 0, "[LC_TIME]");
+#ifdef LC_MESSAGES
+ TEST ("[%{#Lc}]", LC_MESSAGES, 0, 0, "[LC_MESSAGES]");
+#endif // LC_MESSAGES
+
+ TEST ("[%{#Lc}]", std::locale::all, 0, 0, "[std::locale::all]");
+ TEST ("[%{#Lc}]", std::locale::none, 0, 0, "[std::locale::none]");
+ TEST ("[%{#Lc}]", std::locale::collate, 0, 0, "[std::locale::collate]");
+ TEST ("[%{#Lc}]", std::locale::ctype, 0, 0, "[std::locale::ctype]");
+ TEST ("[%{#Lc}]", std::locale::monetary, 0, 0, "[std::locale::monetary]");
+ TEST ("[%{#Lc}]", std::locale::numeric, 0, 0, "[std::locale::numeric]");
+ TEST ("[%{#Lc}]", std::locale::messages, 0, 0, "[std::locale::messages]");
+ TEST ("[%{#Lc}]", std::locale::time, 0, 0, "[std::locale::time]");
}
/***********************************************************************/
@@ -1869,68 +2128,68 @@
static size_t big_endian = size_t (0 == u.bytes [0]);
- const size_t lo_inx = size_t (1 - big_endian);
- const size_t hi_inx = size_t (big_endian);
+ const size_t lo_inx = size_t (big_endian);
+ const size_t hi_inx = size_t (1 - big_endian);
#if 4 == _RWSTD_LONG_SIZE
uval.lval [hi_inx] = 0UL;
uval.lval [lo_inx] = 0UL;
- TEST ("%{M}", uval.mptr, 0, 0, "00000000:00000000");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x00000000:00000000");
+ TEST ("%{M}", uval.mptr, 0, 0, "0000000000000000");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x0000000000000000");
uval.lval [lo_inx] = 1UL;
- TEST ("%{M}", uval.mptr, 0, 0, "00000000:00000001");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x00000000:00000001");
+ TEST ("%{M}", uval.mptr, 0, 0, "0000000000000001");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x0000000000000001");
uval.lval [lo_inx] = 0xffffffffUL;
- TEST ("%{M}", uval.mptr, 0, 0, "00000000:ffffffff");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x00000000:ffffffff");
+ TEST ("%{M}", uval.mptr, 0, 0, "00000000ffffffff");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x00000000ffffffff");
uval.lval [hi_inx] = 0xdeadbeefUL;
uval.lval [lo_inx] = 0UL;
- TEST ("%{M}", uval.mptr, 0, 0, "deadbeef:00000000");
- TEST ("%{#M}", uval.mptr, 0, 0, "0xdeadbeef:00000000");
+ TEST ("%{M}", uval.mptr, 0, 0, "deadbeef00000000");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0xdeadbeef00000000");
uval.lval [lo_inx] = 0x1aUL;
- TEST ("%{M}", uval.mptr, 0, 0, "deadbeef:0000001a");
- TEST ("%{#M}", uval.mptr, 0, 0, "0xdeadbeef:0000001a");
+ TEST ("%{M}", uval.mptr, 0, 0, "deadbeef0000001a");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0xdeadbeef0000001a");
uval.lval [lo_inx] = 0x0fff1fffUL;
- TEST ("%{M}", uval.mptr, 0, 0, "deadbeef:0fff1fff");
- TEST ("%{#M}", uval.mptr, 0, 0, "0xdeadbeef:0fff1fff");
+ TEST ("%{M}", uval.mptr, 0, 0, "deadbeef0fff1fff");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0xdeadbeef0fff1fff");
#elif 8 == _RWSTD_LONG_SIZE
uval.lval [hi_inx] = 0UL;
uval.lval [lo_inx] = 0UL;
- TEST ("%{M}", uval.mptr, 0, 0, "0000000000000000:0000000000000000");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x0000000000000000:0000000000000000");
+ TEST ("%{M}", uval.mptr, 0, 0, "00000000000000000000000000000000");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x00000000000000000000000000000000");
uval.lval [lo_inx] = 1UL;
- TEST ("%{M}", uval.mptr, 0, 0, "0000000000000000:0000000000000001");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x0000000000000000:0000000000000001");
+ TEST ("%{M}", uval.mptr, 0, 0, "00000000000000000000000000000001");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x00000000000000000000000000000001");
uval.lval [lo_inx] = 0xffffffffUL;
- TEST ("%{M}", uval.mptr, 0, 0, "0000000000000000:00000000ffffffff");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x0000000000000000:00000000ffffffff");
+ TEST ("%{M}", uval.mptr, 0, 0, "000000000000000000000000ffffffff");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x000000000000000000000000ffffffff");
uval.lval [hi_inx] = 0x0123456789abcdefUL;
uval.lval [lo_inx] = 0UL;
- TEST ("%{M}", uval.mptr, 0, 0, "0123456789abcdef:0000000000000000");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x0123456789abcdef:0000000000000000");
+ TEST ("%{M}", uval.mptr, 0, 0, "0123456789abcdef0000000000000000");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x0123456789abcdef0000000000000000");
uval.lval [lo_inx] = 0x1aUL;
- TEST ("%{M}", uval.mptr, 0, 0, "0123456789abcdef:000000000000001a");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x0123456789abcdef:000000000000001a");
+ TEST ("%{M}", uval.mptr, 0, 0, "0123456789abcdef000000000000001a");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x0123456789abcdef000000000000001a");
uval.lval [lo_inx] = 0x0fff1fffUL;
- TEST ("%{M}", uval.mptr, 0, 0, "0123456789abcdef:000000000fff1fff");
- TEST ("%{#M}", uval.mptr, 0, 0, "0x0123456789abcdef:000000000fff1fff");
+ TEST ("%{M}", uval.mptr, 0, 0, "0123456789abcdef000000000fff1fff");
+ TEST ("%{#M}", uval.mptr, 0, 0, "0x0123456789abcdef000000000fff1fff");
#else
@@ -3045,6 +3304,8 @@
test_basic_string ();
test_ios_bitmasks ();
+
+ test_locale_category ();
test_ctype_mask ();
Modified: stdcxx/branches/4.2.x/tests/src/21.strings.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/21.strings.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/21.strings.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/21.strings.cpp Wed Apr 16 10:01:56 2008
@@ -630,7 +630,6 @@
case StringIds::find_last_not_of_cstr:
case StringIds::compare_cstr:
case StringIds::ctor_cstr:
- case StringIds::ctor_cstr_alloc:
case StringIds::op_set_cstr:
case StringIds::swap_str:
// format self-referential str argument as *this
Modified: stdcxx/branches/4.2.x/tests/src/23.containers.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/23.containers.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/23.containers.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/23.containers.cpp Wed Apr 16 10:01:56 2008
@@ -33,6 +33,7 @@
#include <23.list.h>
#include <cmdopt.h> // for rw_enabled()
+#include <driver.h> // for rw_note()
#include <rw_allocator.h> // for UserAlloc
#include <rw_printf.h> // for rw_asnprintf()
@@ -532,6 +533,16 @@
const ContainerTestCase &tcase)
{
// temporary empty
+
+ _RWSTD_UNUSED (pbuf);
+ _RWSTD_UNUSED (pbufsize);
+ _RWSTD_UNUSED (which);
+ _RWSTD_UNUSED (self);
+ _RWSTD_UNUSED (str);
+ _RWSTD_UNUSED (str_len);
+ _RWSTD_UNUSED (arg);
+ _RWSTD_UNUSED (arg_len);
+ _RWSTD_UNUSED (tcase);
}
/**************************************************************************/
@@ -551,6 +562,16 @@
const ContainerTestCase &tcase)
{
// temporary empty
+
+ _RWSTD_UNUSED (pbuf);
+ _RWSTD_UNUSED (pbufsize);
+ _RWSTD_UNUSED (which);
+ _RWSTD_UNUSED (self);
+ _RWSTD_UNUSED (str);
+ _RWSTD_UNUSED (str_len);
+ _RWSTD_UNUSED (arg);
+ _RWSTD_UNUSED (arg_len);
+ _RWSTD_UNUSED (tcase);
}
/**************************************************************************/
@@ -570,6 +591,16 @@
const ContainerTestCase &tcase)
{
// temporary empty
+
+ _RWSTD_UNUSED (pbuf);
+ _RWSTD_UNUSED (pbufsize);
+ _RWSTD_UNUSED (which);
+ _RWSTD_UNUSED (self);
+ _RWSTD_UNUSED (str);
+ _RWSTD_UNUSED (str_len);
+ _RWSTD_UNUSED (arg);
+ _RWSTD_UNUSED (arg_len);
+ _RWSTD_UNUSED (tcase);
}
/**************************************************************************/
@@ -589,6 +620,16 @@
const ContainerTestCase &tcase)
{
// temporary empty
+
+ _RWSTD_UNUSED (pbuf);
+ _RWSTD_UNUSED (pbufsize);
+ _RWSTD_UNUSED (which);
+ _RWSTD_UNUSED (self);
+ _RWSTD_UNUSED (str);
+ _RWSTD_UNUSED (str_len);
+ _RWSTD_UNUSED (arg);
+ _RWSTD_UNUSED (arg_len);
+ _RWSTD_UNUSED (tcase);
}
/**************************************************************************/
Modified: stdcxx/branches/4.2.x/tests/src/char.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/char.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/char.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/char.cpp Wed Apr 16 10:01:56 2008
@@ -1284,7 +1284,7 @@
if (-1 == elemsize || 1 == elemsize) {
if (nelems < 0)
- nelems = beg.pc ? strlen (beg.pc) : 0;
+ nelems = beg.pc ? int (strlen (beg.pc)) : 0;
nbytes = rw_asnprintf (pbuf, pbufsize, "%{+}%{#*s}", nelems, beg.pc);
}
Modified: stdcxx/branches/4.2.x/tests/src/ctype.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/ctype.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/ctype.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/ctype.cpp Wed Apr 16 10:01:56 2008
@@ -43,6 +43,9 @@
static void
_rw_throw (const char *file, int line, const char *fmt, ...)
{
+ _RWSTD_UNUSED (file);
+ _RWSTD_UNUSED (line);
+
struct Exception: UserCtypeBase::Exception {
char what_ [256];
Modified: stdcxx/branches/4.2.x/tests/src/driver.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/driver.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/driver.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/driver.cpp Wed Apr 16 10:01:56 2008
@@ -45,6 +45,10 @@
#include <stdlib.h> // for free
#include <string.h> // for strchr, strcpy
+#ifdef _MSC_VER
+# include <crtdbg.h> // for _CrtSetReportMode(), _CrtSetDbgFlag()
+#endif
+
#if !defined (_WIN32) && !defined (_WIN64)
# include <unistd.h> // for isatty()
# include <sys/resource.h> // for setlimit()
@@ -488,6 +492,12 @@
// set mode: enable the option
opt_verbose = 1;
+#ifdef _MSC_VER
+ _CrtSetDbgFlag ( _CRTDBG_ALLOC_MEM_DF
+ | _CRTDBG_CHECK_ALWAYS_DF
+ | _CRTDBG_LEAK_CHECK_DF);
+#endif
+
return 0;
}
@@ -537,6 +547,12 @@
// set mode: enable the option
opt_compat = 1;
+#ifdef _MSC_VER
+ _CrtSetReportMode (_CRT_WARN, _CRTDBG_MODE_DEBUG);
+ _CrtSetReportMode (_CRT_ERROR, _CRTDBG_MODE_DEBUG);
+ _CrtSetReportMode (_CRT_ASSERT, _CRTDBG_MODE_DEBUG);
+#endif
+
return 0;
}
@@ -1540,7 +1556,7 @@
/************************************************************************/
-_TEST_EXPORT void
+_TEST_EXPORT bool
rw_enable (int (*fun) (int, const char*, int, const char*, ...), bool enable)
{
diag_t diag;
@@ -1559,12 +1575,16 @@
diag = diag_info;
else {
RW_ASSERT (!"Invalid function in rw_enable");
- return;
+ return false;
}
+ const bool enabled = 0 == (_rw_diag_ignore & (1 << diag));
+
// if (enable)
// _rw_diag_ignore &= ~(1 << diag);
// else
// _rw_diag_ignore |= 1 << diag;
_rw_diag_ignore ^= ((enable - 1) ^ _rw_diag_ignore) & (1 << diag);
+
+ return enabled;
}
Modified: stdcxx/branches/4.2.x/tests/src/environ.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/environ.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/environ.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/environ.cpp Wed Apr 16 10:01:56 2008
@@ -93,7 +93,8 @@
const size_t varlen = pend - pvar;
- char* const envvar = (char*)malloc (pend - pvar + 1);
+ // reserve the one more character for Windows mode
+ char* const envvar = (char*)malloc (varlen + 2);
if (0 == envvar)
return -1;
@@ -101,10 +102,13 @@
envvar [varlen] = '\0';
// look for the first equals sign
- const char* const equals = strchr (envvar, '=');
+ char* const equals = strchr (envvar, '=');
char *var = 0;
+ // putenv mode: 0 - POSIX; 1 - undefined; 2 - Windows
+ static int mode = 1;
+
if (equals) {
// add the variable to the environment or modify it if
// it's already defined
@@ -112,21 +116,46 @@
// Note: calling Solaris 7 putenv() during program startup
// (i.e., from ctors of namespace-scope objects) prevents
// getenv() from finding that variable at program runtime
- ret = putenv (envvar);
+
+ char namebuf [256];
+ const size_t namelen = equals - envvar;
+ assert (namelen < sizeof (namebuf));
+
+ memcpy (namebuf, envvar, namelen);
+ namebuf [namelen] = '\0';
+
+ switch (!equals [1] * mode) {
+ case 0:
+ ret = putenv (envvar);
+ break;
+ case 1:
+ ret = putenv (envvar);
+ if (getenv (namebuf)) {
+ mode = 0;
+ break;
+ }
+ mode = 2;
+ // fall through
+ case 2:
+ // on Windows it's impossible to set empty environment variable
+ // append any character after '='
+ equals [1] = '1';
+ equals [2] = '\0';
+ ret = putenv (envvar);
+ equals [1] = '\0';
+ break;
+ }
// determine wheteher putenv() made copy of the variable
// or if it simply used the pointer passed to it; if the
// former, deallocate the buffer dynamically allocated
// above
-
- char namebuf [256];
- assert (size_t (equals - envvar) < sizeof namebuf);
-
- memcpy (namebuf, envvar, equals - envvar);
- namebuf [equals - envvar] = '\0';
-
var = getenv (namebuf);
+ // empty the environment variable directly on Windows
+ if (!equals [1] && 2 == mode)
+ *var = '\0';
+
if (equals + 1 != var)
free (envvar);
}
@@ -143,7 +172,27 @@
ret = unsetenv (envvar);
# endif // FreeBSD ...
#else // ifdef _RWSTD_NO_UNSETENV
- ret = putenv (envvar);
+ switch (mode) {
+ case 0:
+ ret = putenv (envvar);
+ break;
+ case 1:
+ ret = putenv (envvar);
+ if (!getenv (envvar)) {
+ mode = 0;
+ break;
+ }
+ mode = 2;
+ // fall through
+ case 2:
+ // on Windows append '=' character to remove
+ // the environment variable
+ envvar [varlen] = '=';
+ envvar [varlen + 1] = '\0';
+ ret = putenv (envvar);
+ envvar [varlen] = '\0';
+ break;
+ }
#endif // _RWSTD_NO_UNSETENV
if (0 == ret) {
Modified: stdcxx/branches/4.2.x/tests/src/fmt_bits.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/fmt_bits.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/fmt_bits.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/fmt_bits.cpp Wed Apr 16 10:01:56 2008
@@ -22,7 +22,7 @@
* implied. See the License for the specific language governing
* permissions and limitations under the License.
*
- * Copyright 2005-2006 Rogue Wave Software.
+ * Copyright 2005-2008 Rogue Wave Software. Inc.
*
**************************************************************************/
@@ -134,10 +134,16 @@
// verify that buffer wasn't overflowed
RW_ASSERT (buffersize <= sizeof buffer);
+ // NUL-terminate string so that it can be appended to using
+ // the %{+} directive, taking care not to make the NUL a part
+ // of the formatted string
FmtSpec newspec (spec);
newspec.fl_pound = 0;
- return _rw_fmtstr (newspec, buf, buffer, buffersize);
+ const int len = _rw_fmtstr (newspec, buf, buffer, buffersize + 1);
+ --buf.endoff;
+
+ return 0 < len ? len - 1 : len;
}
/********************************************************************/
@@ -179,7 +185,7 @@
#endif // _RWSTD_NO_EXT_REENTRANT_IO
- { "std::ios::iostate(0)", "iostate(0)", std::ios::iostate () }
+ { "std::ios::fmtflags(0)", "fmtflags(0)", std::ios::fmtflags () }
};
@@ -192,7 +198,7 @@
int len = _rw_bmpfmt (spec, buf, names, count, bits);
- if (base && base != 8 && base != 10 && base != 16) {
+ if (0 < len && base && base != 8 && base != 10 && base != 16) {
// for numeric bases other than those required by the standard,
// use the text "base (%d)" to show the extended numeric base
@@ -204,7 +210,19 @@
#endif // _RWSTD_NO_EXT_BIN_IO
- len = rw_asnprintf (buf.pbuf, buf.pbufsize, "%{+} | std::ios::base(%d)", base);
+ const int n = rw_asnprintf (buf.pbuf, buf.pbufsize,
+ "%{+} | %{?}std::ios::%{;}base(%d)",
+ spec.fl_pound, base);
+
+ if (0 < n) {
+ // adjust length and the end offset after appending above
+ len += n;
+ buf.endoff += n;
+ }
+ else {
+ // error (most likely ENOMEM)
+ len = n;
+ }
}
return len;
@@ -293,7 +311,7 @@
/********************************************************************/
/* extern */ int
-_rw_fmtevent (const FmtSpec&, Buffer &buf, int event)
+_rw_fmtevent (const FmtSpec& spec, Buffer &buf, int event)
{
const char* const str =
std::ios::copyfmt_event == event ? "copyfmt_event"
@@ -301,9 +319,26 @@
: std::ios::erase_event == event ? "erase_event"
: 0;
- return rw_asnprintf (buf.pbuf, buf.pbufsize,
- "%{+}%{?}%s%{:}copyfmt_event(%d)%{;}",
- 0 != str, str, event);
+ // NUL-terminate before appending below
+ FmtSpec newspec (spec);
+ newspec.fl_pound = 0;
+
+ int len = _rw_fmtstr (newspec, buf, "", 1);
+
+ if (1 == len) {
+ // back up before the terminating NUL
+ buf.endoff -= 1;
+
+ // append name of event
+ len = rw_asnprintf (buf.pbuf, buf.pbufsize,
+ "%{+}%{?}std::ios::%{;}%{?}%s%{:}event(%d)%{;}",
+ spec.fl_pound, 0 != str, str, event);
+
+ if (0 < len)
+ buf.endoff += len;
+ }
+
+ return len;
}
/********************************************************************/
@@ -327,8 +362,25 @@
}
- if (str)
- return rw_asnprintf (buf.pbuf, buf.pbufsize, "%{+}%s", str);
+ if (str) {
+ // NUL-terminate before appending below
+ FmtSpec newspec (spec);
+ newspec.fl_pound = 0;
+
+ int len = _rw_fmtstr (newspec, buf, "", 1);
+
+ if (1 == len) {
+ // back up before the terminating NUL
+ buf.endoff -= 1;
+
+ len = rw_asnprintf (buf.pbuf, buf.pbufsize, "%{+}%s", str);
+
+ if (0 < len)
+ buf.endoff += len;
+ }
+
+ return len;
+ }
static const Bitnames names [] = {
BITNAME (std::locale, all),
Modified: stdcxx/branches/4.2.x/tests/src/locale.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/locale.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/locale.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/locale.cpp Wed Apr 16 10:01:56 2008
@@ -36,6 +36,8 @@
#include <file.h> // for SHELL_RM_RF, rw_tmpnam
#include <rw_process.h> // for rw_system()
#include <rw_printf.h> // for rw_snprintf()
+#include <rw_fnmatch.h> // for rw_fnmatch()
+#include <rw_braceexp.h> // for rw_shell_expand()
#include <driver.h> // for rw_error()
#ifdef _RWSTD_OS_LINUX
@@ -79,12 +81,15 @@
# ifndef LC_MESSAGES
# define LC_MESSAGES _RWSTD_LC_MESSAGES
# endif // LC_MESSAGES
-# include <langinfo.h>
# define EXE_SUFFIX ""
#else // if MSVC
+# define _RWSTD_NO_LANGINFO
# define EXE_SUFFIX ".exe"
#endif // _MSC_VER
+#ifndef _RWSTD_NO_LANGINFO
+# include <langinfo.h>
+#endif
#if !defined (PATH_MAX) || PATH_MAX < 128 || 4096 < PATH_MAX
// deal with undefined, bogus, or excessive values
@@ -288,8 +293,14 @@
static void atexit_rm_locale_root ()
{
+ const bool e = rw_enable (rw_error, false);
+ const bool n = rw_enable (rw_note , false);
+
// remove temporary locale databases created by the test
rw_system (SHELL_RM_RF "%s", rw_locale_root);
+
+ rw_enable (rw_note , n);
+ rw_enable (rw_error, e);
}
}
@@ -362,6 +373,10 @@
// allocate first time through
if (!slocname) {
slocname = _RWSTD_STATIC_CAST (char*, _QUIET_MALLOC (total_size));
+
+ if (!slocname)
+ return deflocname;
+
*slocname = '\0';
}
@@ -388,16 +403,16 @@
return deflocname; // error
}
- // make sure that grep_exp is <= 80
+ // make sure that grep_exp is <= 80
if (grep_exp && 80 < strlen (grep_exp)) {
abort ();
}
// execute a shell command and redirect its output into the file
const int exit_status =
- grep_exp && *grep_exp
- ? rw_system ("locale -a | grep \"%s\" > %s", grep_exp, fname)
- : rw_system ("locale -a > %s", fname);
+ grep_exp && *grep_exp
+ ? rw_system ("locale -a | grep \"%s\" > %s", grep_exp, fname)
+ : rw_system ("locale -a > %s", fname);
if (exit_status) {
return deflocname; // error
@@ -457,6 +472,8 @@
char* tmp =
_RWSTD_STATIC_CAST (char*, _QUIET_MALLOC (total_size));
+ if (!tmp)
+ break;
memcpy (tmp, slocname, total_size - grow_size);
@@ -641,7 +658,8 @@
// determine whether the wide character is valid
// and if so, the length of the multibyte character
// that corresponds to it
- const int len = wctomb (tmp, wchar_t (i));
+ const wchar_t wc = wchar_t (i);
+ const int len = wctomb (tmp, wc);
if (nbytes == 0 && 0 < len || nbytes != 0 && nbytes == len) {
// if the requested length is 0 (i.e., the caller doesn't
@@ -650,7 +668,7 @@
// and the value returned from mblen() is the same, store
// it (this makes it possible to find invalid characters
// as well as valid ones)
- wbuf [nchars++];
+ wbuf [nchars++] = wc;
if (nchars == bufsize)
return nchars;
}
@@ -671,10 +689,10 @@
wc |= wchar_t (rand ());
}
- const int len = wctomb (tmp, wchar_t (i));
+ const int len = wctomb (tmp, wc);
if (nbytes == 0 && 0 < len || nbytes != 0 && nbytes == len) {
- wbuf [nchars++];
+ wbuf [nchars++] = wc;
if (nchars == bufsize)
return nchars;
}
@@ -930,3 +948,706 @@
return ret;
}
+
+inline bool
+_rw_isspace (char ch)
+{
+ return 0 != isspace ((unsigned char)ch);
+}
+
+inline char
+_rw_toupper (char ch)
+{
+ return toupper ((unsigned char)ch);
+}
+
+inline char
+_rw_tolower (char ch)
+{
+ return tolower ((unsigned char)ch);
+}
+
+// our locale database is a big array of these
+struct _rw_locale_entry {
+ char locale_name [64]; // English_United States.1252
+ char canonical_name [32]; // en-US-1-1252
+ struct _rw_locale_entry* next;
+};
+
+struct _rw_locale_array {
+ _rw_locale_entry* entries;
+ _RWSTD_SIZE_T count;
+};
+
+struct _rw_lookup_entry_t {
+ const char* native;
+ const char* canonical;
+};
+
+extern "C" {
+
+static int
+_rw_lookup_comparator (const void* _lhs, const void* _rhs)
+{
+ const _rw_lookup_entry_t* lhs = (const _rw_lookup_entry_t*)_lhs;
+ const _rw_lookup_entry_t* rhs = (const _rw_lookup_entry_t*)_rhs;
+
+ return strcmp (lhs->native, rhs->native);
+}
+
+} // extern "C"
+
+struct _rw_lookup_table_t {
+
+ _rw_lookup_table_t ()
+ : entries_ (0), count_ (0), table_data_ (0) {
+ }
+
+ ~_rw_lookup_table_t () {
+ if (entries_)
+ free (entries_);
+ entries_ = 0;
+ count_ = 0;
+
+ if (table_data_)
+ free (table_data_);
+ table_data_ = 0;
+ }
+
+ bool load_from_file (const char* path, const char* file, int upper_or_lower);
+
+ const _rw_lookup_entry_t* get_entries () const {
+ return entries_;
+ }
+
+ size_t get_num_entries () const {
+ return count_;
+ }
+
+ const char* get_canonical_name (const char* name) const;
+
+private:
+
+ _rw_lookup_entry_t* entries_;
+ size_t count_;
+ char* table_data_;
+
+private:
+ // intentionally hidden
+ _rw_lookup_table_t (const _rw_lookup_table_t& rhs);
+ _rw_lookup_table_t& operator= (const _rw_lookup_table_t& rhs);
+};
+
+
+static void
+_rw_reset_locales (_rw_locale_array* a)
+{
+ // reset the next pointers so that all locales are included
+ for (size_t i = 0; i < a->count; ++i)
+ a->entries [i].next = &a->entries [i+1];
+ a->entries [a->count - 1].next = 0;
+}
+
+//
+// this function gets a list of all of the locales that are installed. it
+// only queries the system once and caches the result for use in future
+// requests.
+//
+static _rw_locale_array
+_rw_all_locales ()
+{
+ static _rw_locale_array result;
+
+ // if we have already collection, reuse it
+ if (result.entries && result.count != 0) {
+ _rw_reset_locales (&result);
+ return result;
+ }
+
+ static _rw_locale_entry fallback = {
+ "C", "C", 0
+ };
+
+ result.entries = &fallback;
+ result.count = 1;
+
+ const char* const fname = rw_tmpnam (0);
+ if (!fname) {
+ return result;
+ }
+
+ const int status = rw_system ("locale -a > %s", fname);
+ if (status) {
+ return result;
+ }
+
+ FILE* file = fopen (fname, "r");
+ if (file) {
+
+ // looks to be the first time, get a list of all locales
+ const size_t entry_size = sizeof (_rw_locale_entry);
+ const size_t grow_size = 64;
+
+ _rw_locale_entry* entries = 0;
+ size_t capacity = 0;
+ size_t size = 0;
+
+ // load the native to canonical lookup table
+ _rw_lookup_table_t languages_map;
+ _rw_lookup_table_t countries_map;
+ _rw_lookup_table_t encodings_map;
+
+ // use TOPDIR to determine the root of the source tree
+ const char* const topdir = getenv (TOPDIR);
+ if (!topdir || !*topdir) {
+ rw_error (0, __FILE__, __LINE__,
+ "the environment variable %s is %s",
+ TOPDIR, topdir ? "empty" : "undefined");
+ }
+ else {
+ // we should be loading this from some other well
+ // known path so we don't depend on $TOPDIR. sadly
+ // __FILE__ is not an absolute path on msvc
+
+ char path [PATH_MAX];
+ strcpy (path, topdir);
+ strcat (path, SLASH RELPATH SLASH);
+
+ // load mapping from local to canonical names
+ languages_map.load_from_file (path, "languages", -1);
+ countries_map.load_from_file (path, "countries", 1);
+ encodings_map.load_from_file (path, "encodings", 1);
+ }
+
+ char locale [128];
+ while (fgets (locale, sizeof (locale), file)) {
+
+ // ensure sufficient space in array
+ if (! (size < capacity)) {
+ capacity += grow_size;
+
+ _rw_locale_entry* new_entries =
+ _RWSTD_STATIC_CAST(_rw_locale_entry*,
+ _QUIET_MALLOC (entry_size * capacity));
+ if (!new_entries) {
+ break;
+ }
+
+ memcpy (new_entries, entries, entry_size * size);
+
+ // deallocate the old buffer
+ _QUIET_FREE (entries);
+
+ entries = new_entries;
+ }
+
+ // grab entry to update
+ _rw_locale_entry* const entry = &entries [size];
+ entry->next = 0;
+
+ const size_t len = strlen (locale);
+ locale [len ? len - 1 : 0] = '\0';
+
+ // make sure that the named locale is one that we can use
+ if (!setlocale (LC_CTYPE, locale)) {
+
+ rw_note (0, __FILE__, __LINE__,
+ "setlocale() failed for '%s'", locale);
+
+ continue;
+
+ }
+
+ // is not an alias for the C or POSIX locale
+ else if (!strcmp (locale, "C") || !strcmp (locale, "POSIX")) {
+ continue; // we don't do C/POSIX locale
+ }
+
+ // has a name that is short enough for our buffer
+ else if (sizeof (entry->locale_name) < len) {
+
+ rw_note (0, __FILE__, __LINE__,
+ "locale name '%s' was to long for fixed buffer",
+ locale);
+
+ continue; // locale name didn't fit, so we skip it
+ }
+
+#ifndef _RWSTD_NO_LANGINFO
+ char codeset [40];
+
+ int i = 0;
+ for (const char* charset = nl_langinfo (CODESET);
+ *charset;
+ ++charset) {
+ codeset [i++] = _rw_toupper (*charset);
+ }
+
+ codeset [i] = '\0';
+#endif
+
+ // copy the locale name
+ strcpy (entry->locale_name, locale);
+
+ // attempt to split line into parts
+ char* extension = strrchr (locale, '@');
+ if (extension) {
+ *extension++ = '\0';
+ }
+
+ char* encoding = strrchr (locale, '.');
+ if (encoding) {
+ *encoding++ = '\0';
+
+ for (int n = 0; encoding [n]; ++n)
+ encoding [n] = _rw_toupper (encoding [n]);
+ }
+
+ char* country = strrchr (locale, '_');
+ if (country) {
+ *country++ = '\0';
+
+ for (int n = 0; country [n]; ++n)
+ country [n] = _rw_toupper (country [n]);
+ }
+
+ char* language = locale;
+
+ for (int n = 0; language [n]; ++n)
+ language [n] = _rw_tolower (language [n]);
+
+ // use mapping databases to find the canonical
+ // names for each part of the locale name
+
+ const char* planguage =
+ languages_map.get_canonical_name (language);
+ if (!planguage)
+ planguage = language;
+
+ // if country name was provided, then lookup in the country
+ // mapping. otherwise use language to guess country.
+ const char* pcountry =
+ countries_map.get_canonical_name (country);
+ if (!pcountry)
+ pcountry = country;
+
+#ifndef _RWSTD_NO_LANGINFO
+ const char* pencoding =
+ encodings_map.get_canonical_name (codeset);
+ if (!pencoding)
+ pencoding = codeset;
+#else
+ const char* pencoding =
+ encodings_map.get_canonical_name (encoding);
+ if (!pencoding)
+ pencoding = encoding;
+#endif
+
+ // require all three mappings are valid
+ if (!planguage || !*planguage) {
+
+ //rw_note (0, __FILE__, __LINE__,
+ // "failed to get language for locale '%s'",
+ // entry->locale_name);
+
+ continue;
+ }
+ else if (!pcountry || !*pcountry) {
+
+ //rw_note (0, __FILE__, __LINE__,
+ // "failed to get country for locale '%s'",
+ // entry->locale_name);
+
+ continue;
+ }
+ else if (!pencoding || !*pencoding) {
+
+ //rw_note (0, __FILE__, __LINE__,
+ // "failed to get codeset for locale '%s'",
+ // entry->locale_name);
+
+ continue;
+ }
+
+ // the canonical name for lookup
+ sprintf (entry->canonical_name, "%s-%s-%d-%s",
+ planguage, pcountry, int (MB_CUR_MAX), pencoding);
+
+ //
+ // eliminate locales that are duplicates according to
+ // canonical name. we do this because the setlocale()
+ // doesn't seem to tell us about aliases.
+ //
+
+ bool duplicate = false;
+
+ // search backward as matches are more likely to be near
+ // the back
+ for (size_t e = size; 0 != e; --e) {
+
+ if (!strcmp (entries [e-1].canonical_name,
+ entry->canonical_name)) {
+
+ //rw_note (0, __FILE__, __LINE__,
+ // "ignoring duplicate locale '%s'",
+ // entry->locale_name);
+
+ duplicate = true;
+
+ break;
+ }
+ }
+
+ if (!duplicate)
+ size += 1;
+ }
+
+ fclose (file);
+
+ // delete temp file
+ remove (fname);
+
+ // link all of the nodes into result
+ if (size) {
+ result.entries = entries;
+ result.count = size;
+ }
+ else
+ _QUIET_FREE (entries);
+ }
+
+ // link each node to the next. if the array is sorted,
+ // the list will be sorted.
+ _rw_reset_locales (&result);
+
+ return result;
+}
+
+_TEST_EXPORT char*
+rw_locale_query (int loc_cat, const char* query, size_t wanted)
+{
+ // query format <language>-<COUNTRY>-<MB_CUR_LEN>-<CODESET>
+
+ // the null query string will return any locale
+ if (!query)
+ query = "*";
+
+ if (!wanted)
+ wanted = _RWSTD_SIZE_MAX;
+
+ char buf [256];
+
+ // get a brace expanded representation of query, each expansion
+ // is a null terminated string. the entire buffer is also null
+ // terminated
+ char* res = rw_shell_expand (query, 0, buf, sizeof (buf), '\0');
+ if (!res)
+ return 0;
+
+ // cache the locale name so we can restore later, this must happen
+ // before _rw_all_locales() because that function just changes the
+ // locale without restoring it
+ char save_locale [PATH_MAX];
+ strcpy (save_locale, setlocale (LC_ALL, 0));
+
+ const _rw_locale_array all = _rw_all_locales ();
+
+ // make these local and require the user to deallocate
+ // with free?
+ static char* string = 0;
+ static size_t length = 0;
+ static size_t capacity = 0;
+
+ _rw_locale_entry rejects;
+ rejects.canonical_name [0] = '\0';
+ rejects.locale_name [0] = '\0';
+ rejects.next = all.entries;
+
+ // for each result locale name
+ size_t count = 0;
+ for (const char* name = res; *name; name += strlen (name) + 1)
+ {
+ _rw_locale_entry* dummy = &rejects;
+
+ // linear search for matches in the reject list
+ while (dummy->next)
+ {
+ // append name to the output buffer
+ const _rw_locale_entry* entry = dummy->next;
+
+ // see if we found a match
+ if (rw_fnmatch (name, entry->canonical_name, 0)) {
+
+ // not a match, advance past it leaving it in the
+ // rejects list
+ dummy = dummy->next;
+
+ // and move along to next one
+ continue;
+
+ }
+
+ // remove the accepted entry from the reject list
+ // so we will not include it again
+ dummy->next = entry->next;
+
+ // if the user requested locales from a specific category
+ if (loc_cat != _UNUSED_CAT) {
+
+ // make sure that the matching locale has the specified
+ // locale category and that we can use it.
+ if (!setlocale (loc_cat, entry->locale_name)) {
+
+ // if we can't use it, then bail. this effectively
+ // removes the locale from the rejects list and
+ // doesn't add it to the accepted list.
+ continue;
+ }
+ }
+
+ const size_t add_length = strlen (entry->locale_name) + 1;
+ const size_t new_length = length + add_length;
+
+ // grow buffer if necessary
+ if (! (new_length < capacity)) {
+
+ while (capacity < new_length)
+ capacity += 256;
+
+ // one additional character for the second null
+ char* new_string =
+ _RWSTD_STATIC_CAST(char*, _QUIET_MALLOC (capacity + 1));
+ if (!new_string) {
+
+ // setup to get out of outer loop
+ count = wanted;
+
+ // get out of inner loop
+ break;
+ }
+
+ memcpy (new_string, string, length);
+
+ _QUIET_FREE (string);
+
+ string = new_string;
+ }
+
+ // append the name, and update the length
+ memcpy (string + length, entry->locale_name, add_length);
+
+ length = new_length;
+
+ count += 1;
+ if (! (count < wanted))
+ break;
+ }
+
+ if (! (count < wanted))
+ break;
+ }
+
+ // restore the previous locale
+ setlocale (LC_ALL, save_locale);
+
+ // deallocate the shell expand buffer if needed
+ if (res != buf)
+ free (res);
+
+ // double null terminated
+ if (string) {
+ string [length+0] = '\0';
+ string [length+1] = '\0';
+ }
+
+ return string;
+}
+
+
+const char*
+_rw_lookup_table_t::get_canonical_name (const char* name) const
+{
+ if (!name)
+ return 0; // don't search for null string
+
+ const _rw_lookup_entry_t entry = { name, 0 };
+
+ const _rw_lookup_entry_t* found =
+ (const _rw_lookup_entry_t*)bsearch (&entry,
+ entries_,
+ count_,
+ sizeof (_rw_lookup_entry_t),
+ _rw_lookup_comparator);
+ if (found)
+ return found->canonical;
+
+ return 0;
+}
+
+bool
+_rw_lookup_table_t::load_from_file (const char* path, const char* name, int upper_or_lower)
+{
+ if (entries_)
+ return false; // should never happen
+
+ // buffer overflow!
+ char filename [PATH_MAX];
+ strcpy (filename, path);
+ strcat (filename, name);
+
+ FILE* file = fopen (filename, "rb");
+ if (file) {
+
+ // get the size of the file in bytes
+ fseek (file, 0, SEEK_END);
+ const size_t table_data_size = ftell (file);
+ fseek (file, 0, SEEK_SET);
+
+ char* table_data =
+ (char*)malloc (table_data_size + 1);
+
+ if (!table_data) {
+ fclose (file);
+ return false;
+ }
+
+ // read the entire file into the data buffer
+ const size_t bytes_read =
+ fread (table_data, 1, table_data_size, file);
+ if (bytes_read != table_data_size) {
+ free (table_data);
+ fclose (file);
+ return false;
+ }
+
+ // null terminate
+ table_data [bytes_read] = '\0';
+
+ const size_t entry_size = sizeof (_rw_lookup_entry_t);
+
+ _rw_lookup_entry_t* entries = 0;
+ size_t capacity = 0;
+ size_t size = 0;
+
+ const char* canonical_name = 0;
+
+ for (size_t offset = 0; offset < bytes_read; /**/) {
+
+ char* key = table_data + offset;
+
+ const size_t len = strcspn (key, "\r\n");
+ key [len] = '\0';
+
+ // skip the newline if it is there
+ offset += (len + 1);
+
+ // special handling for line ends and comments
+ if (!*key || *key == '\n'
+ || *key == '#')
+ continue;
+
+ // make upper or lower case as requested
+ if (upper_or_lower < 0) {
+ for (char* s = key; *s; ++s)
+ *s = _rw_tolower (*s);
+ }
+ else if (0 < upper_or_lower) {
+ for (char* s = key; *s; ++s)
+ *s = _rw_toupper (*s);
+ }
+
+ // if first character of new line is not whitespace, then we have a new
+ // canonical name token
+ if (!_rw_isspace (*key)) {
+
+ canonical_name = key;
+
+ // increment key past cannonical name
+ for (/**/; *key; ++key)
+ if (_rw_isspace (*key))
+ break;
+ }
+
+ // kill whitespace
+ while (_rw_isspace (*key))
+ *key++ = '\0';
+
+ // key points to first non-whitespace after canonical name
+
+ while (*key) {
+
+ // key is first non-whitespace character, which is the
+ // next native name we should record
+ const char* native_name = key;
+
+ // find first comma character, that is the end of the
+ // native name
+ while (*key && *key != ',')
+ ++key;
+
+ // if we found a comma, setup next name
+ if (*key)
+ *key++ = '\0';
+
+ // kill any whitespace before comma
+ for (char* bey = key - 1; _rw_isspace (*bey); --bey)
+ *bey = '\0';
+
+ // kill whitespace after comma
+ while (_rw_isspace (*key))
+ *key++ = '\0';
+
+ // ensure we have enough entries
+ if (! (size < capacity)) {
+
+ capacity += 64;
+
+ _rw_lookup_entry_t* new_entries =
+ (_rw_lookup_entry_t*)malloc (entry_size * capacity);
+ if (!new_entries) {
+
+ free (entries);
+
+ free (table_data);
+
+ fclose (file);
+
+ return false;
+ }
+
+ memcpy (new_entries, entries, entry_size * size);
+
+ free (entries);
+
+ entries = new_entries;
+ }
+
+ // add the new mapping entry
+ _rw_lookup_entry_t* const entry = &entries [size];
+ entry->native = native_name;
+ entry->canonical = canonical_name;
+
+ // increment number of entries
+ size += 1;
+ }
+ }
+
+ fclose (file);
+
+ // sort the entries by native name for efficient searching
+ qsort (entries, size, entry_size, _rw_lookup_comparator);
+
+ // setup the table for return
+ entries_ = entries;
+ count_ = size;
+ table_data_ = table_data;
+ }
+ else {
+ rw_error (0, __FILE__, __LINE__,
+ "failed to open the file %s", filename);
+ }
+
+ return true;
+}
+
+
Modified: stdcxx/branches/4.2.x/tests/src/new.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/new.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/new.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/new.cpp Wed Apr 16 10:01:56 2008
@@ -604,6 +604,17 @@
return ret;
}
+static void
+rwt_checkpoint_compare (size_t* diffs, size_t n,
+ const size_t* st0, const size_t* st1,
+ bool& diff_0)
+{
+ for (size_t i = 0; i != n; ++i) {
+ diffs [i] = st1 [i] - st0 [i];
+ if (diffs [i])
+ diff_0 = false;
+ }
+}
_TEST_EXPORT rwt_free_store*
rwt_checkpoint (const rwt_free_store *st0, const rwt_free_store *st1)
@@ -616,20 +627,23 @@
// of the free_store specified by the arguments
static rwt_free_store diff;
-
memset (&diff, 0, sizeof diff);
- size_t* diffs = diff.new_calls_;
- const size_t* st0_args = st0->new_calls_;
- const size_t* st1_args = st1->new_calls_;
-
bool diff_0 = true; // difference of 0 (i.e., none)
- for (size_t i = 0; i != 16; ++i) {
- diffs [i] = st1_args [i] - st0_args [i];
- if (diffs [i])
- diff_0 = false;
- }
+#define EXTENT(array) (sizeof (array) / sizeof(*array))
+#define COMPARE(member) \
+ rwt_checkpoint_compare (diff.member, EXTENT(diff.member), \
+ st0->member, st1->member, diff_0)
+
+ COMPARE (new_calls_);
+ COMPARE (delete_calls_);
+ COMPARE (delete_0_calls_);
+ COMPARE (blocks_);
+ COMPARE (bytes_);
+ COMPARE (max_blocks_);
+ COMPARE (max_bytes_);
+ COMPARE (max_block_size_);
if (diff_0)
return 0;
Modified: stdcxx/branches/4.2.x/tests/src/opt_lines.cpp
URL: http://svn.apache.org/viewvc/stdcxx/branches/4.2.x/tests/src/opt_lines.cpp?rev=648752&r1=648751&r2=648752&view=diff
==============================================================================
--- stdcxx/branches/4.2.x/tests/src/opt_lines.cpp (original)
+++ stdcxx/branches/4.2.x/tests/src/opt_lines.cpp Wed Apr 16 10:01:56 2008
@@ -93,6 +93,8 @@
static int
_rw_enable_line (int argc, char *argv[], int flags)
{
+ _RWSTD_UNUSED (argc);
+
char *parg = strchr (argv [0], '=');
assert (0 != parg);