]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
removed unused GetScrollbarArrowSize() version
[wxWidgets.git] / src / common / string.cpp
index 1cb717510f704a8cd0b2c034a04976c9b3423b56..418fc9f0779f585285fb2d8586606351d6b138cf 100644 (file)
@@ -35,6 +35,7 @@
 #endif
 
 #include <ctype.h>
+#include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 
@@ -174,7 +175,7 @@ void wxStringBase::InitWith(const wxChar *psz, size_t nPos, size_t nLength)
 // poor man's iterators are "void *" pointers
 wxStringBase::wxStringBase(const void *pStart, const void *pEnd)
 {
-  if ( pEnd > pStart )
+  if ( pEnd >= pStart )
   {
     InitWith((const wxChar *)pStart, 0,
              (const wxChar *)pEnd - (const wxChar *)pStart);
@@ -1684,8 +1685,8 @@ bool wxString::ToLong(long *val, int base) const
     *val = wxStrtol(start, &end, base);
 
     // return true only if scan was stopped by the terminating NUL and if the
-    // string was not empty to start with
-    return !*end && (end != start);
+    // string was not empty to start with and no under/overflow occurred
+    return !*end && (end != start) && (errno != ERANGE);
 }
 
 bool wxString::ToULong(unsigned long *val, int base) const
@@ -1698,8 +1699,8 @@ bool wxString::ToULong(unsigned long *val, int base) const
     *val = wxStrtoul(start, &end, base);
 
     // return true only if scan was stopped by the terminating NUL and if the
-    // string was not empty to start with
-    return !*end && (end != start);
+    // string was not empty to start with and no overflow occurred
+    return !*end && (end != start) && (errno != ERANGE);
 }
 
 bool wxString::ToDouble(double *val) const
@@ -1711,8 +1712,8 @@ bool wxString::ToDouble(double *val) const
     *val = wxStrtod(start, &end);
 
     // return true only if scan was stopped by the terminating NUL and if the
-    // string was not empty to start with
-    return !*end && (end != start);
+    // string was not empty to start with and no under/overflow occurred
+    return !*end && (end != start) && (errno != ERANGE);
 }
 
 // ---------------------------------------------------------------------------