From 9972377ad21a0191bbde3b5580f5f3b6f6331dff Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Thu, 17 Jun 1999 19:15:57 +0000 Subject: [PATCH] fixed ToInteger (again) and eliminate bug 8140 git-svn-id: svn://10.0.0.236/trunk@35810 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/string/obsolete/nsString2.cpp | 9 +++++---- mozilla/xpcom/ds/nsString2.cpp | 9 +++++---- mozilla/xpcom/string/obsolete/nsString2.cpp | 9 +++++---- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/mozilla/string/obsolete/nsString2.cpp b/mozilla/string/obsolete/nsString2.cpp index 7e75d055208..917657481fb 100644 --- a/mozilla/string/obsolete/nsString2.cpp +++ b/mozilla/string/obsolete/nsString2.cpp @@ -796,14 +796,15 @@ PRInt32 nsString2::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const { //copy chars to local buffer -- step down from 2 bytes to 1 if necessary... nsAutoString2 theString(*this,eOneByte); PRUint32 theRadix=aRadix; - PRInt32 result=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead - - if(NS_OK==result){ + PRInt32 result=0; + + *anErrorCode=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead + if(NS_OK==*anErrorCode){ if(kAutoDetect==aRadix) aRadix=theRadix; if((kRadix10==aRadix) || (kRadix16==aRadix)) result=_ToInteger(theString,anErrorCode,aRadix); //note we use the given radix, not the computed one. - else result=NS_ERROR_ILLEGAL_VALUE; + else *anErrorCode=NS_ERROR_ILLEGAL_VALUE; } return result; diff --git a/mozilla/xpcom/ds/nsString2.cpp b/mozilla/xpcom/ds/nsString2.cpp index 7e75d055208..917657481fb 100644 --- a/mozilla/xpcom/ds/nsString2.cpp +++ b/mozilla/xpcom/ds/nsString2.cpp @@ -796,14 +796,15 @@ PRInt32 nsString2::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const { //copy chars to local buffer -- step down from 2 bytes to 1 if necessary... nsAutoString2 theString(*this,eOneByte); PRUint32 theRadix=aRadix; - PRInt32 result=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead - - if(NS_OK==result){ + PRInt32 result=0; + + *anErrorCode=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead + if(NS_OK==*anErrorCode){ if(kAutoDetect==aRadix) aRadix=theRadix; if((kRadix10==aRadix) || (kRadix16==aRadix)) result=_ToInteger(theString,anErrorCode,aRadix); //note we use the given radix, not the computed one. - else result=NS_ERROR_ILLEGAL_VALUE; + else *anErrorCode=NS_ERROR_ILLEGAL_VALUE; } return result; diff --git a/mozilla/xpcom/string/obsolete/nsString2.cpp b/mozilla/xpcom/string/obsolete/nsString2.cpp index 7e75d055208..917657481fb 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.cpp +++ b/mozilla/xpcom/string/obsolete/nsString2.cpp @@ -796,14 +796,15 @@ PRInt32 nsString2::ToInteger(PRInt32* anErrorCode,PRUint32 aRadix) const { //copy chars to local buffer -- step down from 2 bytes to 1 if necessary... nsAutoString2 theString(*this,eOneByte); PRUint32 theRadix=aRadix; - PRInt32 result=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead - - if(NS_OK==result){ + PRInt32 result=0; + + *anErrorCode=GetNumericSubstring(theString,theRadix); //we actually don't use this radix; use given radix instead + if(NS_OK==*anErrorCode){ if(kAutoDetect==aRadix) aRadix=theRadix; if((kRadix10==aRadix) || (kRadix16==aRadix)) result=_ToInteger(theString,anErrorCode,aRadix); //note we use the given radix, not the computed one. - else result=NS_ERROR_ILLEGAL_VALUE; + else *anErrorCode=NS_ERROR_ILLEGAL_VALUE; } return result;