You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stdcxx.apache.org by se...@apache.org on 2006/06/27 22:36:58 UTC
svn commit: r417581 - /incubator/stdcxx/trunk/tests/src/21.strings.cpp
Author: sebor
Date: Tue Jun 27 13:36:57 2006
New Revision: 417581
URL: http://svn.apache.org/viewvc?rev=417581&view=rev
Log:
2006-06-27 Martin Sebor <se...@roguewave.com>
* 21.strings.cpp (_rw_reverse_results): Conditionally declared
static to avoid Sun C++ bug/limitation (see STDCXX-207), and
constified locals.
(_rw_dispatch): Qualified the call to _rw_reverse_results with
:: and constified locals.
Used size_t instead of the _RWSTD_SIZE_T macro intended to be
used only in headers.
Modified:
incubator/stdcxx/trunk/tests/src/21.strings.cpp
Modified: incubator/stdcxx/trunk/tests/src/21.strings.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/21.strings.cpp?rev=417581&r1=417580&r2=417581&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/21.strings.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/21.strings.cpp Tue Jun 27 13:36:57 2006
@@ -1007,33 +1007,32 @@
/**************************************************************************/
// helper function to reverse substring in the resulting sequence
-static
-StringTestCase _rw_reverse_results (const StringTestCase &tsrc,
- _RWSTD_SIZE_T off, _RWSTD_SIZE_T ext)
+_RWSTD_INTERNAL StringTestCase
+_rw_reverse_results (const StringTestCase &tsrc,
+ size_t off, size_t ext)
{
// expand expected results
- char *new_res = 0;
- _RWSTD_SIZE_T res_len = 0;
- new_res = rw_expand (new_res, tsrc.res, tsrc.nres, &res_len);
+ size_t res_len = 0;
+ char* const new_res = rw_expand ((char*)0, tsrc.res, tsrc.nres, &res_len);
// reverse them
- _RWSTD_SIZE_T res_off = off;
- _RWSTD_SIZE_T res_ext = (ext < res_len ? ext : res_len) - 1;
+ const size_t res_off = off;
+ const size_t res_ext = (ext < res_len ? ext : res_len) - 1;
char* beg = new_res + res_off;
char* end = beg + res_ext;
for (; beg < end; ++beg, --end) {
- char tmp = *beg;
+ const char tmp = *beg;
*beg = *end;
*end = tmp;
}
// form new test case
- StringTestCase new_case = {
+ const StringTestCase new_case = {
tsrc.line, tsrc.off, tsrc.size, tsrc.off2,
- tsrc.size2, tsrc.val, tsrc.str, tsrc.str_len,
- tsrc.arg, tsrc.arg_len, new_res, res_len, tsrc.bthrow
+ tsrc.size2, tsrc.val, tsrc.str, tsrc.str_len,
+ tsrc.arg, tsrc.arg_len, new_res, res_len, tsrc.bthrow
};
return new_case;
@@ -1054,31 +1053,33 @@
TestFunc* const tfunc = _RWSTD_REINTERPRET_CAST (TestFunc*, farray [inx]);
- bool reverse_iter = StringIds::ReverseIterator == func.iter_id_
+ const bool reverse_iter =
+ StringIds::ReverseIterator == func.iter_id_
|| StringIds::ConstReverseIterator == func.iter_id_;
const Data tdata (func, tcase);
- // special processing for the reverse iterators
if (reverse_iter) {
+ // special processing for reverse iterators
- _RWSTD_SIZE_T func_id = tdata.func_.which_ & StringIds::fid_mask;
- bool like_ctor = StringIds::fid_ctor == func_id
- || StringIds::fid_assign == func_id;
-
- // ctor and assign require the full string reverse
- _RWSTD_SIZE_T off = like_ctor ? 0 : tdata.off1_;
- _RWSTD_SIZE_T ext = like_ctor ? tdata.reslen_ : tdata.ext2_;
+ const size_t func_id = tdata.func_.which_ & StringIds::fid_mask;
- StringTestCase rev_tcase = _rw_reverse_results (tcase, off, ext);
+ const bool like_ctor = StringIds::fid_ctor == func_id
+ || StringIds::fid_assign == func_id;
+
+ // ctor and assignment operator require the full string reverse
+ const size_t off = like_ctor ? 0 : tdata.off1_;
+ const size_t ext = like_ctor ? tdata.reslen_ : tdata.ext2_;
+
+ const StringTestCase rev_tcase =
+ ::_rw_reverse_results (tcase, off, ext);
const Data rev_tdata (func, rev_tcase);
tfunc ((charT*)0, (Traits*)0, (Allocator*)0, rev_tdata);
// clean up allocated memory, if any
- if (0 != rev_tcase.res)
- delete[] rev_tcase.res;
+ delete[] rev_tcase.res;
}
else
tfunc ((charT*)0, (Traits*)0, (Allocator*)0, tdata);