Remove deprecated nsTString::ToCString (bug 323471). r+sr=darin.
git-svn-id: svn://10.0.0.236/trunk@188104 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -1105,24 +1105,9 @@ nsString::EqualsIgnoreCase( const char* aString, PRInt32 aCount ) const
|
||||
}
|
||||
|
||||
/**
|
||||
* ToCString, ToFloat, ToInteger
|
||||
* nsTString::ToFloat
|
||||
*/
|
||||
|
||||
char*
|
||||
nsString::ToCString( char* aBuf, PRUint32 aBufLength, PRUint32 aOffset ) const
|
||||
{
|
||||
// because the old implementation checked aBuf
|
||||
if (!(aBuf && aBufLength > 0 && aOffset <= mLength))
|
||||
return nsnull;
|
||||
|
||||
PRUint32 maxCount = NS_MIN(aBufLength-1, mLength - aOffset);
|
||||
|
||||
LossyConvertEncoding<PRUnichar, char> converter(aBuf);
|
||||
converter.write(mData + aOffset, maxCount);
|
||||
converter.write_terminator();
|
||||
return aBuf;
|
||||
}
|
||||
|
||||
float
|
||||
nsCString::ToFloat(PRInt32* aErrorCode) const
|
||||
{
|
||||
@@ -1149,25 +1134,7 @@ nsCString::ToFloat(PRInt32* aErrorCode) const
|
||||
float
|
||||
nsString::ToFloat(PRInt32* aErrorCode) const
|
||||
{
|
||||
float res = 0.0f;
|
||||
char buf[100];
|
||||
if (mLength > 0 && mLength < sizeof(buf))
|
||||
{
|
||||
char *conv_stopped;
|
||||
const char *str = ToCString(buf, sizeof(buf));
|
||||
// Use PR_strtod, not strtod, since we don't want locale involved.
|
||||
res = (float)PR_strtod(str, &conv_stopped);
|
||||
if (conv_stopped == str+mLength)
|
||||
*aErrorCode = (PRInt32) NS_OK;
|
||||
else // Not all the string was scanned
|
||||
*aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
// The string was too short (0 characters) or too long (sizeof(buf))
|
||||
*aErrorCode = (PRInt32) NS_ERROR_ILLEGAL_VALUE;
|
||||
}
|
||||
return res;
|
||||
return NS_LossyConvertUTF16toASCII(*this).ToFloat(aErrorCode);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user