]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/string.cpp
removed unused GetScrollbarArrowSize() version
[wxWidgets.git] / src / common / string.cpp
index 5770917d5f233a444eca744daffff459b629ac23..418fc9f0779f585285fb2d8586606351d6b138cf 100644 (file)
@@ -35,6 +35,7 @@
 #endif
 
 #include <ctype.h>
 #endif
 
 #include <ctype.h>
+#include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 
 #include <string.h>
 #include <stdlib.h>
 
@@ -174,8 +175,16 @@ 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)
 {
 // poor man's iterators are "void *" pointers
 wxStringBase::wxStringBase(const void *pStart, const void *pEnd)
 {
-  InitWith((const wxChar *)pStart, 0,
-           (const wxChar *)pEnd - (const wxChar *)pStart);
+  if ( pEnd >= pStart )
+  {
+    InitWith((const wxChar *)pStart, 0,
+             (const wxChar *)pEnd - (const wxChar *)pStart);
+  }
+  else
+  {
+    wxFAIL_MSG( _T("pStart is not before pEnd") );
+    Init();
+  }
 }
 
 wxStringBase::wxStringBase(size_type n, wxChar ch)
 }
 
 wxStringBase::wxStringBase(size_type n, wxChar ch)
@@ -1676,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
     *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
 }
 
 bool wxString::ToULong(unsigned long *val, int base) const
@@ -1690,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
     *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
 }
 
 bool wxString::ToDouble(double *val) const
@@ -1703,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
     *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);
 }
 
 // ---------------------------------------------------------------------------
 }
 
 // ---------------------------------------------------------------------------