incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Pevtsov" <Ant...@moscow.vdiweb.com>
Subject RE: svn commit: r416537 - /incubator/stdcxx/trunk/tests/src/char.cpp
Date Fri, 23 Jun 2006 15:29:54 GMT
Martin, I have a question about the change in char.cpp. It results in
the following:

1) The strings beginning with '\0' and requiring expand will not be
expanded.
2) The strings with '\0' at the end will be expanded incorrectly
(without last symbol).

Is this expected?


Thanks,
Anton Pevtsov


-----Original Message-----
From: sebor@apache.org [mailto:sebor@apache.org] 
Sent: Friday, June 23, 2006 05:15
To: stdcxx-commits@incubator.apache.org
Subject: svn commit: r416537 -
/incubator/stdcxx/trunk/tests/src/char.cpp


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?r
ev=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