making string conversions explicit

This commit is contained in:
scc%netscape.com 2000-04-01 23:29:51 +00:00
Родитель 553f4a01dc
Коммит e6ee6bb3f2
6 изменённых файлов: 30 добавлений и 27 удалений

Просмотреть файл

@ -51,8 +51,10 @@ nsBasicAuth::Authenticate(nsIURI* i_URI,
tempBuff = PL_Base64Encode(iUserPass, 0, tempBuff);
if (!tempBuff)
return NS_ERROR_FAILURE; // ??
nsString authString("Basic ");
authString += tempBuff;
// STRING USE WARNING: perhaps |authString| should be an |nsCAutoString|? -- scc
nsString authString; authString.AssignWithConversion("Basic ");
authString.AppendWithConversion(tempBuff);
*oResult = authString.ToNewCString();
PR_Free(tempBuff);
rv = NS_OK;

Просмотреть файл

@ -1640,9 +1640,9 @@ nsHTTPChannel::Authenticate(const char *iChallenge, PRBool iProxyAuth)
PRBool retval = PR_FALSE;
//TODO localize it!
nsAutoString message = "Enter username for ";
nsAutoString message; message.AssignWithConversion("Enter username for ");
// later on change to only show realm and then host's info.
message += iChallenge;
message.AppendWithConversion(iChallenge);
// Get url
nsXPIDLCString urlCString;

Просмотреть файл

@ -322,7 +322,7 @@ nsHTTPHandler::NewPostDataStream(PRBool isFile,
}
else {
nsCOMPtr<nsISupports> in;
rv = NS_NewStringInputStream(getter_AddRefs(in), data);
rv = NS_NewCStringInputStream(getter_AddRefs(in), data);
if (NS_FAILED(rv)) return rv;
rv = in->QueryInterface(NS_GET_IID(nsIInputStream), (void**)result);
@ -460,7 +460,7 @@ nsHTTPHandler::GetVendor(PRUnichar* *aVendor)
NS_IMETHODIMP
nsHTTPHandler::SetVendor(const PRUnichar* aVendor)
{
mVendor = aVendor;
mVendor.AssignWithConversion(aVendor);
return BuildUserAgent();
}
@ -475,7 +475,7 @@ nsHTTPHandler::GetVendorSub(PRUnichar* *aVendorSub)
NS_IMETHODIMP
nsHTTPHandler::SetVendorSub(const PRUnichar* aVendorSub)
{
mVendorSub = aVendorSub;
mVendorSub.AssignWithConversion(aVendorSub);
return BuildUserAgent();
}
@ -490,7 +490,7 @@ nsHTTPHandler::GetVendorComment(PRUnichar* *aComment)
NS_IMETHODIMP
nsHTTPHandler::SetVendorComment(const PRUnichar* aComment)
{
mVendorComment = aComment;
mVendorComment.AssignWithConversion(aComment);
return BuildUserAgent();
}
@ -505,7 +505,7 @@ nsHTTPHandler::GetProduct(PRUnichar* *aProduct)
NS_IMETHODIMP
nsHTTPHandler::SetProduct(const PRUnichar* aProduct)
{
mProduct = aProduct;
mProduct.AssignWithConversion(aProduct);
return BuildUserAgent();
}
@ -520,7 +520,7 @@ nsHTTPHandler::GetProductSub(PRUnichar* *aProductSub)
NS_IMETHODIMP
nsHTTPHandler::SetProductSub(const PRUnichar* aProductSub)
{
mProductSub = aProductSub;
mProductSub.AssignWithConversion(aProductSub);
return BuildUserAgent();
}
@ -535,7 +535,7 @@ nsHTTPHandler::GetProductComment(PRUnichar* *aComment)
NS_IMETHODIMP
nsHTTPHandler::SetProductComment(const PRUnichar* aComment)
{
mProductComment = aComment;
mProductComment.AssignWithConversion(aComment);
return BuildUserAgent();
}
@ -550,7 +550,7 @@ nsHTTPHandler::GetLanguage(PRUnichar* *aLanguage)
NS_IMETHODIMP
nsHTTPHandler::SetLanguage(const PRUnichar* aLanguage)
{
mAppLanguage = aLanguage;
mAppLanguage.AssignWithConversion(aLanguage);
return BuildUserAgent();
}
@ -590,7 +590,7 @@ nsHTTPHandler::GetMisc(PRUnichar* *aMisc)
NS_IMETHODIMP
nsHTTPHandler::SetMisc(const PRUnichar* aMisc)
{
mAppMisc = (const PRUnichar*)aMisc;
mAppMisc.AssignWithConversion(NS_STATIC_CAST(const PRUnichar*, aMisc));
return BuildUserAgent();
}
@ -660,7 +660,7 @@ nsHTTPHandler::InitUserAgentComponents()
rv = mPrefs->CopyCharPref(UA_PREF_PREFIX "security",
getter_Copies(UAPrefVal));
if (NS_SUCCEEDED(rv))
mAppSecurity = UAPrefVal;
mAppSecurity.Assign(NS_STATIC_CAST(const char*, UAPrefVal));
else
mAppSecurity = "N";

Просмотреть файл

@ -309,7 +309,7 @@ nsHTTPRequest::formHeaders (PRUint32 capabilities)
nsXPIDLString ua;
if (NS_SUCCEEDED (httpHandler -> GetUserAgent (getter_Copies(ua))))
{
nsCAutoString uaString ((const PRUnichar*)ua);
nsCAutoString uaString; uaString.AssignWithConversion(NS_STATIC_CAST(const PRUnichar*, ua));
SetHeader (nsHTTPAtoms::User_Agent, uaString.GetBuffer ());
}

Просмотреть файл

@ -694,7 +694,6 @@ nsresult nsHTTPResponse::EmitHeaders(nsCString& aResponseBuffer)
PRBool bMoreHeaders;
nsXPIDLCString autoBuffer;
nsAutoString autoString;
nsCOMPtr<nsISupports> item;
nsCOMPtr<nsIHTTPHeader> header;
nsCOMPtr<nsIAtom> headerAtom;
@ -729,11 +728,13 @@ nsresult nsHTTPResponse::EmitHeaders(nsCString& aResponseBuffer)
header->GetValue(getter_Copies(autoBuffer));
// STRING USE WARNING: perhaps |autoString| should be an |nsCAutoString|? -- scc
nsAutoString autoString;
headerAtom->ToString(autoString);
autoString.Append(": ");
autoString.Append(autoBuffer);
autoString.Append(CRLF);
aResponseBuffer.Append(autoString);
autoString.AppendWithConversion(": ");
autoString.AppendWithConversion(autoBuffer);
autoString.AppendWithConversion(CRLF);
aResponseBuffer.AppendWithConversion(autoString);
}
return NS_OK;
@ -828,7 +829,7 @@ nsresult nsHTTPResponse::UpdateHeaders(nsISimpleEnumerator *aEnumerator)
// Convert the atom name from unicode to ascii...
atom->GetUnicode(&name);
nameBuffer.Assign(name);
nameBuffer.AssignWithConversion(name);
PR_LOG(gHTTPLog, PR_LOG_ALWAYS,
("\tUpdateHeaders [this=%x]."
"\tIgnoring response header: \'%s\'\n",
@ -850,7 +851,7 @@ nsresult nsHTTPResponse::UpdateHeaders(nsISimpleEnumerator *aEnumerator)
const PRUnichar *name = nsnull;
atom->GetUnicode(&name);
nameBuffer.Assign(name);
nameBuffer.AssignWithConversion(name);
PR_LOG(gHTTPLog, PR_LOG_ALWAYS,
("\tUpdateHeaders [this=%x].\tNew response header: \'%s: %s\'\n",
this, nameBuffer.GetBuffer(), (const char*)headerValue));

Просмотреть файл

@ -374,8 +374,8 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel,
StreamConvService, kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsString fromStr ( compressHeader );
nsString toStr ( "uncompressed" );
nsString fromStr; fromStr.AssignWithConversion ( compressHeader );
nsString toStr; toStr.AssignWithConversion ( "uncompressed" );
nsCOMPtr<nsIStreamListener> converterListener;
rv = StreamConvService->AsyncConvertData(
@ -402,8 +402,8 @@ nsHTTPServerListener::OnDataAvailable(nsIChannel* channel,
StreamConvService, kStreamConverterServiceCID, &rv);
if (NS_FAILED(rv)) return rv;
nsString fromStr ( chunkHeader);
nsString toStr ("unchunked" );
nsString fromStr; fromStr.AssignWithConversion ( chunkHeader );
nsString toStr; toStr.AssignWithConversion ( "unchunked" );
nsCOMPtr<nsIStreamListener> converterListener;
rv = StreamConvService->AsyncConvertData(
@ -653,7 +653,7 @@ nsWriteToString(void* closure,
{
nsString *str = (nsString*)closure;
str->Append(fromRawSegment, count);
str->AppendWithConversion(fromRawSegment, count);
*writeCount = count;
return NS_OK;