stdcxx-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From se...@apache.org
Subject svn commit: r370557 - /incubator/stdcxx/trunk/src/string.cpp
Date Thu, 19 Jan 2006 17:55:37 GMT
Author: sebor
Date: Thu Jan 19 09:55:33 2006
New Revision: 370557

URL: http://svn.apache.org/viewcvs?rev=370557&view=rev
Log:
2006-01-19  Martin Sebor  <sebor@roguewave.com>

	* string.cpp [_RWSTD_NO_MEMCPY] (__rw_memcpy): Explicitly cast void*
	to char* before doing any arithmetic on the value.
	(__rw_memchr): Same.
	(__rw_memset): Same.
	(__rw_memcmp): Same.
	(__rw_memmove): Same. Added a missing return statement.
	[_RWSTD_NO_WMEMMOVE] (__rw_wmemmove): Added a missing return statement.

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

Modified: incubator/stdcxx/trunk/src/string.cpp
URL: http://svn.apache.org/viewcvs/incubator/stdcxx/trunk/src/string.cpp?rev=370557&r1=370556&r2=370557&view=diff
==============================================================================
--- incubator/stdcxx/trunk/src/string.cpp (original)
+++ incubator/stdcxx/trunk/src/string.cpp Thu Jan 19 09:55:33 2006
@@ -155,8 +155,10 @@
 
 #else   // if defined (_RWSTD_NO_MEMCPY)
 
-    for (char *tmp = dst; nbytes; ++tmp, --nbytes)
-        *tmp++ = *src++;
+    const char* csrc = _RWSTD_STATIC_CAST (const char*, src);
+
+    for (char *tmp = _RWSTD_STATIC_CAST (char*, dst); nbytes; ++tmp, --nbytes)
+        *tmp++ = *csrc++;
 
     return dst;
 
@@ -176,17 +178,20 @@
 
 #else   // if _RWSTD_NO_MEMMOVE
 
-    if (dst < src) {
+    char* cdst = _RWSTD_STATIC_CAST (char*, dst);
+    const char* csrc = _RWSTD_STATIC_CAST (const char*, src);
+
+    if (cdst < csrc) {
         while (nbytes--)
-            *dst++ = *src++;
+            *cdst++ = *csrc++;
     }
     else {
-        dst += nchars;
-        src += nchars;
-        while (nchars--)
-            *--dst = *--src;
+        for (cdst += nbytes, csrc += nbytes; nbytes--; )
+            *--cdst = *--csrc;
     }
 
+    return dst;
+
 #endif   // _RWSTD_NO_MEMMOVE
 
 }
@@ -205,10 +210,12 @@
 
     typedef unsigned char UChar;
 
-    while (nbytes-- > 0 && int (UChar (*src)) != c)
-        ++src;
+    const UChar* csrc = _RWSTD_STATIC_CAST (const UChar*, src);
+
+    while (nbytes-- > 0 && int (*csrc) != c)
+        ++csrc;
 
-    return *src == c ? src : 0;
+    return *csrc == c ? csrc : 0;
 
 #endif   // _RWSTD_NO_MEMCHR
 
@@ -226,7 +233,7 @@
 
 #else   // if defined (_RWSTD_NO_MEMSET)
 
-    for (char *tmp = dst; nbytes; ++tmp, --nbytes)
+    for (char *tmp = _RWSTD_STATIC_CAST (char*, dst); nbytes; ++tmp, --nbytes)
         *tmp = c;
 
     return dst;
@@ -247,9 +254,12 @@
 
 #else   // if defined (_RWSTD_NO_MEMCMP)
 
+    const char* const cs1 = _RWSTD_STATIC_CAST (const char*, s1);
+    const char* const cs2 = _RWSTD_STATIC_CAST (const char*, s2);
+
     for (_RWSTD_SIZE_T i = 0; i != nbytes; ++i) {
-        if (s1 [i] != s2 [i])
-            return s1 [i] < s2 [i] ? -1 : 1;
+        if (cs1 [i] != cs2 [i])
+            return cs1 [i] < cs2 [i] ? -1 : 1;
     }
 
     return 0;
@@ -319,11 +329,11 @@
             *dst++ = *src++;
     }
     else {
-        dst += nwchars;
-        src += nwchars;
-        while (nwchars--)
+        for (dst += nwchars, src += nwchars; nwchars--; )
             *--dst = *--src;
     }
+
+    return dst;
 
 #endif   // _RWSTD_NO_WMEMMOVE
 



Mime
View raw message