stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r416537 - /incubator/stdcxx/trunk/tests/src/char.cpp
Date Fri, 23 Jun 2006 01:14:52 GMT
Author: sebor
Date: Thu Jun 22 18:14:52 2006
New Revision: 416537

URL: http://svn.apache.org/viewvc?rev=416537&view=rev
Log:
2006-06-22  Martin Sebor  <sebor@roguewave.com>

	* char.cpp (_rw_expand): NUL-terminated expanded string.
	(rw_match): Avoided false positives when detecting whether
	to expand the first argument.

Modified:
    incubator/stdcxx/trunk/tests/src/char.cpp

Modified: incubator/stdcxx/trunk/tests/src/char.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/tests/src/char.cpp?rev=416537&r1=416536&r2=416537&view=diff
==============================================================================
--- incubator/stdcxx/trunk/tests/src/char.cpp (original)
+++ incubator/stdcxx/trunk/tests/src/char.cpp Thu Jun 22 18:14:52 2006
@@ -641,8 +641,10 @@
         pnext   = (char*)pnext + count * elemsize;
         buflen += count;
 
-        if (0 == src_len)
+        if (0 == src_len) {
+            memset (pnext, 0, elemsize);
             break;
+        }
     }
 
     if (dst_len)
@@ -690,10 +692,25 @@
     size_t s1_len = sizeof s1_buf;
 
     // see if the first string contains '@' and might need
-    // to be expanded  (see rw_expand() for details)
-    if (   _RWSTD_SIZE_MAX == len && strchr (s1, '@')
-        || _RWSTD_SIZE_MAX != len && memchr (s1, '@', len)) {
-        s1 = rw_expand (s1_buf, s1, len, &s1_len);
+    // to be expanded (see rw_expand() for details)
+    bool expand = false;
+
+    if (_RWSTD_SIZE_MAX == len) {
+        expand = 0 != strchr (s1, '@');
+    }
+    else {
+        for (const char *p = s1; *p; ++p) {
+            if (size_t (p - s1) == len)
+                break;
+            if ('@' == *p) {
+                expand = true;
+                break;
+            }
+        }
+    }
+
+    if (expand) {
+        s1  = rw_expand (s1_buf, s1, _RWSTD_SIZE_MAX, &s1_len);
         len = s1_len;
     }
 



Mime
View raw message