stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From far...@apache.org
Subject svn commit: r492599 - /incubator/stdcxx/trunk/src/string.cpp
Date Thu, 04 Jan 2007 15:22:41 GMT
Author: faridz
Date: Thu Jan  4 07:22:41 2007
New Revision: 492599

URL: http://svn.apache.org/viewvc?view=rev&rev=492599
Log:
2007-01-04 Farid Zaripov <faridz@kyiv.vdiweb.com>

	* string.cpp (__rw_memchr, __rw_wmemchr): Fixed bug: the function
	returns incorrect result when nbytes == 0 and *src == c

Modified:
    incubator/stdcxx/trunk/src/string.cpp

Modified: incubator/stdcxx/trunk/src/string.cpp
URL: http://svn.apache.org/viewvc/incubator/stdcxx/trunk/src/string.cpp?view=diff&rev=492599&r1=492598&r2=492599
==============================================================================
--- incubator/stdcxx/trunk/src/string.cpp (original)
+++ incubator/stdcxx/trunk/src/string.cpp Thu Jan  4 07:22:41 2007
@@ -75,10 +75,12 @@
 
     const UChar* csrc = _RWSTD_STATIC_CAST (const UChar*, src);
 
-    while (nbytes-- > 0 && int (*csrc) != c)
+    while (nbytes > 0 && int (*csrc) != c) {
         ++csrc;
+        --nbytes;
+    }
 
-    return int (*csrc) == c ? csrc : 0;
+    return nbytes ? csrc : 0;
 }
 
 
@@ -160,10 +162,12 @@
 {
     _RWSTD_ASSERT (0 == nwchars || src);
 
-    while (nwchars-- > 0 && *src != wc)
+    while (nwchars > 0 && *src != wc) {
         ++src;
+        --nwchars;
+    }
 
-    return *src == wc ? src : 0;
+    return nwchars ? src : 0;
 }
 
 



Mime
View raw message