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/07/10 00:46:11 UTC
svn commit: r420363 - in /incubator/stdcxx/trunk/tests: self/0.char.cpp
src/char.cpp
Author: sebor
Date: Sun Jul 9 15:46:11 2006
New Revision: 420363
URL: http://svn.apache.org/viewvc?rev=420363&view=rev
Log:
2006-07-09 Martin Sebor <se...@roguewave.com>
* src/char.cpp (_rw_get_char): Handled terminating NUL when
the source string length is specified (i.e., not SIZE_MAX).
(_rw_expand, rw_match): Passed the length of the source
string to _rw_get_char.
* self/0.char.cpp (test_rw_match): Added assertions exercising
the above (see also the thread at http://tinyurl.com/zf9pm).
Modified:
incubator/stdcxx/trunk/tests/self/0.char.cpp
incubator/stdcxx/trunk/tests/src/char.cpp
Modified: incubator/stdcxx/trunk/tests/self/0.char.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/self/0.char.cpp?rev=420363&r1=420362&r2=420363&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/self/0.char.cpp (original)
+++ incubator/stdcxx/trunk/tests/self/0.char.cpp Sun Jul 9 15:46:11 2006
@@ -10,8 +10,6 @@
* Copyright 2006 The Apache Software Foundation or its licensors,
* as applicable.
*
- * Copyright 2006 Rogue Wave Software.
- *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -815,11 +813,15 @@
TEST ("a@1", "a", -1, 2);
TEST ("a@1", "a@1", -1, 2);
- TEST ("\0ab", "\0ac", 2, 2);
- TEST ("\0@0ab", "ab", 2, 2);
- TEST ("\0@0a\0@0b", "ab", 2, 2);
- TEST ("\0@1ab", "\0@1ac", 2, 2);
- TEST ("\0@1ab", "\0@1ac", 2, 2);
+ TEST ("\0ab", "\0ac", 2, 2);
+ TEST ("\0@0ab", "ab", 2, 2);
+ TEST ("\0@0a\0@0b", "ab", 2, 2);
+ TEST ("\0@1ab", "\0@1ac", 2, 2);
+ TEST ("\0@1ab", "\0@1ac", 2, 2);
+ TEST ("a\0@0b", "a\0@0c", -1, 2);
+ TEST ("a\0@0b", "a\0@1c", -1, 2);
+ TEST ("a\0@1b", "a\0@0c", -1, 2);
+ TEST ("a\0@1b", "a\0@1c", -1, 2);
TEST ("a\0bc", "a\0bd", -1, 2);
TEST ("a\0bc", "a\0bd", 0, 0);
@@ -965,6 +967,8 @@
TEST ("\0ab", L"\0ac", 2, 2);
TEST ("\0@0ab", L"ab", 2, 2);
TEST ("\0@0a\0@0b", L"ab", 2, 2);
+ TEST ("a\0@0b", L"a\0\0", -1, 2);
+ TEST ("a\0@1b", L"a\0\0", -1, 2);
TEST ("a\0bc", L"a\0bd", -1, 2);
TEST ("a\0bc", L"a\0bd", 0, 0);
@@ -1056,6 +1060,8 @@
TEST ("\0ab", "\0ac", 2, 2);
TEST ("\0@0ab", "ab", 2, 2);
TEST ("\0@0a\0@0b", "ab", 2, 2);
+ TEST ("a\0@0b", "a\0\0", -1, 2);
+ TEST ("a\0@1b", "a\0\0", -1, 2);
TEST ("a\0bc", "a\0bd", -1, 2);
TEST ("a\0bc", "a\0bd", 0, 0);
Modified: incubator/stdcxx/trunk/tests/src/char.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/char.cpp?rev=420363&r1=420362&r2=420363&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/char.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/char.cpp Sun Jul 9 15:46:11 2006
@@ -9,8 +9,6 @@
* Copyright 2006 The Apache Software Foundation or its licensors,
* as applicable.
*
- * Copyright 2006 Rogue Wave Software.
- *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -529,8 +527,24 @@
static unsigned long
_rw_get_char (const char *src, const char** end, size_t *count)
{
+ RW_ASSERT (0 != src);
+ RW_ASSERT (0 != end);
+ RW_ASSERT (0 != count);
+
+ if (0 == *count) {
+ *end = src;
+ return 0;
+ }
+
unsigned long ch = UChar (*src++);
+ if (0 == ch && _RWSTD_SIZE_MAX == *count) {
+ // stop at the terminating NUL
+ *end = src;
+ *count = 1;
+ return ch;
+ }
+
if ('<' == char (ch) && 'U' == src [0] && isxdigit (src [1])) {
// this looks like the beginning of a <Unnn...>
// sequence encoding a Unicode character, look
@@ -596,14 +610,11 @@
if (_RWSTD_SIZE_MAX == src_len)
src_len = strlen (src);
- // remember if src is the empty string
- const bool empty_string = 0 == src_len;
-
void *pnext = dst;
for (const char *psrc = src; ; ) {
- size_t count = 0;
+ size_t count = src_len;
const char *end = 0;
const unsigned long ch = _rw_get_char (psrc, &end, &count);
@@ -730,7 +741,7 @@
}
if (dst_len)
- *dst_len = buflen - empty_string;
+ *dst_len = buflen;
return dst;
}
@@ -778,7 +789,7 @@
return 0;
do {
- size_t n = 0;
+ size_t n = _RWSTD_SIZE_MAX == len ? len : len - count;
_rw_get_char (p1, &p1, &n);
@@ -795,11 +806,15 @@
for (unsigned long ch1, ch2; count < len; ) {
- while (0 == n1)
+ while (0 == n1) {
+ n1 = _RWSTD_SIZE_MAX == len ? len : len - count;
ch1 = _rw_get_char (p1, &p1, &n1);
+ }
- while (0 == n2)
+ while (0 == n2) {
+ n2 = _RWSTD_SIZE_MAX == len ? len : len - count;
ch2 = _rw_get_char (p2, &p2, &n2);
+ }
if (ch1 != ch2)
break;
@@ -941,8 +956,10 @@
for (unsigned long ch1, ch2; count < len; ) {
- while (0 == n1)
+ while (0 == n1) {
+ n1 = _RWSTD_SIZE_MAX == len ? len : len - count;
ch1 = _rw_get_char (p1, &p1, &n1);
+ }
ch2 = _RWSTD_STATIC_CAST (unsigned long, *p2++);
n2 = 1;
@@ -1090,8 +1107,10 @@
for (UserChar ch2; count < len; ) {
- while (0 == n1)
+ while (0 == n1) {
+ n1 = _RWSTD_SIZE_MAX == len ? len : len - count;
ch1 = _rw_get_char (p1, &p1, &n1);
+ }
ch2 = *p2++;
n2 = 1;