diff --git a/mozilla/base/src/nsString.cpp b/mozilla/base/src/nsString.cpp index 653044ea743..0b7b83e393b 100644 --- a/mozilla/base/src/nsString.cpp +++ b/mozilla/base/src/nsString.cpp @@ -623,7 +623,8 @@ float nsString::ToFloat(PRInt32* aErrorCode) const */ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const { PRInt32 result = 0; - PRUnichar* cp = mStr + mLength-1; + PRInt32 decPt=Find(PRUnichar('.'),0); + PRUnichar* cp = (-1==decPt) ? mStr + mLength-1 : mStr+decPt-1; char digit=0; PRUnichar theChar; PRInt32 theShift=0; @@ -631,6 +632,7 @@ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const { *aErrorCode = (0= mStr) { theChar = *cp; @@ -1635,9 +1637,9 @@ PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const { return 1; } if (aIgnoreCase) { - return nsCRT::strncasecmp(mStr,S.mStr,maxlen); + return nsCRT::strcasecmp(mStr,S.mStr); } - return nsCRT::strncmp(mStr,S.mStr,maxlen); + return nsCRT::strcmp(mStr,S.mStr); } /** @@ -2060,6 +2062,15 @@ NS_BASE int fputs(const nsString& aString, FILE* out) * @return */ void nsString::SelfTest(void) { + + nsAutoString a("foobar"); + nsAutoString b("foo"); + nsAutoString c(".5111"); + PRInt32 result=a.Compare(b); + PRInt32 result2=result; + result=c.ToInteger(&result2); + result2=result; + #if 0 static const char* kConstructorError = kConstructorError; diff --git a/mozilla/string/obsolete/nsString.cpp b/mozilla/string/obsolete/nsString.cpp index 653044ea743..0b7b83e393b 100644 --- a/mozilla/string/obsolete/nsString.cpp +++ b/mozilla/string/obsolete/nsString.cpp @@ -623,7 +623,8 @@ float nsString::ToFloat(PRInt32* aErrorCode) const */ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const { PRInt32 result = 0; - PRUnichar* cp = mStr + mLength-1; + PRInt32 decPt=Find(PRUnichar('.'),0); + PRUnichar* cp = (-1==decPt) ? mStr + mLength-1 : mStr+decPt-1; char digit=0; PRUnichar theChar; PRInt32 theShift=0; @@ -631,6 +632,7 @@ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const { *aErrorCode = (0= mStr) { theChar = *cp; @@ -1635,9 +1637,9 @@ PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const { return 1; } if (aIgnoreCase) { - return nsCRT::strncasecmp(mStr,S.mStr,maxlen); + return nsCRT::strcasecmp(mStr,S.mStr); } - return nsCRT::strncmp(mStr,S.mStr,maxlen); + return nsCRT::strcmp(mStr,S.mStr); } /** @@ -2060,6 +2062,15 @@ NS_BASE int fputs(const nsString& aString, FILE* out) * @return */ void nsString::SelfTest(void) { + + nsAutoString a("foobar"); + nsAutoString b("foo"); + nsAutoString c(".5111"); + PRInt32 result=a.Compare(b); + PRInt32 result2=result; + result=c.ToInteger(&result2); + result2=result; + #if 0 static const char* kConstructorError = kConstructorError; diff --git a/mozilla/xpcom/ds/nsString.cpp b/mozilla/xpcom/ds/nsString.cpp index 653044ea743..0b7b83e393b 100644 --- a/mozilla/xpcom/ds/nsString.cpp +++ b/mozilla/xpcom/ds/nsString.cpp @@ -623,7 +623,8 @@ float nsString::ToFloat(PRInt32* aErrorCode) const */ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const { PRInt32 result = 0; - PRUnichar* cp = mStr + mLength-1; + PRInt32 decPt=Find(PRUnichar('.'),0); + PRUnichar* cp = (-1==decPt) ? mStr + mLength-1 : mStr+decPt-1; char digit=0; PRUnichar theChar; PRInt32 theShift=0; @@ -631,6 +632,7 @@ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const { *aErrorCode = (0= mStr) { theChar = *cp; @@ -1635,9 +1637,9 @@ PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const { return 1; } if (aIgnoreCase) { - return nsCRT::strncasecmp(mStr,S.mStr,maxlen); + return nsCRT::strcasecmp(mStr,S.mStr); } - return nsCRT::strncmp(mStr,S.mStr,maxlen); + return nsCRT::strcmp(mStr,S.mStr); } /** @@ -2060,6 +2062,15 @@ NS_BASE int fputs(const nsString& aString, FILE* out) * @return */ void nsString::SelfTest(void) { + + nsAutoString a("foobar"); + nsAutoString b("foo"); + nsAutoString c(".5111"); + PRInt32 result=a.Compare(b); + PRInt32 result2=result; + result=c.ToInteger(&result2); + result2=result; + #if 0 static const char* kConstructorError = kConstructorError; diff --git a/mozilla/xpcom/string/obsolete/nsString.cpp b/mozilla/xpcom/string/obsolete/nsString.cpp index 653044ea743..0b7b83e393b 100644 --- a/mozilla/xpcom/string/obsolete/nsString.cpp +++ b/mozilla/xpcom/string/obsolete/nsString.cpp @@ -623,7 +623,8 @@ float nsString::ToFloat(PRInt32* aErrorCode) const */ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const { PRInt32 result = 0; - PRUnichar* cp = mStr + mLength-1; + PRInt32 decPt=Find(PRUnichar('.'),0); + PRUnichar* cp = (-1==decPt) ? mStr + mLength-1 : mStr+decPt-1; char digit=0; PRUnichar theChar; PRInt32 theShift=0; @@ -631,6 +632,7 @@ PRInt32 nsString::ToInteger(PRInt32* aErrorCode,PRInt32 aRadix) const { *aErrorCode = (0= mStr) { theChar = *cp; @@ -1635,9 +1637,9 @@ PRInt32 nsString::Compare(const nsString &S,PRBool aIgnoreCase) const { return 1; } if (aIgnoreCase) { - return nsCRT::strncasecmp(mStr,S.mStr,maxlen); + return nsCRT::strcasecmp(mStr,S.mStr); } - return nsCRT::strncmp(mStr,S.mStr,maxlen); + return nsCRT::strcmp(mStr,S.mStr); } /** @@ -2060,6 +2062,15 @@ NS_BASE int fputs(const nsString& aString, FILE* out) * @return */ void nsString::SelfTest(void) { + + nsAutoString a("foobar"); + nsAutoString b("foo"); + nsAutoString c(".5111"); + PRInt32 result=a.Compare(b); + PRInt32 result2=result; + result=c.ToInteger(&result2); + result2=result; + #if 0 static const char* kConstructorError = kConstructorError;