From 4b348cc604a1a337752cb5cb89a28969c78ff997 Mon Sep 17 00:00:00 2001 From: "kipp%netscape.com" Date: Thu, 2 Sep 1999 18:13:07 +0000 Subject: [PATCH] Use nsAutoString instead of nsString for temps git-svn-id: svn://10.0.0.236/trunk@45699 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 5 +++-- mozilla/dom/src/base/nsGlobalWindow.cpp | 12 ++++++------ mozilla/htmlparser/src/nsParser.cpp | 2 +- mozilla/netwerk/base/src/nsStdURL.cpp | 8 ++++---- mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp | 4 ++-- mozilla/netwerk/mime/src/nsMIMEService.cpp | 4 ++-- mozilla/parser/htmlparser/src/nsParser.cpp | 2 +- mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp | 4 ++-- mozilla/webshell/src/nsWebShell.cpp | 5 +++-- mozilla/webshell/tests/viewer/nsBrowserWindow.cpp | 14 +++++++++----- mozilla/webshell/tests/viewer/nsSetupRegistry.cpp | 6 +++--- .../toolkit_service/nsUnixToolkitService.cpp | 10 +++++----- 12 files changed, 41 insertions(+), 35 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 854f0e42ca0..8b0229a345c 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -2230,7 +2230,7 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, { nsresult rv; - nsString2 urlStr = aURLSpec; + nsAutoString urlStr(aURLSpec); #ifdef NECKO CancelRefreshURITimers(); @@ -4235,7 +4235,7 @@ nsWebShell::SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet) NS_IMETHODIMP nsWebShell::GetForceCharacterSet (const PRUnichar** aForceCharacterSet) { - nsString emptyStr = ""; + nsAutoString emptyStr; if (mForceCharacterSet.Equals(emptyStr)) { *aForceCharacterSet = nsnull; } @@ -4244,6 +4244,7 @@ nsWebShell::GetForceCharacterSet (const PRUnichar** aForceCharacterSet) } return NS_OK; } + NS_IMETHODIMP nsWebShell::SetForceCharacterSet (const PRUnichar* aForceCharacterSet) { diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index d0038ed343c..e67a32b2bf8 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -2659,12 +2659,12 @@ GlobalWindowImpl::SetProperty(JSContext *aContext, jsval aID, jsval *aVp) { PRBool result = PR_TRUE; if (JS_TypeOfValue(aContext, *aVp) == JSTYPE_FUNCTION && JSVAL_IS_STRING(aID)) { - nsString mPropName; - nsAutoString mPrefix; - mPropName.SetString(JS_GetStringChars(JS_ValueToString(aContext, aID))); - mPrefix.SetString(mPropName.GetUnicode(), 2); - if (mPrefix == "on") { - result = CheckForEventListener(aContext, mPropName); + nsAutoString propName; + nsAutoString prefix; + propName.SetString(JS_GetStringChars(JS_ValueToString(aContext, aID))); + prefix.SetString(propName.GetUnicode(), 2); + if (prefix.EqualsIgnoreCase("on")) { + result = CheckForEventListener(aContext, propName); } } else if (JSVAL_IS_STRING(aID)) { diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index d526f481b26..e6b616318fb 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -441,7 +441,7 @@ eParseMode DetermineParseMode(nsParser& aParser) { nsScanner* theScanner=aParser.GetScanner(); if(theScanner){ - nsString theBufCopy; + nsAutoString theBufCopy; nsString& theBuffer=theScanner->GetBuffer(); theBuffer.Left(theBufCopy,125); theBufCopy.ToUpperCase(); diff --git a/mozilla/netwerk/base/src/nsStdURL.cpp b/mozilla/netwerk/base/src/nsStdURL.cpp index 66ac7184944..f6db0063a51 100644 --- a/mozilla/netwerk/base/src/nsStdURL.cpp +++ b/mozilla/netwerk/base/src/nsStdURL.cpp @@ -586,7 +586,7 @@ nsStdURL::ReconstructSpec() portBuffer[0] = '\0'; } - nsString finalSpec; + nsAutoString finalSpec; if (mScheme) { finalSpec = mScheme; @@ -689,7 +689,7 @@ nsStdURL::SetDirectory(char* i_Directory) if (mDirectory) nsCRT::free(mDirectory); - nsString dir; + nsAutoString dir; if ('/' != *i_Directory) dir += "/"; @@ -788,7 +788,7 @@ nsStdURL::ReconstructPath(void) { //Take all the elements of the path and construct it if (mPath) nsCRT::free(mPath); - nsString path; + nsAutoString path; if (mDirectory) { path = mDirectory; @@ -982,7 +982,7 @@ nsStdURL::DirFile(char **o_DirFile) if (!o_DirFile) return NS_ERROR_NULL_POINTER; - nsString temp; + nsAutoString temp; if (mDirectory) { temp = mDirectory; diff --git a/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp b/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp index 76c55f1098b..5df0ad1ad85 100644 --- a/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp +++ b/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp @@ -37,7 +37,7 @@ nsMIMEInfoImpl::~nsMIMEInfoImpl() { PRBool nsMIMEInfoImpl::InExtensions(nsIAtom* anIAtom) { - nsString2 extension; + nsAutoString extension; anIAtom->ToString(extension); // XXX this is broken. need to use gessner's tokenizer stuff to delimit the commas @@ -67,7 +67,7 @@ NS_IMETHODIMP nsMIMEInfoImpl::GetMIMEType(char * *aMIMEType) { if (!aMIMEType) return NS_ERROR_NULL_POINTER; - nsString2 strMIMEType; + nsAutoString strMIMEType; mMIMEType->ToString(strMIMEType); *aMIMEType = strMIMEType.ToNewCString(); if (!*aMIMEType) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/netwerk/mime/src/nsMIMEService.cpp b/mozilla/netwerk/mime/src/nsMIMEService.cpp index 561f228bd18..6a4d7bc3787 100644 --- a/mozilla/netwerk/mime/src/nsMIMEService.cpp +++ b/mozilla/netwerk/mime/src/nsMIMEService.cpp @@ -221,7 +221,7 @@ NS_IMETHODIMP nsMIMEService::GetTypeFromURI(nsIURI *aURI, char **aContentType) { nsresult rv = NS_ERROR_FAILURE; char *cStrSpec= nsnull; - nsString2 specStr; + nsAutoString specStr; // first try to get a url out of the uri so we can skip post // filename stuff (i.e. query string) @@ -240,7 +240,7 @@ nsMIMEService::GetTypeFromURI(nsIURI *aURI, char **aContentType) { // find the file extension (if any) specStr.SetString(cStrSpec); nsAllocator::Free(cStrSpec); - nsString2 extStr; + nsAutoString extStr; PRInt32 extLoc = specStr.RFindChar('.'); if (-1 != extLoc) { specStr.Right(extStr, specStr.Length() - extLoc - 1); diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index d526f481b26..e6b616318fb 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -441,7 +441,7 @@ eParseMode DetermineParseMode(nsParser& aParser) { nsScanner* theScanner=aParser.GetScanner(); if(theScanner){ - nsString theBufCopy; + nsAutoString theBufCopy; nsString& theBuffer=theScanner->GetBuffer(); theBuffer.Left(theBufCopy,125); theBufCopy.ToUpperCase(); diff --git a/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp b/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp index 76c55f1098b..5df0ad1ad85 100644 --- a/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp +++ b/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp @@ -37,7 +37,7 @@ nsMIMEInfoImpl::~nsMIMEInfoImpl() { PRBool nsMIMEInfoImpl::InExtensions(nsIAtom* anIAtom) { - nsString2 extension; + nsAutoString extension; anIAtom->ToString(extension); // XXX this is broken. need to use gessner's tokenizer stuff to delimit the commas @@ -67,7 +67,7 @@ NS_IMETHODIMP nsMIMEInfoImpl::GetMIMEType(char * *aMIMEType) { if (!aMIMEType) return NS_ERROR_NULL_POINTER; - nsString2 strMIMEType; + nsAutoString strMIMEType; mMIMEType->ToString(strMIMEType); *aMIMEType = strMIMEType.ToNewCString(); if (!*aMIMEType) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index 854f0e42ca0..8b0229a345c 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -2230,7 +2230,7 @@ nsWebShell::LoadURL(const PRUnichar *aURLSpec, { nsresult rv; - nsString2 urlStr = aURLSpec; + nsAutoString urlStr(aURLSpec); #ifdef NECKO CancelRefreshURITimers(); @@ -4235,7 +4235,7 @@ nsWebShell::SetDefaultCharacterSet (const PRUnichar* aDefaultCharacterSet) NS_IMETHODIMP nsWebShell::GetForceCharacterSet (const PRUnichar** aForceCharacterSet) { - nsString emptyStr = ""; + nsAutoString emptyStr; if (mForceCharacterSet.Equals(emptyStr)) { *aForceCharacterSet = nsnull; } @@ -4244,6 +4244,7 @@ nsWebShell::GetForceCharacterSet (const PRUnichar** aForceCharacterSet) } return NS_OK; } + NS_IMETHODIMP nsWebShell::SetForceCharacterSet (const PRUnichar* aForceCharacterSet) { diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 30d6b136ff2..ef6b1c2e564 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -1325,7 +1325,8 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) NS_CreateButton(mWindow,mBack,r,HandleBackEvent,&font); if (NS_OK == mBack->QueryInterface(kIWidgetIID,(void**)&widget)) { - mBack->SetLabel("Back"); + nsAutoString back("Back"); + mBack->SetLabel(back); NS_RELEASE(widget); } @@ -1342,7 +1343,8 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) widget->Create(mWindow, r, HandleForwardEvent, NULL); widget->SetFont(font); widget->Show(PR_TRUE); - mForward->SetLabel("Forward"); + nsAutoString forward("Forward"); + mForward->SetLabel(forward); NS_RELEASE(widget); } @@ -1363,7 +1365,8 @@ nsBrowserWindow::CreateToolBar(PRInt32 aWidth) widget->SetForegroundColor(NS_RGB(0, 0, 0)); widget->SetBackgroundColor(NS_RGB(255, 255, 255)); PRUint32 size; - mLocation->SetText("",size); + nsAutoString empty; + mLocation->SetText(empty, size); NS_RELEASE(widget); } @@ -1697,7 +1700,7 @@ nsBrowserWindow::SetTitle(const PRUnichar* aTitle) nsAutoString newTitle(aTitle); //newTitle.Append(" - Raptor"); newTitle.Append(*gTitleSuffix); - mWindow->SetTitle(newTitle.GetUnicode()); + mWindow->SetTitle(newTitle); return NS_OK; } @@ -1771,7 +1774,8 @@ nsBrowserWindow::BeginLoadURL(nsIWebShell* aShell, const PRUnichar* aURL) if (mThrobber) { mThrobber->Start(); PRUint32 size; - mLocation->SetText(aURL,size); + nsAutoString tmp(aURL); + mLocation->SetText(tmp,size); } } return NS_OK; diff --git a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp index 0bbdeb1c654..da2b9b2fb9d 100644 --- a/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp +++ b/mozilla/webshell/tests/viewer/nsSetupRegistry.cpp @@ -284,9 +284,9 @@ NS_SetupRegistry() NS_ASSERTION(rv == NS_OK,"Cannot obtain unix toolkit service."); - nsString unixToolkitName = "error"; - nsString unixWidgetDllName = "error"; - nsString unixGfxDllName = "error"; + nsAutoString unixToolkitName("error"); + nsAutoString unixWidgetDllName("error"); + nsAutoString unixGfxDllName("error"); if (NS_OK == rv && nsnull != unixToolkitService) { diff --git a/mozilla/widget/src/unix_services/toolkit_service/nsUnixToolkitService.cpp b/mozilla/widget/src/unix_services/toolkit_service/nsUnixToolkitService.cpp index 7cbe31bba19..9845b28fc61 100644 --- a/mozilla/widget/src/unix_services/toolkit_service/nsUnixToolkitService.cpp +++ b/mozilla/widget/src/unix_services/toolkit_service/nsUnixToolkitService.cpp @@ -118,8 +118,8 @@ nsUnixToolkitService::GetWidgetDllName(nsString & aWidgetDllNameOut) // Set sWidgetDllName only once if (nsnull == sWidgetDllName) { - nsString name(""); - nsString toolkit(""); + nsAutoString name; + nsAutoString toolkit; nsresult rv2 = GlobalGetToolkitName(toolkit); @@ -165,8 +165,8 @@ nsUnixToolkitService::GetGfxDllName(nsString & aGfxDllNameOut) // Set sGfxDllName only once if (nsnull == sGfxDllName) { - nsString name(""); - nsString toolkit(""); + nsAutoString name; + nsAutoString toolkit; nsresult rv2 = GlobalGetToolkitName(toolkit); @@ -223,7 +223,7 @@ nsUnixToolkitService::GetTimerCID(nsCID ** aTimerCIDOut) if (nsnull == sTimerCID) { - nsString unixToolkitName; + nsAutoString unixToolkitName; GlobalGetToolkitName(unixToolkitName);