diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index 208310271dc..116d13b0114 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -1430,7 +1430,7 @@ NS_IMETHODIMP nsChromeRegistry::SelectLocaleForProfile(const PRUnichar *aLocale, const PRUnichar *aProfilePath) { // to be changed to use given path - return SetProvider(nsCAutoString("locale"), mSelectedLocale, aLocale, PR_TRUE, NS_ConvertUCS2toUTF8(aProfilePath), PR_TRUE); + return SetProvider(nsCAutoString("locale"), mSelectedLocale, aLocale, PR_TRUE, NS_ConvertUCS2toUTF8(aProfilePath).get(), PR_TRUE); } /* wstring getSelectedLocale (); */ diff --git a/mozilla/content/base/src/nsDocumentEncoder.cpp b/mozilla/content/base/src/nsDocumentEncoder.cpp index 626e284b105..40114f2487a 100644 --- a/mozilla/content/base/src/nsDocumentEncoder.cpp +++ b/mozilla/content/base/src/nsDocumentEncoder.cpp @@ -413,7 +413,8 @@ ConvertAndWrite(nsAReadableString& aString, NS_ENSURE_ARG_POINTER(aEncoder); nsresult rv; PRInt32 charLength, startCharLength; - const PRUnichar* unicodeBuf = (const PRUnichar*)nsPromiseFlatString(aString); + nsPromiseFlatString flat(aString); + const PRUnichar* unicodeBuf = flat.get(); PRInt32 unicodeLength = aString.Length(); PRInt32 startLength = unicodeLength; diff --git a/mozilla/content/base/src/nsHTMLContentSerializer.cpp b/mozilla/content/base/src/nsHTMLContentSerializer.cpp index 38da9acd81a..2fa248b8327 100644 --- a/mozilla/content/base/src/nsHTMLContentSerializer.cpp +++ b/mozilla/content/base/src/nsHTMLContentSerializer.cpp @@ -185,7 +185,7 @@ nsHTMLContentSerializer::SerializeAttributes(nsIContent* aContent, nsXPIDLString sharedName; attrName->GetUnicode(getter_Shares(sharedName)); if (nsCRT::strncmp(sharedName, - NS_ConvertASCIItoUCS2(kMozStr), + NS_ConvertASCIItoUCS2(kMozStr).get(), sizeof(kMozStr)-1) == 0) { continue; } @@ -719,8 +719,7 @@ nsHTMLContentSerializer::StartIndentation(nsIAtom* aName, { if ((mDoFormat || aHasDirtyAttr) && !mPreLevel && !mColPos) { for (PRInt32 i = mIndent; --i >= 0; ) { - AppendToString(kIndentStr, -1, - aStr); + AppendToString(kIndentStr, aStr); } } @@ -759,8 +758,7 @@ nsHTMLContentSerializer::EndIndentation(nsIAtom* aName, if ((mDoFormat || aHasDirtyAttr) && !mPreLevel && !mColPos) { for (PRInt32 i = mIndent; --i >= 0; ) { - AppendToString(kIndentStr, -1, - aStr); + AppendToString(kIndentStr, aStr); } } } diff --git a/mozilla/content/base/src/nsPlainTextSerializer.cpp b/mozilla/content/base/src/nsPlainTextSerializer.cpp index c9924cc79fe..0dbf655f8ee 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/content/base/src/nsPlainTextSerializer.cpp @@ -1385,7 +1385,7 @@ nsPlainTextSerializer::Write(const nsAReadableString& aString) mEmptyLines=0; mAtFirstColumn = PR_TRUE; bol = newline+1; - if('\r' == aString[newline] && bol < totLen && '\n' == aString[bol]) { + if('\r' == *iter && bol < totLen && '\n' == *++iter) { // There was a CRLF in the input. This used to be illegal and // stripped by the parser. Apparently not anymore. Let's skip // over the LF. diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index 7d543026787..6239d94f67d 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -493,7 +493,7 @@ HTMLContentSink::SinkTraceNode(PRUint32 aBit, dtd->IntTagToStringTag(nsHTMLTag(aNode.GetNodeType()), str); cp = str.ToCString(cbuf, sizeof(cbuf)); } else { - cp = (const char*)flat; + cp = flat.get(); } PR_LogPrint("%s: this=%p node='%s' stackPos=%d", aMsg, aThis, cp, aStackPos); } diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 678263cfcbc..5573481b4f8 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -163,7 +163,7 @@ MyPrefChangedCallback(const char*aPrefName, void* instance_data) { if(nsCRT::strlen(detector_name) > 0) { PL_strncpy(g_detector_contractid, NS_CHARSET_DETECTOR_CONTRACTID_BASE,DETECTOR_CONTRACTID_MAX); - PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name),DETECTOR_CONTRACTID_MAX); + PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get(),DETECTOR_CONTRACTID_MAX); gPlugDetector = PR_TRUE; } else { g_detector_contractid[0]=0; @@ -779,7 +779,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, &detector_name))) { PL_strncpy(g_detector_contractid, NS_CHARSET_DETECTOR_CONTRACTID_BASE,DETECTOR_CONTRACTID_MAX); - PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name),DETECTOR_CONTRACTID_MAX); + PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get(),DETECTOR_CONTRACTID_MAX); gPlugDetector = PR_TRUE; PR_FREEIF(detector_name); } @@ -905,7 +905,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, if(cachedData) { rv=cachedData->SetAnnotation("charset",charset.Length()+1, - NS_ConvertUCS2toUTF8(charset.GetUnicode())); + NS_ConvertUCS2toUTF8(charset).get()); NS_ASSERTION(NS_SUCCEEDED(rv),"cannot SetAnnotation"); } diff --git a/mozilla/content/xbl/src/nsBindingManager.cpp b/mozilla/content/xbl/src/nsBindingManager.cpp index 4177ff29d3e..2fa37c8b254 100644 --- a/mozilla/content/xbl/src/nsBindingManager.cpp +++ b/mozilla/content/xbl/src/nsBindingManager.cpp @@ -160,8 +160,7 @@ nsXBLDocumentInfo::GetPrototypeBinding(const nsAReadableCString& aRef, nsIXBLPro if (!mBindingTable) return NS_OK; - const char* str = nsPromiseFlatCString(aRef); - nsCStringKey key(str); + nsCStringKey key(nsPromiseFlatCString(aRef).get()); *aResult = NS_STATIC_CAST(nsIXBLPrototypeBinding*, mBindingTable->Get(&key)); // Addref happens here. return NS_OK; @@ -173,8 +172,7 @@ nsXBLDocumentInfo::SetPrototypeBinding(const nsAReadableCString& aRef, nsIXBLPro if (!mBindingTable) mBindingTable = new nsSupportsHashtable(); - const char* str = nsPromiseFlatCString(aRef); - nsCStringKey key(str); + nsCStringKey key(nsPromiseFlatCString(aRef).get()); mBindingTable->Put(&key, aBinding); return NS_OK; @@ -899,7 +897,7 @@ NS_IMETHODIMP nsBindingManager::LoadBindingDocument(nsIDocument* aBoundDoc, const nsAReadableString& aURL, nsIDocument** aResult) { - nsCAutoString url; url.AssignWithConversion((const PRUnichar*)nsPromiseFlatString(aURL).get()); + nsCAutoString url; url.AssignWithConversion(nsPromiseFlatString(aURL).get()); nsCOMPtr uri; nsComponentManager::CreateInstance("@mozilla.org/network/standard-url;1", diff --git a/mozilla/content/xbl/src/nsXBLWindowHandler.cpp b/mozilla/content/xbl/src/nsXBLWindowHandler.cpp index 880ff8b2bf8..63eb42d4a5b 100644 --- a/mozilla/content/xbl/src/nsXBLWindowHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLWindowHandler.cpp @@ -139,7 +139,7 @@ nsXBLSpecialDocInfo::GetHandlers(nsIXBLDocumentInfo* aInfo, root->ChildAt(i, *getter_AddRefs(child)); nsAutoString id; child->GetAttribute(kNameSpaceID_None, nsHTMLAtoms::id, id); - if (id.EqualsWithConversion(nsPromiseFlatCString(aRef))) { + if (id.EqualsWithConversion(nsPromiseFlatCString(aRef).get())) { NS_NewXBLPrototypeBinding(aRef, child, aInfo, getter_AddRefs(binding)); aInfo->SetPrototypeBinding(aRef, binding); break; diff --git a/mozilla/content/xml/document/src/nsXMLDocument.cpp b/mozilla/content/xml/document/src/nsXMLDocument.cpp index bfd86ccb357..c62eed4bb69 100644 --- a/mozilla/content/xml/document/src/nsXMLDocument.cpp +++ b/mozilla/content/xml/document/src/nsXMLDocument.cpp @@ -110,7 +110,7 @@ MyPrefChangedCallback(const char*aPrefName, void* instance_data) { if(nsCRT::strlen(detector_name) > 0) { PL_strncpy(g_detector_contractid, NS_CHARSET_DETECTOR_CONTRACTID_BASE,DETECTOR_CONTRACTID_MAX); - PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name),DETECTOR_CONTRACTID_MAX); + PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get(),DETECTOR_CONTRACTID_MAX); gPlugDetector = PR_TRUE; } else { g_detector_contractid[0]=0; @@ -581,7 +581,7 @@ nsXMLDocument::StartDocumentLoad(const char* aCommand, &detector_name))) { PL_strncpy(g_detector_contractid, NS_CHARSET_DETECTOR_CONTRACTID_BASE,DETECTOR_CONTRACTID_MAX); - PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name),DETECTOR_CONTRACTID_MAX); + PL_strncat(g_detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get(),DETECTOR_CONTRACTID_MAX); gPlugDetector = PR_TRUE; PR_FREEIF(detector_name); } diff --git a/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp b/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp index 2e3b2bef92d..1c3b4e36fb5 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp @@ -725,7 +725,7 @@ nsLDAPChannel::OnLDAPMessage(nsILDAPMessage *aMessage) // log the message // rv = consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: WARNING: nsLDAPChannel::OnLDAPMessage(): Unexpected LDAP message received")); + NS_LITERAL_STRING("LDAP: WARNING: nsLDAPChannel::OnLDAPMessage(): Unexpected LDAP message received").get()); NS_ASSERTION(NS_SUCCEEDED(rv), "nsLDAPChannel::OnLDAPMessage(): " "consoleSvc->LogStringMessage() failed"); break; diff --git a/mozilla/directory/xpcom/base/src/nsLDAPConnection.cpp b/mozilla/directory/xpcom/base/src/nsLDAPConnection.cpp index 491ddc2e2f3..544b2773a42 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPConnection.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPConnection.cpp @@ -416,14 +416,14 @@ nsLDAPConnection::Run(void) case LDAP_DECODING_ERROR: consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: WARNING: decoding error; possible corrupt data received")); + NS_LITERAL_STRING("LDAP: WARNING: decoding error; possible corrupt data received").get()); NS_WARNING("nsLDAPConnection::Run(): ldaperrno = " "LDAP_DECODING_ERROR after ldap_result()"); break; case LDAP_NO_MEMORY: consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: ERROR: couldn't allocate memory while getting async operation result")); + NS_LITERAL_STRING("LDAP: ERROR: couldn't allocate memory while getting async operation result").get()); // punt and hope things work out better next time around break; @@ -431,7 +431,7 @@ nsLDAPConnection::Run(void) // shouldn't happen; internal error // consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: DEBUG: ldaperrno set to unexpected value after ldap_result() call in nsLDAPConnection::Run()")); + NS_LITERAL_STRING("LDAP: DEBUG: ldaperrno set to unexpected value after ldap_result() call in nsLDAPConnection::Run()").get()); NS_WARNING("nsLDAPConnection::Run(): ldaperrno set to " "unexpected value after ldap_result() " "call in nsLDAPConnection::Run()"); @@ -457,7 +457,7 @@ nsLDAPConnection::Run(void) msg = new nsLDAPMessage(); if (!msg) { consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: ERROR: couldn't allocate memory for new LDAP message; search entry dropped")); + NS_LITERAL_STRING("LDAP: ERROR: couldn't allocate memory for new LDAP message; search entry dropped").get()); // punt and hope things work out better next time around break; } @@ -470,7 +470,7 @@ nsLDAPConnection::Run(void) case NS_ERROR_LDAP_DECODING_ERROR: consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: WARNING: decoding error; possible corrupt data received")); + NS_LITERAL_STRING("LDAP: WARNING: decoding error; possible corrupt data received").get()); NS_WARNING("nsLDAPConnection::Run(): ldaperrno = " "LDAP_DECODING_ERROR after ldap_result()"); continue; @@ -478,7 +478,7 @@ nsLDAPConnection::Run(void) case NS_ERROR_OUT_OF_MEMORY: consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: ERROR: couldn't allocate memory for new LDAP message; search entry dropped")); + NS_LITERAL_STRING("LDAP: ERROR: couldn't allocate memory for new LDAP message; search entry dropped").get()); // punt and hope things work out better next time around continue; break; @@ -489,7 +489,7 @@ nsLDAPConnection::Run(void) // shouldn't happen; internal error // consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: DEBUG: nsLDAPConnection::Run(): nsLDAPMessage::Init() returned unexpected value")); + NS_LITERAL_STRING("LDAP: DEBUG: nsLDAPConnection::Run(): nsLDAPMessage::Init() returned unexpected value").get()); NS_WARNING("nsLDAPConnection::Run(): nsLDAPMessage::Init() " "returned unexpected value."); @@ -504,7 +504,7 @@ nsLDAPConnection::Run(void) rv = InvokeMessageCallback(msgHandle, msg, operationFinished); if (NS_FAILED(rv)) { consoleSvc->LogStringMessage( - NS_LITERAL_STRING("LDAP: ERROR: problem invoking message callback")); + NS_LITERAL_STRING("LDAP: ERROR: problem invoking message callback").get()); NS_ERROR("LDAP: ERROR: problem invoking message callback"); // punt and hope things work out better next time around continue; diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 19b616bdb3e..c9acfaddedb 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -1211,7 +1211,7 @@ nsWebShell :: IsCommandEnabled ( const nsAReadableString & inCommand, PRBool* ou nsCOMPtr controller; rv = GetControllerForCommand ( inCommand, getter_AddRefs(controller) ); if ( controller ) - rv = controller->IsCommandEnabled(nsPromiseFlatString(inCommand), outEnabled); + rv = controller->IsCommandEnabled(nsPromiseFlatString(inCommand).get(), outEnabled); return rv; } @@ -1225,7 +1225,7 @@ nsWebShell :: DoCommand ( const nsAReadableString & inCommand ) nsCOMPtr controller; rv = GetControllerForCommand ( inCommand, getter_AddRefs(controller) ); if ( controller ) - rv = controller->DoCommand(nsPromiseFlatString(inCommand)); + rv = controller->DoCommand(nsPromiseFlatString(inCommand).get()); return rv; } diff --git a/mozilla/dom/src/base/nsGlobalWindow.cpp b/mozilla/dom/src/base/nsGlobalWindow.cpp index fcff5e01dba..f25a02aee65 100644 --- a/mozilla/dom/src/base/nsGlobalWindow.cpp +++ b/mozilla/dom/src/base/nsGlobalWindow.cpp @@ -1146,7 +1146,7 @@ GlobalWindowImpl::SetTitle(const nsAReadableString& aTitle) if(type == nsIDocShellTreeItem::typeChrome) { nsCOMPtr docShellAsWin(do_QueryInterface(mDocShell)); if(docShellAsWin) { - docShellAsWin->SetTitle(nsPromiseFlatString(mTitle)); + docShellAsWin->SetTitle(nsPromiseFlatString(mTitle).get()); } } } diff --git a/mozilla/dom/src/base/nsLocation.cpp b/mozilla/dom/src/base/nsLocation.cpp index 2c1948bda6d..a8c0064773e 100644 --- a/mozilla/dom/src/base/nsLocation.cpp +++ b/mozilla/dom/src/base/nsLocation.cpp @@ -218,7 +218,7 @@ LocationImpl::SetHash(const nsAReadableString& aHash) nsCOMPtr url(do_QueryInterface(uri, &result)); if (url) { - url->SetRef(NS_ConvertUCS2toUTF8(aHash)); + url->SetRef(NS_ConvertUCS2toUTF8(aHash).get()); SetURL(url); } @@ -281,7 +281,7 @@ LocationImpl::SetHost(const nsAReadableString& aHost) result = NS_NewURI(getter_AddRefs(uri), href); if (uri) { - uri->SetHost(NS_ConvertUCS2toUTF8(aHost)); + uri->SetHost(NS_ConvertUCS2toUTF8(aHost).get()); SetURL(uri); } @@ -331,7 +331,7 @@ LocationImpl::SetHostname(const nsAReadableString& aHostname) result = NS_NewURI(getter_AddRefs(uri), href); if (uri) { - uri->SetHost(NS_ConvertUCS2toUTF8(aHostname)); + uri->SetHost(NS_ConvertUCS2toUTF8(aHostname).get()); SetURL(uri); } } @@ -495,7 +495,7 @@ LocationImpl::SetPathname(const nsAReadableString& aPathname) result = NS_NewURI(getter_AddRefs(uri), href); if (uri) { - uri->SetPath(NS_ConvertUCS2toUTF8(aPathname)); + uri->SetPath(NS_ConvertUCS2toUTF8(aPathname).get()); SetURL(uri); } } @@ -608,7 +608,7 @@ LocationImpl::SetProtocol(const nsAReadableString& aProtocol) result = NS_NewURI(getter_AddRefs(uri), href); if (uri) { - uri->SetScheme(NS_ConvertUCS2toUTF8(aProtocol)); + uri->SetScheme(NS_ConvertUCS2toUTF8(aProtocol).get()); SetURL(uri); } } @@ -667,7 +667,7 @@ LocationImpl::SetSearch(const nsAReadableString& aSearch) nsCOMPtr url(do_QueryInterface(uri, &result)); if (url) { - result = url->SetQuery(NS_ConvertUCS2toUTF8(aSearch)); + result = url->SetQuery(NS_ConvertUCS2toUTF8(aSearch).get()); SetURL(uri); } diff --git a/mozilla/editor/base/TextEditorTest.cpp b/mozilla/editor/base/TextEditorTest.cpp index 7ffe8f49391..260cfc955b2 100644 --- a/mozilla/editor/base/TextEditorTest.cpp +++ b/mozilla/editor/base/TextEditorTest.cpp @@ -71,13 +71,13 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF // shouldn't we just bail on error here? // insert some simple text - result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890")); + result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890").get()); TEST_RESULT(result); (*outNumTests)++; (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); // insert some more text - result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere")); + result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere").get()); TEST_RESULT(result); (*outNumTests)++; (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); diff --git a/mozilla/editor/base/nsEditor.cpp b/mozilla/editor/base/nsEditor.cpp index 76dcca61820..b3def864b9f 100644 --- a/mozilla/editor/base/nsEditor.cpp +++ b/mozilla/editor/base/nsEditor.cpp @@ -913,7 +913,7 @@ nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, if (wrapColumn > 0) flags |= nsIDocumentEncoder::OutputWrap; rv = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy, - aFormat.GetUnicode(), NS_LITERAL_STRING(""), + aFormat.GetUnicode(), NS_LITERAL_STRING("").get(), flags, wrapColumn); if (NS_SUCCEEDED(rv)) DoAfterDocumentSave(); diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index 087aecf9437..a38aafddab2 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -2948,12 +2948,12 @@ nsEditorShell::GetString(const PRUnichar *stringName, PRUnichar **_retval) // Use this version within the shell: -void nsEditorShell::GetBundleString(const PRUnichar *stringName, nsString &outString) +void nsEditorShell::GetBundleString(const nsAReadableString &stringName, nsAWritableString &outString) { outString.Truncate(); nsXPIDLString tempString; - if (NS_SUCCEEDED(GetString(stringName, getter_Copies(tempString))) && tempString) + if (NS_SUCCEEDED(GetString(nsPromiseFlatString(stringName).get(), getter_Copies(tempString))) && tempString) outString = tempString.get(); } @@ -4537,7 +4537,7 @@ nsEditorShell::InitSpellChecker() nsCOMPtr chromeRegistry = do_GetService(kChromeRegistryCID, &result); if (NS_SUCCEEDED(result) && chromeRegistry) - result = chromeRegistry->GetSelectedLocale(NS_LITERAL_STRING("navigator"), &dictName); + result = chromeRegistry->GetSelectedLocale(NS_LITERAL_STRING("navigator").get(), &dictName); } if (NS_SUCCEEDED(result) && dictName && *dictName) @@ -5216,7 +5216,7 @@ nsresult nsEditorShell::EndPageLoad(nsIDOMWindow *aDOMWindow, break; } - GetBundleString(stringID.GetUnicode(), alertMessage); + GetBundleString(stringID, alertMessage); Alert(alertLabel, alertMessage); nsCOMPtr baseWindow; diff --git a/mozilla/editor/base/nsEditorShell.h b/mozilla/editor/base/nsEditorShell.h index 1eeb98200f9..26b7136dfa3 100644 --- a/mozilla/editor/base/nsEditorShell.h +++ b/mozilla/editor/base/nsEditorShell.h @@ -144,7 +144,7 @@ class nsEditorShell : public nsIEditorShell, // Get a string from the string bundle file. If the string is not found // this returns an empty string. - void GetBundleString(const PRUnichar *stringName, nsString &outString); + void GetBundleString(const nsAReadableString &stringName, nsAWritableString &outString); // Get the text of the tag nsresult GetDocumentTitleString(nsString& title); diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index 56738ed5352..4470af1f9f1 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -1771,7 +1771,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) // put a space in it so layout will draw the list item res = selection->Collapse(newBQ,0); if (NS_FAILED(res)) return res; - res = InsertText(NS_LITERAL_STRING(" ")); + res = InsertText(NS_LITERAL_STRING(" ").get()); if (NS_FAILED(res)) return res; // reposition selection to before the space character res = GetStartNodeAndOffset(selection, address_of(node), &offset); diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index 087aecf9437..a38aafddab2 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -2948,12 +2948,12 @@ nsEditorShell::GetString(const PRUnichar *stringName, PRUnichar **_retval) // Use this version within the shell: -void nsEditorShell::GetBundleString(const PRUnichar *stringName, nsString &outString) +void nsEditorShell::GetBundleString(const nsAReadableString &stringName, nsAWritableString &outString) { outString.Truncate(); nsXPIDLString tempString; - if (NS_SUCCEEDED(GetString(stringName, getter_Copies(tempString))) && tempString) + if (NS_SUCCEEDED(GetString(nsPromiseFlatString(stringName).get(), getter_Copies(tempString))) && tempString) outString = tempString.get(); } @@ -4537,7 +4537,7 @@ nsEditorShell::InitSpellChecker() nsCOMPtr<nsIChromeRegistry> chromeRegistry = do_GetService(kChromeRegistryCID, &result); if (NS_SUCCEEDED(result) && chromeRegistry) - result = chromeRegistry->GetSelectedLocale(NS_LITERAL_STRING("navigator"), &dictName); + result = chromeRegistry->GetSelectedLocale(NS_LITERAL_STRING("navigator").get(), &dictName); } if (NS_SUCCEEDED(result) && dictName && *dictName) @@ -5216,7 +5216,7 @@ nsresult nsEditorShell::EndPageLoad(nsIDOMWindow *aDOMWindow, break; } - GetBundleString(stringID.GetUnicode(), alertMessage); + GetBundleString(stringID, alertMessage); Alert(alertLabel, alertMessage); nsCOMPtr<nsIBaseWindow> baseWindow; diff --git a/mozilla/editor/composer/src/nsEditorShell.h b/mozilla/editor/composer/src/nsEditorShell.h index 1eeb98200f9..26b7136dfa3 100644 --- a/mozilla/editor/composer/src/nsEditorShell.h +++ b/mozilla/editor/composer/src/nsEditorShell.h @@ -144,7 +144,7 @@ class nsEditorShell : public nsIEditorShell, // Get a string from the string bundle file. If the string is not found // this returns an empty string. - void GetBundleString(const PRUnichar *stringName, nsString &outString); + void GetBundleString(const nsAReadableString &stringName, nsAWritableString &outString); // Get the text of the <title> tag nsresult GetDocumentTitleString(nsString& title); diff --git a/mozilla/editor/libeditor/base/nsEditor.cpp b/mozilla/editor/libeditor/base/nsEditor.cpp index 76dcca61820..b3def864b9f 100644 --- a/mozilla/editor/libeditor/base/nsEditor.cpp +++ b/mozilla/editor/libeditor/base/nsEditor.cpp @@ -913,7 +913,7 @@ nsEditor::SaveFile(nsIFile *aFileSpec, PRBool aReplaceExisting, if (wrapColumn > 0) flags |= nsIDocumentEncoder::OutputWrap; rv = diskDoc->SaveFile(aFileSpec, aReplaceExisting, aSaveCopy, - aFormat.GetUnicode(), NS_LITERAL_STRING(""), + aFormat.GetUnicode(), NS_LITERAL_STRING("").get(), flags, wrapColumn); if (NS_SUCCEEDED(rv)) DoAfterDocumentSave(); diff --git a/mozilla/editor/libeditor/html/TextEditorTest.cpp b/mozilla/editor/libeditor/html/TextEditorTest.cpp index 7ffe8f49391..260cfc955b2 100644 --- a/mozilla/editor/libeditor/html/TextEditorTest.cpp +++ b/mozilla/editor/libeditor/html/TextEditorTest.cpp @@ -71,13 +71,13 @@ nsresult TextEditorTest::RunUnitTest(PRInt32 *outNumTests, PRInt32 *outNumTestsF // shouldn't we just bail on error here? // insert some simple text - result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890")); + result = mTextEditor->InsertText(NS_LITERAL_STRING("1234567890abcdefghij1234567890").get()); TEST_RESULT(result); (*outNumTests)++; (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); // insert some more text - result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere")); + result = mTextEditor->InsertText(NS_LITERAL_STRING("Moreover, I am cognizant of the interrelatedness of all communities and states. I cannot sit idly by in Atlanta and not be concerned about what happens in Birmingham. Injustice anywhere is a threat to justice everywhere").get()); TEST_RESULT(result); (*outNumTests)++; (*outNumTestsFailed) += (NS_FAILED(result) != NS_OK); diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index 56738ed5352..4470af1f9f1 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -1771,7 +1771,7 @@ nsHTMLEditor::Indent(const nsString& aIndent) // put a space in it so layout will draw the list item res = selection->Collapse(newBQ,0); if (NS_FAILED(res)) return res; - res = InsertText(NS_LITERAL_STRING(" ")); + res = InsertText(NS_LITERAL_STRING(" ").get()); if (NS_FAILED(res)) return res; // reposition selection to before the space character res = GetStartNodeAndOffset(selection, address_of(node), &offset); diff --git a/mozilla/embedding/browser/powerplant/source/CProfileManager.cpp b/mozilla/embedding/browser/powerplant/source/CProfileManager.cpp index d254da14ba5..382a681b0c9 100755 --- a/mozilla/embedding/browser/powerplant/source/CProfileManager.cpp +++ b/mozilla/embedding/browser/powerplant/source/CProfileManager.cpp @@ -81,9 +81,9 @@ void CProfileManager::StartUp() // Make a new default profile NS_NAMED_LITERAL_STRING(newProfileName, "default"); - rv = profileService->CreateNewProfile(newProfileName, nsnull, nsnull, PR_FALSE); + rv = profileService->CreateNewProfile(newProfileName.get(), nsnull, nsnull, PR_FALSE); ThrowIfError_(rv); - rv = profileService->SetCurrentProfile(newProfileName); + rv = profileService->SetCurrentProfile(newProfileName.get()); ThrowIfError_(rv); } else @@ -327,7 +327,7 @@ nsresult CProfileManager::GetShowDialogOnStart(PRBool* showIt) nsRegistryKey profilesTreeKey; rv = registry->GetKey(nsIRegistry::Common, - kRegistryGlobalPrefsSubtreeString, + kRegistryGlobalPrefsSubtreeString.get(), &profilesTreeKey); if (NS_SUCCEEDED(rv)) @@ -355,13 +355,13 @@ nsresult CProfileManager::SetShowDialogOnStart(PRBool showIt) nsRegistryKey profilesTreeKey; rv = registry->GetKey(nsIRegistry::Common, - kRegistryGlobalPrefsSubtreeString, + kRegistryGlobalPrefsSubtreeString.get(), &profilesTreeKey); if (NS_FAILED(rv)) { rv = registry->AddKey(nsIRegistry::Common, - kRegistryGlobalPrefsSubtreeString, + kRegistryGlobalPrefsSubtreeString.get(), &profilesTreeKey); } if (NS_SUCCEEDED(rv)) diff --git a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index 00aed9990b3..960d4339ccf 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -615,9 +615,9 @@ nsWindowWatcher::RegisterNotification(nsIObserver *aObserver) nsCOMPtr<nsIObserverService> os(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (os) { - rv = os->AddObserver(aObserver, NOTIFICATION_OPENED); + rv = os->AddObserver(aObserver, NOTIFICATION_OPENED.get()); if (NS_SUCCEEDED(rv)) - rv = os->AddObserver(aObserver, NOTIFICATION_CLOSED); + rv = os->AddObserver(aObserver, NOTIFICATION_CLOSED.get()); } return rv; } @@ -633,8 +633,8 @@ nsWindowWatcher::UnregisterNotification(nsIObserver *aObserver) nsCOMPtr<nsIObserverService> os(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (os) { - os->RemoveObserver(aObserver, NOTIFICATION_OPENED); - os->RemoveObserver(aObserver, NOTIFICATION_CLOSED); + os->RemoveObserver(aObserver, NOTIFICATION_OPENED.get()); + os->RemoveObserver(aObserver, NOTIFICATION_CLOSED.get()); } return rv; } @@ -702,7 +702,7 @@ nsWindowWatcher::AddWindow(nsIDOMWindow *aWindow) nsCOMPtr<nsIObserverService> os(do_GetService(NS_OBSERVERSERVICE_CONTRACTID, &rv)); if (os) { nsCOMPtr<nsISupports> domwin(do_QueryInterface(aWindow)); - rv = os->Notify(domwin, NOTIFICATION_OPENED, 0); + rv = os->Notify(domwin, NOTIFICATION_OPENED.get(), 0); } return rv; @@ -776,11 +776,11 @@ nsresult nsWindowWatcher::RemoveWindow(WindowInfo *inInfo) #ifdef USEWEAKREFS nsCOMPtr<nsISupports> domwin(do_QueryReferent(inInfo->mWindow)); if (domwin) - rv = os->Notify(domwin, NOTIFICATION_CLOSED, 0); + rv = os->Notify(domwin, NOTIFICATION_CLOSED.get(), 0); // else bummer. since the window is gone, there's nothing to notify with. #else nsCOMPtr<nsISupports> domwin(do_QueryInterface(inInfo->mWindow)); - rv = os->Notify(domwin, NOTIFICATION_CLOSED, 0); + rv = os->Notify(domwin, NOTIFICATION_CLOSED.get(), 0); #endif } diff --git a/mozilla/extensions/wallet/src/wallet.cpp b/mozilla/extensions/wallet/src/wallet.cpp index b3e32e4c3eb..fbecc0dd1b1 100644 --- a/mozilla/extensions/wallet/src/wallet.cpp +++ b/mozilla/extensions/wallet/src/wallet.cpp @@ -1046,7 +1046,7 @@ wallet_WriteToList( break; } } - } else if((mapElementPtr->item1.Compare(item1))==0) { + } else if(Compare(mapElementPtr->item1, item1)==0) { if (DUP_OVERWRITE==placement) { delete mapElement; mapElementPtr->item1 = item1; @@ -1059,7 +1059,7 @@ wallet_WriteToList( added_to_list = PR_TRUE; break; } - } else if((mapElementPtr->item1.Compare(item1))>=0) { + } else if(Compare(mapElementPtr->item1, item1)>=0) { list->InsertElementAt(mapElement, i); added_to_list = PR_TRUE; break; @@ -1093,7 +1093,7 @@ wallet_ReadFromList( PRInt32 count = LIST_COUNT(list); for (PRInt32 i=index; i<count; i++) { mapElementPtr = NS_STATIC_CAST(wallet_MapElement*, list->ElementAt(i)); - if((mapElementPtr->item1.Compare(item1))==0) { + if(Compare(mapElementPtr->item1, item1)==0) { if (obscure) { if (NS_FAILED(Wallet_Decrypt(mapElementPtr->item2, item2))) { return PR_FALSE; diff --git a/mozilla/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp b/mozilla/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp index 1f429af8088..ea160888714 100644 --- a/mozilla/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp +++ b/mozilla/extensions/webservices/soap/src/nsDefaultSOAPEncoder.cpp @@ -32,6 +32,7 @@ #include "nsIXPConnect.h" #include "nsISupportsPrimitives.h" #include "prprf.h" +#include "nsReadableUtils.h" nsDefaultSOAPEncoder::nsDefaultSOAPEncoder() { @@ -62,38 +63,38 @@ GetElementNameForType(PRInt32 aType, PRUnichar** name) switch (aType) { case nsISOAPParameter::PARAMETER_TYPE_NULL: case nsISOAPParameter::PARAMETER_TYPE_VOID: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kStructElementName)); + *name = ToNewUnicode(nsLiteralCString(kStructElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_STRING: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kStringElementName)); + *name = ToNewUnicode(nsLiteralCString(kStringElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_BOOLEAN: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kBooleanElementName)); + *name = ToNewUnicode(nsLiteralCString(kBooleanElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_DOUBLE: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kDoubleElementName)); + *name = ToNewUnicode(nsLiteralCString(kDoubleElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_FLOAT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kFloatElementName)); + *name = ToNewUnicode(nsLiteralCString(kFloatElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_LONG: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kLongElementName)); + *name = ToNewUnicode(nsLiteralCString(kLongElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_INT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kIntElementName)); + *name = ToNewUnicode(nsLiteralCString(kIntElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_SHORT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kShortElementName)); + *name = ToNewUnicode(nsLiteralCString(kShortElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_BYTE: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kByteElementName)); + *name = ToNewUnicode(nsLiteralCString(kByteElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_ARRAY: case nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_ARRAY: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kArrayElementName)); + *name = ToNewUnicode(nsLiteralCString(kArrayElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_OBJECT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kStructElementName)); + *name = ToNewUnicode(nsLiteralCString(kStructElementName)); break; } } @@ -102,34 +103,34 @@ static void GetTypeForElementName(const PRUnichar* name, PRInt32* aType) { *aType = nsISOAPParameter::PARAMETER_TYPE_NULL; - if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kStringElementName)) == 0) { + if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kStringElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_STRING; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kBooleanElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kBooleanElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_BOOLEAN; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kDoubleElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kDoubleElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_DOUBLE; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kFloatElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kFloatElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_FLOAT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kLongElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kLongElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_LONG; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kIntElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kIntElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_INT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kShortElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kShortElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_SHORT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kByteElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kByteElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_BYTE; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kArrayElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kArrayElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_ARRAY; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kStructElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kStructElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_OBJECT; } } @@ -156,35 +157,35 @@ GetXSDTypeForType(PRInt32 aType, PRUnichar** name) // This will have a xsi:null attribute instead break; case nsISOAPParameter::PARAMETER_TYPE_STRING: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDStringName)); + *name = ToNewUnicode(nsLiteralCString(kXSDStringName)); break; case nsISOAPParameter::PARAMETER_TYPE_BOOLEAN: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDBooleanName)); + *name = ToNewUnicode(nsLiteralCString(kXSDBooleanName)); break; case nsISOAPParameter::PARAMETER_TYPE_DOUBLE: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDDoubleName)); + *name = ToNewUnicode(nsLiteralCString(kXSDDoubleName)); break; case nsISOAPParameter::PARAMETER_TYPE_FLOAT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDFloatName)); + *name = ToNewUnicode(nsLiteralCString(kXSDFloatName)); break; case nsISOAPParameter::PARAMETER_TYPE_LONG: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDLongName)); + *name = ToNewUnicode(nsLiteralCString(kXSDLongName)); break; case nsISOAPParameter::PARAMETER_TYPE_INT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDIntName)); + *name = ToNewUnicode(nsLiteralCString(kXSDIntName)); break; case nsISOAPParameter::PARAMETER_TYPE_SHORT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDShortName)); + *name = ToNewUnicode(nsLiteralCString(kXSDShortName)); break; case nsISOAPParameter::PARAMETER_TYPE_BYTE: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDByteName)); + *name = ToNewUnicode(nsLiteralCString(kXSDByteName)); break; case nsISOAPParameter::PARAMETER_TYPE_ARRAY: case nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_ARRAY: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kSOAPEncArrayAttrName)); + *name = ToNewUnicode(nsLiteralCString(kSOAPEncArrayAttrName)); break; case nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_OBJECT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDStructName)); + *name = ToNewUnicode(nsLiteralCString(kXSDStructName)); break; } } @@ -193,37 +194,37 @@ static void GetTypeForXSDType(const PRUnichar* name, PRInt32* aType) { *aType = nsISOAPParameter::PARAMETER_TYPE_NULL; - if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDStringName)) == 0) { + if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDStringName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_STRING; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDBooleanName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDBooleanName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_BOOLEAN; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDDoubleName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDDoubleName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_DOUBLE; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDFloatName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDFloatName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_FLOAT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDLongName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDLongName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_LONG; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDIntName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDIntName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_INT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDShortName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDShortName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_SHORT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDByteName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDByteName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_BYTE; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kSOAPEncArrayAttrName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kSOAPEncArrayAttrName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_ARRAY; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDStructName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDStructName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_OBJECT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDUrTypeName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDUrTypeName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_UNKNOWN; } } @@ -403,7 +404,7 @@ nsDefaultSOAPEncoder::SerializeJavaScriptObject(JSObject* obj, nsresult rv = newparam->SetValue(cx, val); if (NS_FAILED(rv)) return rv; - param->SetName(NS_ConvertASCIItoUCS2(name)); + param->SetName(NS_ConvertASCIItoUCS2(name).get()); nsCOMPtr<nsIDOMElement> child; rv = EncodeParameter(param, document, getter_AddRefs(child)); @@ -678,13 +679,13 @@ nsDefaultSOAPEncoder::DecodeParameter(nsIDOMElement* element, // Find the corresponding encoder nsCAutoString encoderContractid; encoderContractid.Assign(NS_SOAPENCODER_CONTRACTID_PREFIX); - encoderContractid.Append(NS_ConvertUCS2toUTF8(attrVal.GetUnicode())); + encoderContractid.Append(NS_ConvertUCS2toUTF8(attrVal)); nsCOMPtr<nsISOAPEncoder> encoder = do_CreateInstance(encoderContractid); if (!encoder) return NS_ERROR_INVALID_ARG; return encoder->ElementToParameter(element, - NS_ConvertUCS2toUTF8(attrVal.GetUnicode()), + NS_ConvertUCS2toUTF8(attrVal).get(), type, _retval); } @@ -766,7 +767,7 @@ nsDefaultSOAPEncoder::DeserializeJavaScriptObject(nsIDOMElement *element, if (NS_FAILED(rv)) return rv; if (name) { - JS_SetProperty(cx, obj, NS_ConvertUCS2toUTF8(name), &val); + JS_SetProperty(cx, obj, NS_ConvertUCS2toUTF8(name).get(), &val); } else { JS_SetElement(cx, obj, (jsint)index, &val); @@ -840,7 +841,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, float val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%f", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%f", &val); dub->SetData((double)val); value = dub; @@ -854,7 +855,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, float val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%f", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%f", &val); flt->SetData(val); value = flt; @@ -868,7 +869,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, PRInt64 val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%lld", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%lld", &val); isup64->SetData(val); value = isup64; @@ -882,7 +883,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, PRInt32 val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%ld", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%ld", &val); isup32->SetData(val); value = isup32; @@ -896,7 +897,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, PRInt16 val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%hd", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%hd", &val); isup16->SetData(val); value = isup16; @@ -910,7 +911,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, char val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%c", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%c", &val); isup8->SetData(val); value = isup8; diff --git a/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp b/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp index 1f429af8088..ea160888714 100644 --- a/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp +++ b/mozilla/extensions/xmlextras/soap/src/nsDefaultSOAPEncoder.cpp @@ -32,6 +32,7 @@ #include "nsIXPConnect.h" #include "nsISupportsPrimitives.h" #include "prprf.h" +#include "nsReadableUtils.h" nsDefaultSOAPEncoder::nsDefaultSOAPEncoder() { @@ -62,38 +63,38 @@ GetElementNameForType(PRInt32 aType, PRUnichar** name) switch (aType) { case nsISOAPParameter::PARAMETER_TYPE_NULL: case nsISOAPParameter::PARAMETER_TYPE_VOID: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kStructElementName)); + *name = ToNewUnicode(nsLiteralCString(kStructElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_STRING: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kStringElementName)); + *name = ToNewUnicode(nsLiteralCString(kStringElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_BOOLEAN: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kBooleanElementName)); + *name = ToNewUnicode(nsLiteralCString(kBooleanElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_DOUBLE: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kDoubleElementName)); + *name = ToNewUnicode(nsLiteralCString(kDoubleElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_FLOAT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kFloatElementName)); + *name = ToNewUnicode(nsLiteralCString(kFloatElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_LONG: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kLongElementName)); + *name = ToNewUnicode(nsLiteralCString(kLongElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_INT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kIntElementName)); + *name = ToNewUnicode(nsLiteralCString(kIntElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_SHORT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kShortElementName)); + *name = ToNewUnicode(nsLiteralCString(kShortElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_BYTE: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kByteElementName)); + *name = ToNewUnicode(nsLiteralCString(kByteElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_ARRAY: case nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_ARRAY: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kArrayElementName)); + *name = ToNewUnicode(nsLiteralCString(kArrayElementName)); break; case nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_OBJECT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kStructElementName)); + *name = ToNewUnicode(nsLiteralCString(kStructElementName)); break; } } @@ -102,34 +103,34 @@ static void GetTypeForElementName(const PRUnichar* name, PRInt32* aType) { *aType = nsISOAPParameter::PARAMETER_TYPE_NULL; - if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kStringElementName)) == 0) { + if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kStringElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_STRING; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kBooleanElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kBooleanElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_BOOLEAN; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kDoubleElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kDoubleElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_DOUBLE; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kFloatElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kFloatElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_FLOAT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kLongElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kLongElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_LONG; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kIntElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kIntElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_INT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kShortElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kShortElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_SHORT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kByteElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kByteElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_BYTE; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kArrayElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kArrayElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_ARRAY; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kStructElementName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kStructElementName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_OBJECT; } } @@ -156,35 +157,35 @@ GetXSDTypeForType(PRInt32 aType, PRUnichar** name) // This will have a xsi:null attribute instead break; case nsISOAPParameter::PARAMETER_TYPE_STRING: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDStringName)); + *name = ToNewUnicode(nsLiteralCString(kXSDStringName)); break; case nsISOAPParameter::PARAMETER_TYPE_BOOLEAN: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDBooleanName)); + *name = ToNewUnicode(nsLiteralCString(kXSDBooleanName)); break; case nsISOAPParameter::PARAMETER_TYPE_DOUBLE: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDDoubleName)); + *name = ToNewUnicode(nsLiteralCString(kXSDDoubleName)); break; case nsISOAPParameter::PARAMETER_TYPE_FLOAT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDFloatName)); + *name = ToNewUnicode(nsLiteralCString(kXSDFloatName)); break; case nsISOAPParameter::PARAMETER_TYPE_LONG: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDLongName)); + *name = ToNewUnicode(nsLiteralCString(kXSDLongName)); break; case nsISOAPParameter::PARAMETER_TYPE_INT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDIntName)); + *name = ToNewUnicode(nsLiteralCString(kXSDIntName)); break; case nsISOAPParameter::PARAMETER_TYPE_SHORT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDShortName)); + *name = ToNewUnicode(nsLiteralCString(kXSDShortName)); break; case nsISOAPParameter::PARAMETER_TYPE_BYTE: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDByteName)); + *name = ToNewUnicode(nsLiteralCString(kXSDByteName)); break; case nsISOAPParameter::PARAMETER_TYPE_ARRAY: case nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_ARRAY: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kSOAPEncArrayAttrName)); + *name = ToNewUnicode(nsLiteralCString(kSOAPEncArrayAttrName)); break; case nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_OBJECT: - *name = nsCRT::strdup(NS_ConvertASCIItoUCS2(kXSDStructName)); + *name = ToNewUnicode(nsLiteralCString(kXSDStructName)); break; } } @@ -193,37 +194,37 @@ static void GetTypeForXSDType(const PRUnichar* name, PRInt32* aType) { *aType = nsISOAPParameter::PARAMETER_TYPE_NULL; - if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDStringName)) == 0) { + if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDStringName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_STRING; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDBooleanName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDBooleanName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_BOOLEAN; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDDoubleName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDDoubleName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_DOUBLE; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDFloatName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDFloatName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_FLOAT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDLongName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDLongName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_LONG; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDIntName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDIntName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_INT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDShortName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDShortName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_SHORT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDByteName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDByteName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_BYTE; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kSOAPEncArrayAttrName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kSOAPEncArrayAttrName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_ARRAY; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDStructName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDStructName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_JAVASCRIPT_OBJECT; } - else if (nsCRT::strcmp(name, NS_ConvertASCIItoUCS2(kXSDUrTypeName)) == 0) { + else if (nsLiteralString(name).Equals(NS_ConvertASCIItoUCS2(kXSDUrTypeName))) { *aType = nsISOAPParameter::PARAMETER_TYPE_UNKNOWN; } } @@ -403,7 +404,7 @@ nsDefaultSOAPEncoder::SerializeJavaScriptObject(JSObject* obj, nsresult rv = newparam->SetValue(cx, val); if (NS_FAILED(rv)) return rv; - param->SetName(NS_ConvertASCIItoUCS2(name)); + param->SetName(NS_ConvertASCIItoUCS2(name).get()); nsCOMPtr<nsIDOMElement> child; rv = EncodeParameter(param, document, getter_AddRefs(child)); @@ -678,13 +679,13 @@ nsDefaultSOAPEncoder::DecodeParameter(nsIDOMElement* element, // Find the corresponding encoder nsCAutoString encoderContractid; encoderContractid.Assign(NS_SOAPENCODER_CONTRACTID_PREFIX); - encoderContractid.Append(NS_ConvertUCS2toUTF8(attrVal.GetUnicode())); + encoderContractid.Append(NS_ConvertUCS2toUTF8(attrVal)); nsCOMPtr<nsISOAPEncoder> encoder = do_CreateInstance(encoderContractid); if (!encoder) return NS_ERROR_INVALID_ARG; return encoder->ElementToParameter(element, - NS_ConvertUCS2toUTF8(attrVal.GetUnicode()), + NS_ConvertUCS2toUTF8(attrVal).get(), type, _retval); } @@ -766,7 +767,7 @@ nsDefaultSOAPEncoder::DeserializeJavaScriptObject(nsIDOMElement *element, if (NS_FAILED(rv)) return rv; if (name) { - JS_SetProperty(cx, obj, NS_ConvertUCS2toUTF8(name), &val); + JS_SetProperty(cx, obj, NS_ConvertUCS2toUTF8(name).get(), &val); } else { JS_SetElement(cx, obj, (jsint)index, &val); @@ -840,7 +841,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, float val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%f", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%f", &val); dub->SetData((double)val); value = dub; @@ -854,7 +855,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, float val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%f", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%f", &val); flt->SetData(val); value = flt; @@ -868,7 +869,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, PRInt64 val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%lld", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%lld", &val); isup64->SetData(val); value = isup64; @@ -882,7 +883,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, PRInt32 val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%ld", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%ld", &val); isup32->SetData(val); value = isup32; @@ -896,7 +897,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, PRInt16 val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%hd", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%hd", &val); isup16->SetData(val); value = isup16; @@ -910,7 +911,7 @@ nsDefaultSOAPEncoder::DeserializeParameter(nsIDOMElement *element, char val; nsSOAPUtils::GetElementTextContent(element, text); - PR_sscanf(NS_ConvertUCS2toUTF8(text.GetUnicode()), "%c", &val); + PR_sscanf(NS_ConvertUCS2toUTF8(text).get(), "%c", &val); isup8->SetData(val); value = isup8; diff --git a/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp b/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp index 86c18e25fff..52181f26436 100644 --- a/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp +++ b/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp @@ -289,7 +289,7 @@ PRInt32 nsHTMLContentSinkStream::Write(const nsAReadableString& aString) { nsresult res; PRUnichar *encodedBuffer = nsnull; - res = mEntityConverter->ConvertToEntities(nsPromiseFlatString(aString), + res = mEntityConverter->ConvertToEntities(nsPromiseFlatString(aString).get(), nsIEntityConverter::html40Latin1, &encodedBuffer); if (NS_SUCCEEDED(res) && encodedBuffer) @@ -328,7 +328,7 @@ PRInt32 nsHTMLContentSinkStream::Write(const nsAReadableString& aString) { // Call the converter to convert to the target charset. // Convert() takes a char* output param even though it's writing unicode. - res = mCharsetEncoder->Convert(nsPromiseFlatString(aString), &encodedBuffer); + res = mCharsetEncoder->Convert(nsPromiseFlatString(aString).get(), &encodedBuffer); if (NS_SUCCEEDED(res) && encodedBuffer) { charsWritten = nsCRT::strlen(encodedBuffer); @@ -339,18 +339,16 @@ PRInt32 nsHTMLContentSinkStream::Write(const nsAReadableString& aString) // If it didn't work, just write the unicode else { - const PRUnichar* unicode = nsPromiseFlatString(aString); charsWritten = aString.Length(); - out.write(unicode, charsWritten); + out.write(nsPromiseFlatString(aString).get(), charsWritten); } } // If we couldn't get an encoder, just write the unicode else { - const PRUnichar* unicode = nsPromiseFlatString(aString); charsWritten = aString.Length(); - out.write(unicode, charsWritten); + out.write(nsPromiseFlatString(aString).get(), charsWritten); } return charsWritten; diff --git a/mozilla/htmlparser/src/nsHTMLNullSink.cpp b/mozilla/htmlparser/src/nsHTMLNullSink.cpp index 6156f32cd24..2ff3c2413ab 100644 --- a/mozilla/htmlparser/src/nsHTMLNullSink.cpp +++ b/mozilla/htmlparser/src/nsHTMLNullSink.cpp @@ -134,10 +134,7 @@ static void DebugDump(const char* str1,const nsAReadableString& str2,PRInt32 tab PR_fprintf(PR_STDOUT, " "); //add some tabbing to debug output... } - const char* cp = NS_ConvertUCS2toUTF8(str2); - PR_fprintf(PR_STDOUT, "%s%s>\n", str1, cp); - // should this be deleted? - // delete[] cp; + PR_fprintf(PR_STDOUT, "%s%s>\n", str1, NS_ConvertUCS2toUTF8(str2).get()); } #endif diff --git a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp index 31294b781bb..5ca9f98a74c 100644 --- a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp @@ -580,7 +580,7 @@ nsresult nsHTMLTokenizer::ConsumeAttributes(PRUnichar aChar,CStartToken* aToken, const nsAReadableString& key=theToken->GetKey(); const nsAReadableString& text=theToken->GetValue(); // support XML like syntax to fix bugs like 44186 - if((kForwardSlash==key.CharAt(0)) && (0==text.Length())){ + if((kForwardSlash==key.First()) && (0==text.Length())){ aToken->SetEmpty(PR_TRUE); isUsableAttr=!mDoXMLEmptyTags; } diff --git a/mozilla/htmlparser/src/nsLoggingSink.cpp b/mozilla/htmlparser/src/nsLoggingSink.cpp index 7ea1600cc03..39fcbd13590 100644 --- a/mozilla/htmlparser/src/nsLoggingSink.cpp +++ b/mozilla/htmlparser/src/nsLoggingSink.cpp @@ -708,7 +708,11 @@ nsLoggingSink::LeafNode(const nsIParserNode& aNode) nsresult nsLoggingSink::QuoteText(const nsAReadableString& aValue, nsString& aResult) { aResult.Truncate(); - const PRUnichar* cp = nsPromiseFlatString(aValue); + /* + if you're stepping through the string anyway, why not use iterators instead of forcing the string to copy? + */ + nsPromiseFlatString flat(aValue); + const PRUnichar* cp = flat.get(); const PRUnichar* end = cp + aValue.Length(); while (cp < end) { PRUnichar ch = *cp++; diff --git a/mozilla/htmlparser/src/nsToken.cpp b/mozilla/htmlparser/src/nsToken.cpp index e730e8381f9..c0801b34425 100644 --- a/mozilla/htmlparser/src/nsToken.cpp +++ b/mozilla/htmlparser/src/nsToken.cpp @@ -108,7 +108,7 @@ void CToken::DebugDumpToken(nsOutputStream& anOutputStream) { PRUint32 i=0; PRUint32 theLen=GetStringValue().Length(); for(i=0;i<theLen;i++){ - anOutputStream << (const char*)NS_ConvertUCS2toUTF8(GetStringValue()); + anOutputStream << NS_ConvertUCS2toUTF8(GetStringValue()).get(); } anOutputStream << " TypeID: " << mTypeID << " AttrCount: " << mAttrCount << nsEndl; } @@ -121,7 +121,7 @@ void CToken::DebugDumpToken(nsOutputStream& anOutputStream) { * @param ostream -- output stream to accept output data */ void CToken::DebugDumpSource(nsOutputStream& anOutputStream) { - anOutputStream << (const char*)NS_ConvertUCS2toUTF8(GetStringValue()); + anOutputStream << NS_ConvertUCS2toUTF8(GetStringValue()).get(); } diff --git a/mozilla/intl/locale/src/unix/nsCollationUnix.cpp b/mozilla/intl/locale/src/unix/nsCollationUnix.cpp index 231e2bb584e..597fa04934a 100644 --- a/mozilla/intl/locale/src/unix/nsCollationUnix.cpp +++ b/mozilla/intl/locale/src/unix/nsCollationUnix.cpp @@ -31,7 +31,6 @@ #include "nsIPlatformCharset.h" #include "nsIPosixLocale.h" #include "nsCOMPtr.h" -#include "nsFileSpec.h" /* for nsAutoString */ #include "nsIPref.h" //#define DEBUG_UNIX_COLLATION @@ -87,7 +86,7 @@ nsresult nsCollationUnix::Initialize(nsILocale* locale) PRUnichar *prefValue; res = prefs->GetLocalizedUnicharPref("intl.collationOption", &prefValue); if (NS_SUCCEEDED(res)) { - mUseCodePointOrder = !nsCRT::strcasecmp(prefValue, NS_LITERAL_STRING("useCodePointOrder")); + mUseCodePointOrder = !nsCRT::strcasecmp(prefValue, NS_LITERAL_STRING("useCodePointOrder").get()); nsMemory::Free(prefValue); } } diff --git a/mozilla/intl/uconv/src/nsCharsetMenu.cpp b/mozilla/intl/uconv/src/nsCharsetMenu.cpp index 2a806d0556a..cddb22a5614 100644 --- a/mozilla/intl/uconv/src/nsCharsetMenu.cpp +++ b/mozilla/intl/uconv/src/nsCharsetMenu.cpp @@ -1155,7 +1155,7 @@ nsresult nsCharsetMenu::AddFromPrefsToMenu( if (NS_FAILED(res)) return res; if (value != NULL) { - res = AddFromStringToMenu(NS_ConvertUCS2toUTF8(value), aArray, aContainer, + res = AddFromStringToMenu(NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(value).get()), aArray, aContainer, aDecs, aIDPrefix); nsMemory::Free(value); } @@ -1300,7 +1300,7 @@ nsresult nsCharsetMenu::WriteCacheToPrefs(nsVoidArray * aArray, } // write the pref - res = mPrefService->SetCharPref(aKey, NS_ConvertUCS2toUTF8(cache.GetUnicode())); + res = mPrefService->SetCharPref(aKey, NS_ConvertUCS2toUTF8(cache).get()); return res; } diff --git a/mozilla/layout/generic/nsFrameFrame.cpp b/mozilla/layout/generic/nsFrameFrame.cpp index c81833e1ce6..87cc676893a 100644 --- a/mozilla/layout/generic/nsFrameFrame.cpp +++ b/mozilla/layout/generic/nsFrameFrame.cpp @@ -484,7 +484,7 @@ nsHTMLFrameInnerFrame::~nsHTMLFrameInnerFrame() nsCOMPtr<nsISHistory> hist; webShell->GetSessionHistory(getter_AddRefs(hist)); if (hist) - boxObject->SetPropertyAsSupports(NS_LITERAL_STRING("history"), hist); + boxObject->SetPropertyAsSupports(NS_LITERAL_STRING("history").get(), hist); } } } @@ -908,7 +908,7 @@ static PRBool CheckForBrowser(nsIContent* aContent, nsIBaseWindow* aShell) nsCOMPtr<nsIBrowserBoxObject> browser(do_QueryInterface(boxObject)); if (browser) { nsCOMPtr<nsISupports> supp; - boxObject->GetPropertyAsSupports(NS_LITERAL_STRING("history"), getter_AddRefs(supp)); + boxObject->GetPropertyAsSupports(NS_LITERAL_STRING("history").get(), getter_AddRefs(supp)); if (supp) { nsCOMPtr<nsISHistory> hist(do_QueryInterface(supp)); if (hist) { @@ -916,7 +916,7 @@ static PRBool CheckForBrowser(nsIContent* aContent, nsIBaseWindow* aShell) webNav->SetSessionHistory(hist); nsCOMPtr<nsIWebNavigation> histNav(do_QueryInterface(hist)); histNav->Reload(0); - boxObject->RemoveProperty(NS_LITERAL_STRING("history")); + boxObject->RemoveProperty(NS_LITERAL_STRING("history").get()); return PR_FALSE; } } diff --git a/mozilla/layout/html/document/src/nsFrameFrame.cpp b/mozilla/layout/html/document/src/nsFrameFrame.cpp index c81833e1ce6..87cc676893a 100644 --- a/mozilla/layout/html/document/src/nsFrameFrame.cpp +++ b/mozilla/layout/html/document/src/nsFrameFrame.cpp @@ -484,7 +484,7 @@ nsHTMLFrameInnerFrame::~nsHTMLFrameInnerFrame() nsCOMPtr<nsISHistory> hist; webShell->GetSessionHistory(getter_AddRefs(hist)); if (hist) - boxObject->SetPropertyAsSupports(NS_LITERAL_STRING("history"), hist); + boxObject->SetPropertyAsSupports(NS_LITERAL_STRING("history").get(), hist); } } } @@ -908,7 +908,7 @@ static PRBool CheckForBrowser(nsIContent* aContent, nsIBaseWindow* aShell) nsCOMPtr<nsIBrowserBoxObject> browser(do_QueryInterface(boxObject)); if (browser) { nsCOMPtr<nsISupports> supp; - boxObject->GetPropertyAsSupports(NS_LITERAL_STRING("history"), getter_AddRefs(supp)); + boxObject->GetPropertyAsSupports(NS_LITERAL_STRING("history").get(), getter_AddRefs(supp)); if (supp) { nsCOMPtr<nsISHistory> hist(do_QueryInterface(supp)); if (hist) { @@ -916,7 +916,7 @@ static PRBool CheckForBrowser(nsIContent* aContent, nsIBaseWindow* aShell) webNav->SetSessionHistory(hist); nsCOMPtr<nsIWebNavigation> histNav(do_QueryInterface(hist)); histNav->Reload(0); - boxObject->RemoveProperty(NS_LITERAL_STRING("history")); + boxObject->RemoveProperty(NS_LITERAL_STRING("history").get()); return PR_FALSE; } } diff --git a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp index cd030264d73..77ad1bcb326 100644 --- a/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp +++ b/mozilla/layout/html/forms/src/nsGfxTextControlFrame2.cpp @@ -409,7 +409,7 @@ nsTextInputListener::Blur (nsIDOMEvent* aEvent) } mFrame->GetText(&blurValue,PR_FALSE); - if (mFocusedValue.Compare(blurValue))//different fire onchange + if (Compare(mFocusedValue, blurValue))//different fire onchange { mFocusedValue = blurValue; mFrame->CallOnChange(); diff --git a/mozilla/layout/xul/base/src/nsBoxObject.cpp b/mozilla/layout/xul/base/src/nsBoxObject.cpp index d0f7bec9a3f..d9555aeeb3e 100644 --- a/mozilla/layout/xul/base/src/nsBoxObject.cpp +++ b/mozilla/layout/xul/base/src/nsBoxObject.cpp @@ -32,7 +32,7 @@ #include "nsIContent.h" #include "nsIStyleContext.h" #include "nsIFrame.h" -#include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsILookAndFeel.h" #include "nsWidgetsCID.h" #include "nsIServiceManager.h" @@ -283,16 +283,16 @@ nsBoxObject::GetLookAndFeelMetric(const PRUnichar* aPropertyName, lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ScrollArrowStyle, metricResult); switch (metricResult) { case nsILookAndFeel::eMetric_ScrollArrowStyleBothAtBottom: - *aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("doublebottom")); + *aResult = ToNewUnicode(NS_LITERAL_STRING("doublebottom")); break; case nsILookAndFeel::eMetric_ScrollArrowStyleBothAtEachEnd: - *aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("double")); + *aResult = ToNewUnicode(NS_LITERAL_STRING("double")); break; case nsILookAndFeel::eMetric_ScrollArrowStyleBothAtTop: - *aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("doubletop")); + *aResult = ToNewUnicode(NS_LITERAL_STRING("doubletop")); break; default: - *aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("single")); + *aResult = ToNewUnicode(NS_LITERAL_STRING("single")); break; } } @@ -300,9 +300,9 @@ nsBoxObject::GetLookAndFeelMetric(const PRUnichar* aPropertyName, PRInt32 metricResult; lookAndFeel->GetMetric(nsILookAndFeel::eMetric_ScrollSliderStyle, metricResult); if ( metricResult == nsILookAndFeel::eMetric_ScrollThumbStyleNormal ) - *aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("fixed")); + *aResult = ToNewUnicode(NS_LITERAL_STRING("fixed")); else - *aResult = nsXPIDLString::Copy(NS_LITERAL_STRING("proportional")); + *aResult = ToNewUnicode(NS_LITERAL_STRING("proportional")); } return NS_OK; } @@ -342,7 +342,7 @@ nsBoxObject::GetProperty(const PRUnichar* aPropertyName, PRUnichar** aResult) nsresult rv = mPresState->GetStateProperty(propertyName, result); if (NS_FAILED(rv)) return rv; - *aResult = nsXPIDLString::Copy(result.GetUnicode()); + *aResult = ToNewUnicode(result); return NS_OK; } diff --git a/mozilla/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp b/mozilla/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp index 24a955959fa..bc189c0a9a1 100644 --- a/mozilla/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/outliner/src/nsOutlinerBodyFrame.cpp @@ -832,7 +832,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintRow(int aRowIndex, const nsRect& aRowRec // Now obtain the properties for our row. // XXX Automatically fill in the following props: open, container, selected, focused - PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING("")); + PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING("").get()); mView->GetRowProperties(aRowIndex, mScratchArray); // Resolve style for the row. It contains all the info we need to lay ourselves @@ -887,7 +887,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintCell(int aRowIndex, // Now obtain the properties for our cell. // XXX Automatically fill in the following props: open, container, selected, focused, and the col ID. - PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING("")); + PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING("").get()); mView->GetCellProperties(aRowIndex, aColumn->GetID(), mScratchArray); // Resolve style for the cell. It contains all the info we need to lay ourselves diff --git a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp index 24a955959fa..bc189c0a9a1 100644 --- a/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp +++ b/mozilla/layout/xul/base/src/tree/src/nsTreeBodyFrame.cpp @@ -832,7 +832,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintRow(int aRowIndex, const nsRect& aRowRec // Now obtain the properties for our row. // XXX Automatically fill in the following props: open, container, selected, focused - PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING("")); + PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING("").get()); mView->GetRowProperties(aRowIndex, mScratchArray); // Resolve style for the row. It contains all the info we need to lay ourselves @@ -887,7 +887,7 @@ NS_IMETHODIMP nsOutlinerBodyFrame::PaintCell(int aRowIndex, // Now obtain the properties for our cell. // XXX Automatically fill in the following props: open, container, selected, focused, and the col ID. - PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING("")); + PrefillPropertyArray(aRowIndex, NS_LITERAL_STRING("").get()); mView->GetCellProperties(aRowIndex, aColumn->GetID(), mScratchArray); // Resolve style for the cell. It contains all the info we need to lay ourselves diff --git a/mozilla/mailnews/base/search/src/nsMsgFilter.cpp b/mozilla/mailnews/base/search/src/nsMsgFilter.cpp index 1cfbf49903c..ad3d28e4680 100644 --- a/mozilla/mailnews/base/search/src/nsMsgFilter.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgFilter.cpp @@ -333,7 +333,7 @@ NS_IMETHODIMP nsMsgFilter::MatchHdr(nsIMsgDBHdr *msgHdr, nsIMsgFolder *folder, n nsXPIDLString folderCharset; folder->GetCharset(getter_Copies(folderCharset)); - const char *charset = NS_ConvertUCS2toUTF8(folderCharset); + const char *charset = NS_ConvertUCS2toUTF8(folderCharset).get(); return nsMsgSearchOfflineMail::MatchTermsForFilter(msgHdr, m_termList, charset, scope, diff --git a/mozilla/mailnews/base/search/src/nsMsgFilterList.cpp b/mozilla/mailnews/base/search/src/nsMsgFilterList.cpp index f22b96364f2..fe44e8c191a 100644 --- a/mozilla/mailnews/base/search/src/nsMsgFilterList.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgFilterList.cpp @@ -662,7 +662,7 @@ nsresult nsMsgFilterList::WriteWstrAttr(nsMsgFilterFileAttribValue attrib, const PRUnichar *aFilterName) { - WriteStrAttr(attrib, NS_ConvertUCS2toUTF8(aFilterName)); + WriteStrAttr(attrib, NS_ConvertUCS2toUTF8(aFilterName).get()); return NS_OK; } diff --git a/mozilla/mailnews/base/search/src/nsMsgLocalSearch.cpp b/mozilla/mailnews/base/search/src/nsMsgLocalSearch.cpp index 8ee877b04e6..b080aaf670b 100644 --- a/mozilla/mailnews/base/search/src/nsMsgLocalSearch.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgLocalSearch.cpp @@ -687,7 +687,7 @@ nsresult nsMsgSearchOfflineMail::Search (PRBool *aDone) PRBool match = PR_FALSE; nsAutoString nullCharset, folderCharset; GetSearchCharsets(nullCharset, folderCharset); - const char *charset = NS_ConvertUCS2toUTF8(folderCharset); + const char *charset = NS_ConvertUCS2toUTF8(folderCharset).get(); // Is this message a hit? err = MatchTermsForSearch (msgDBHdr, m_searchTerms, charset, m_scope, m_db, &match); diff --git a/mozilla/mailnews/base/src/nsMsgMessageDataSource.cpp b/mozilla/mailnews/base/src/nsMsgMessageDataSource.cpp index 6cf580ee5cc..738e7872aab 100644 --- a/mozilla/mailnews/base/src/nsMsgMessageDataSource.cpp +++ b/mozilla/mailnews/base/src/nsMsgMessageDataSource.cpp @@ -429,7 +429,7 @@ nsresult nsMsgMessageDataSource::GetSenderName(const PRUnichar *sender, nsAutoSt nsXPIDLCString name; - rv = mHeaderParser->ExtractHeaderAddressName("UTF-8", NS_ConvertUCS2toUTF8(sender), getter_Copies(name)); + rv = mHeaderParser->ExtractHeaderAddressName("UTF-8", NS_ConvertUCS2toUTF8(sender).get(), getter_Copies(name)); if (NS_SUCCEEDED(rv) && (const char*)name) senderUserName.Assign(NS_ConvertUTF8toUCS2(name)); } diff --git a/mozilla/mailnews/base/util/nsMsgI18N.cpp b/mozilla/mailnews/base/util/nsMsgI18N.cpp index 82cb8492edf..9ac9f182c34 100644 --- a/mozilla/mailnews/base/util/nsMsgI18N.cpp +++ b/mozilla/mailnews/base/util/nsMsgI18N.cpp @@ -428,7 +428,7 @@ char * nsMsgI18NGetDefaultMailCharset() if (NS_SUCCEEDED(res)) { //TODO: map to mail charset (e.g. Shift_JIS -> ISO-2022-JP) bug#3941. - retVal = nsCRT::strdup(NS_ConvertUCS2toUTF8(prefValue)); + retVal = NS_ConvertUCS2toUTF8(prefValue).ToNewCString(); nsMemory::Free(prefValue); } else @@ -737,7 +737,7 @@ nsMsgI18NGetAcceptLanguage(void) res = prefs->GetLocalizedUnicharPref("intl.accept_languages", getter_Copies(prefValue)); if (NS_SUCCEEDED(res) && prefValue) { - PL_strncpy(lang, NS_ConvertUCS2toUTF8(prefValue), sizeof(lang)); + PL_strncpy(lang, NS_ConvertUCS2toUTF8(prefValue).get(), sizeof(lang)); } else PL_strcpy(lang, "en"); diff --git a/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp b/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp index f40f41cd5f5..b0b68324738 100644 --- a/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp +++ b/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp @@ -1192,8 +1192,8 @@ NS_IMETHODIMP nsMsgIncomingServer::DisplayOfflineMsg(nsIMsgWindow *aMsgWindow) nsXPIDLString errorMsgTitle; nsXPIDLString errorMsgBody; - bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodybody"), getter_Copies(errorMsgBody)); - bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodytitle"), getter_Copies(errorMsgTitle)); + bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodybody").get(), getter_Copies(errorMsgBody)); + bundle->GetStringFromName(NS_LITERAL_STRING("nocachedbodytitle").get(), getter_Copies(errorMsgTitle)); if (aMsgWindow) return aMsgWindow->DisplayHTMLInMessagePane(errorMsgTitle, errorMsgBody); else diff --git a/mozilla/mailnews/compose/src/nsMsgCompose.cpp b/mozilla/mailnews/compose/src/nsMsgCompose.cpp index f84657b7a46..69a97ba422a 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompose.cpp @@ -515,7 +515,7 @@ nsresult nsMsgCompose::_SendMsg(MSG_DeliverMode deliverMode, nsIMsgIdentity *ide nsCOMPtr<nsIMsgHeaderParser> parser (do_GetService(kHeaderParserCID)); if (parser) { // convert to UTF8 before passing to MakeFullAddress - parser->MakeFullAddress(nsnull, NS_ConvertUCS2toUTF8(fullName), email, &sender); + parser->MakeFullAddress(nsnull, NS_ConvertUCS2toUTF8(fullName).get(), email, &sender); } if (!sender) @@ -1542,7 +1542,7 @@ nsresult nsMsgCompose::ProcessReplyFlags() if (rdfService && !mOriginalMsgURI.IsEmpty()) { nsCOMPtr<nsIRDFResource> resource; - rdfService->GetResource(NS_ConvertUCS2toUTF8(mOriginalMsgURI), getter_AddRefs(resource)); + rdfService->GetResource(NS_ConvertUCS2toUTF8(mOriginalMsgURI).get(), getter_AddRefs(resource)); nsCOMPtr<nsIMessage> messageResource (do_QueryInterface(resource)); if (messageResource) { diff --git a/mozilla/mailnews/import/src/nsImportFieldMap.cpp b/mozilla/mailnews/import/src/nsImportFieldMap.cpp index 9e199b27ed1..854c3ffaaed 100644 --- a/mozilla/mailnews/import/src/nsImportFieldMap.cpp +++ b/mozilla/mailnews/import/src/nsImportFieldMap.cpp @@ -575,7 +575,7 @@ PRInt32 nsImportFieldMap::FindFieldNum( const PRUnichar *pDesc) nsString * pStr; for (PRInt32 i = 0; i < m_mozFieldCount; i++) { pStr = (nsString *)m_descriptions.ElementAt( i); - if (!pStr->Compare( nsAutoString(pDesc))) + if (!Compare(*pStr, nsAutoString(pDesc))) return( i); } diff --git a/mozilla/mailnews/import/text/src/nsTextImport.cpp b/mozilla/mailnews/import/text/src/nsTextImport.cpp index a1148d294f1..e69d3c43a07 100644 --- a/mozilla/mailnews/import/text/src/nsTextImport.cpp +++ b/mozilla/mailnews/import/text/src/nsTextImport.cpp @@ -785,7 +785,7 @@ void ImportAddressImpl::SaveFieldMap( nsIImportFieldMap *pMap) nsXPIDLCString prefStr; rv = prefs->CopyCharPref( "mailnews.import.text.fieldmap", getter_Copies(prefStr)); if (NS_SUCCEEDED( rv)) { - if (!str.Compare( nsCAutoString((const char *)prefStr))) + if (!Compare(str, nsCAutoString((const char *)prefStr))) done = PR_TRUE; } if (!done) { diff --git a/mozilla/mailnews/local/src/nsLocalMailFolder.cpp b/mozilla/mailnews/local/src/nsLocalMailFolder.cpp index 3404cac7e06..08bd002c396 100644 --- a/mozilla/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mozilla/mailnews/local/src/nsLocalMailFolder.cpp @@ -250,7 +250,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::AddSubfolder(nsAutoString *name, // URI should use UTF-8 // (see RFC2396 Uniform Resource Identifiers (URI): Generic Syntax) - char *escapedName = nsEscape(NS_ConvertUCS2toUTF8(name->GetUnicode()), url_Path); + char *escapedName = nsEscape(NS_ConvertUCS2toUTF8(*name).get(), url_Path); if (escapedName) { uri.Append(escapedName); @@ -1762,7 +1762,7 @@ nsMsgLocalMailFolder::CopyFolderAcrossServer(nsIMsgFolder *destFolder, nsIMsgFol rv = destFolder->CreateSubfolder(folderName,msgWindow); if (NS_FAILED(rv)) return rv; - destFolder->FindSubFolder(NS_ConvertUCS2toUTF8(folderName.get()), getter_AddRefs(newFolder)); + destFolder->FindSubFolder(NS_ConvertUCS2toUTF8(folderName.get()).get(), getter_AddRefs(newFolder)); newMsgFolder = do_QueryInterface(newFolder,&rv); @@ -3014,7 +3014,7 @@ nsMsgLocalMailFolder::setSubfolderFlag(PRUnichar* aFolderName, nsresult rv; nsCOMPtr<nsIFolder> folder; - rv = FindSubFolder(NS_ConvertUCS2toUTF8(aFolderName), getter_AddRefs(folder)); + rv = FindSubFolder(NS_ConvertUCS2toUTF8(aFolderName).get(), getter_AddRefs(folder)); if (NS_FAILED(rv)) return rv; if (!folder) return NS_ERROR_FAILURE; diff --git a/mozilla/mailnews/mime/src/comi18n.cpp b/mozilla/mailnews/mime/src/comi18n.cpp index 4fd36e98674..73768bdf40f 100644 --- a/mozilla/mailnews/mime/src/comi18n.cpp +++ b/mozilla/mailnews/mime/src/comi18n.cpp @@ -1352,11 +1352,11 @@ PRInt32 MimeCharsetConverterClass::Initialize(const char* from_charset, const ch NS_WITH_SERVICE(nsIPref, prefs, kPrefCID, &res); if (NS_SUCCEEDED(res)) { if (NS_SUCCEEDED(prefs->CopyUnicharPref("mail.charset.detector", &detector_name))) { - PL_strcat(detector_contractid, NS_ConvertUCS2toUTF8(detector_name)); + PL_strcat(detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get()); PR_FREEIF(detector_name); } else if (NS_SUCCEEDED(prefs->GetLocalizedUnicharPref("intl.charset.detector", &detector_name))) { - PL_strcat(detector_contractid, NS_ConvertUCS2toUTF8(detector_name)); + PL_strcat(detector_contractid, NS_ConvertUCS2toUTF8(detector_name).get()); PR_FREEIF(detector_name); } } diff --git a/mozilla/mailnews/mime/src/mimetext.cpp b/mozilla/mailnews/mime/src/mimetext.cpp index 1b517db21cb..141d3ebb3ac 100644 --- a/mozilla/mailnews/mime/src/mimetext.cpp +++ b/mozilla/mailnews/mime/src/mimetext.cpp @@ -118,7 +118,7 @@ MimeInlineText_initialize (MimeObject *obj) PRUnichar* value; rv = prefs->GetLocalizedUnicharPref("mailnews.view_default_charset", &value); if(NS_SUCCEEDED(rv)) { - text->defaultCharset = nsCRT::strdup(NS_ConvertUCS2toUTF8(value)); + text->defaultCharset = NS_ConvertUCS2toUTF8(value).ToNewCString(); nsMemory::Free(value); } } diff --git a/mozilla/mailnews/mime/src/nsMimeConverter.cpp b/mozilla/mailnews/mime/src/nsMimeConverter.cpp index 1de9df4d545..9330d3f7c37 100644 --- a/mozilla/mailnews/mime/src/nsMimeConverter.cpp +++ b/mozilla/mailnews/mime/src/nsMimeConverter.cpp @@ -125,7 +125,7 @@ nsMimeConverter::DecodeMimePartIIStr(const nsString& header, mCharsetConverterManager = do_GetService(NS_CHARSETCONVERTERMANAGER_CONTRACTID, &res); if (NS_SUCCEEDED(res)) { nsCOMPtr <nsIAtom> charsetAtom; - res = mCharsetConverterManager->GetCharsetAtom(NS_ConvertASCIItoUCS2(charsetCstr), getter_AddRefs(charsetAtom)); + res = mCharsetConverterManager->GetCharsetAtom(NS_ConvertASCIItoUCS2(charsetCstr).get(), getter_AddRefs(charsetAtom)); if (NS_SUCCEEDED(res)) { if (charsetAtom != mDecoderCharsetAtom) { mDecoderCharsetAtom = charsetAtom; diff --git a/mozilla/mailnews/mime/src/nsStreamConverter.cpp b/mozilla/mailnews/mime/src/nsStreamConverter.cpp index c82ade51227..6a63fedc819 100644 --- a/mozilla/mailnews/mime/src/nsStreamConverter.cpp +++ b/mozilla/mailnews/mime/src/nsStreamConverter.cpp @@ -188,7 +188,7 @@ bridge_new_new_uri(void *bridgeStream, nsIURI *aURI, PRInt32 aOutputType) nsCOMPtr<nsIMsgWindow> msgWindow; msgurl->GetMsgWindow(getter_AddRefs(msgWindow)); if (msgWindow) - msgWindow->SetMailCharacterSet(NS_ConvertASCIItoUCS2(*default_charset)); + msgWindow->SetMailCharacterSet(NS_ConvertASCIItoUCS2(*default_charset).get()); } // if the pref says always override and no manual override then set the folder charset to override diff --git a/mozilla/mailnews/news/src/nsNNTPNewsgroupList.cpp b/mozilla/mailnews/news/src/nsNNTPNewsgroupList.cpp index 9a4c300f2ee..fe1dac5509f 100644 --- a/mozilla/mailnews/news/src/nsNNTPNewsgroupList.cpp +++ b/mozilla/mailnews/news/src/nsNNTPNewsgroupList.cpp @@ -351,7 +351,7 @@ nsNNTPNewsgroupList::GetRangeOfArtsToDownload(nsIMsgWindow * aMsgWindow, rv = bundleService->CreateBundle(NEWS_MSGS_URL, nsnull, getter_AddRefs(bundle)); NS_ENSURE_SUCCESS(rv, rv); - rv = bundle->GetStringFromName(NS_LITERAL_STRING("noNewMessages"), getter_Copies(statusString)); + rv = bundle->GetStringFromName(NS_LITERAL_STRING("noNewMessages").get(), getter_Copies(statusString)); NS_ENSURE_SUCCESS(rv, rv); SetProgressStatus(statusString); } @@ -883,7 +883,7 @@ nsNNTPNewsgroupList::ProcessXOVERLINE(const char *line, PRUint32 *status) NS_ENSURE_SUCCESS(rv, rv); const PRUnichar *formatStrings[2] = { numDownloadedStr.GetUnicode(), totalToDownloadStr.GetUnicode() }; - rv = bundle->FormatStringFromName(NS_LITERAL_STRING("downloadingHeaders"), formatStrings, 2, getter_Copies(statusString)); + rv = bundle->FormatStringFromName(NS_LITERAL_STRING("downloadingHeaders").get(), formatStrings, 2, getter_Copies(statusString)); NS_ENSURE_SUCCESS(rv, rv); SetProgressStatus(statusString); @@ -985,7 +985,7 @@ nsNNTPNewsgroupList::FinishXOVERLINE(int status, int *newstatus) NS_ENSURE_SUCCESS(rv, rv); const PRUnichar *formatStrings[2] = { firstStr.GetUnicode(), lastStr.GetUnicode() }; - rv = bundle->FormatStringFromName(NS_LITERAL_STRING("downloadingArticles"), formatStrings, 2, getter_Copies(statusString)); + rv = bundle->FormatStringFromName(NS_LITERAL_STRING("downloadingArticles").get(), formatStrings, 2, getter_Copies(statusString)); NS_ENSURE_SUCCESS(rv, rv); SetProgressStatus(statusString); diff --git a/mozilla/mailnews/news/src/nsNNTPProtocol.cpp b/mozilla/mailnews/news/src/nsNNTPProtocol.cpp index 74a210561e1..0ba8fdea7ab 100644 --- a/mozilla/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mozilla/mailnews/news/src/nsNNTPProtocol.cpp @@ -3258,7 +3258,7 @@ PRInt32 nsNNTPProtocol::ReadNewsList(nsIInputStream * inputStream, PRUint32 leng numGroupsStr.AppendInt(mNumGroupsListed); const PRUnichar *formatStrings[3] = { numGroupsStr.GetUnicode(), bytesStr.GetUnicode(), rateStr.GetUnicode() }; - rv = bundle->FormatStringFromName(NS_LITERAL_STRING("bytesReceived"), + rv = bundle->FormatStringFromName(NS_LITERAL_STRING("bytesReceived").get(), formatStrings, 3, getter_Copies(statusString)); @@ -3962,7 +3962,7 @@ nsNNTPProtocol::SetCheckingForNewNewsStatus(PRInt32 current, PRInt32 total) const PRUnichar *formatStrings[] = { thisGroupStr.GetUnicode(),totalGroupStr.GetUnicode() }; - rv = bundle->FormatStringFromName(NS_LITERAL_STRING("checkingForNewNews"), + rv = bundle->FormatStringFromName(NS_LITERAL_STRING("checkingForNewNews").get(), formatStrings, 2, getter_Copies(statusString)); NS_ENSURE_SUCCESS(rv, rv); diff --git a/mozilla/modules/libpref/src/nsPref.cpp b/mozilla/modules/libpref/src/nsPref.cpp index 9720b577e11..0a613b9f440 100644 --- a/mozilla/modules/libpref/src/nsPref.cpp +++ b/mozilla/modules/libpref/src/nsPref.cpp @@ -390,7 +390,7 @@ nsresult nsPref::useLockPrefFile() if (NS_SUCCEEDED(rv = GetLocalizedUnicharPref("browser.startup.homepage", getter_Copies(prefVal)) && (prefVal))) { - printf("\nStartup homepage %s \n", (const char *)NS_ConvertUCS2toUTF8(prefVal)); + printf("\nStartup homepage %s \n", NS_ConvertUCS2toUTF8(prefVal).get()); } #endif @@ -516,7 +516,7 @@ nsresult nsPref::useLockPrefFile() } #ifdef DEBUG_tao GetLocalizedUnicharPref("browser.startup.homepage",getter_Copies(prefVal)); - printf("\nStartup homepage %s \n", (const char *)NS_ConvertUCS2toUTF8(prefVal)); + printf("\nStartup homepage %s \n", NS_ConvertUCS2toUTF8(prefVal).get()); #endif } return rv; @@ -637,8 +637,8 @@ static int PR_CALLBACK NotifyObserver(const char *newpref, void *data) { nsCOMPtr<nsIObserver> observer = NS_STATIC_CAST(nsIObserver *, data); - observer->Observe(observer, NS_LITERAL_STRING("nsPref:changed"), - NS_ConvertASCIItoUCS2(newpref)); + observer->Observe(observer, NS_LITERAL_STRING("nsPref:changed").get(), + NS_ConvertASCIItoUCS2(newpref).get()); return 0; } @@ -815,7 +815,7 @@ NS_IMETHODIMP nsPref::SetCharPref(const char *pref,const char* value) NS_IMETHODIMP nsPref::SetUnicharPref(const char *pref, const PRUnichar *value) { if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE; - return SetCharPref(pref, NS_ConvertUCS2toUTF8(value)); + return SetCharPref(pref, NS_ConvertUCS2toUTF8(value).get()); } NS_IMETHODIMP nsPref::SetIntPref(const char *pref,PRInt32 value) @@ -878,7 +878,7 @@ NS_IMETHODIMP nsPref::SetDefaultUnicharPref(const char *pref, const PRUnichar *value) { if (NS_FAILED(SecurePrefCheck(pref))) return NS_ERROR_FAILURE; - return SetDefaultCharPref(pref, NS_ConvertUCS2toUTF8(value)); + return SetDefaultCharPref(pref, NS_ConvertUCS2toUTF8(value).get()); } NS_IMETHODIMP nsPref::SetDefaultIntPref(const char *pref,PRInt32 value) diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 3412ca90aa5..c15a5249355 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -4202,19 +4202,19 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary) PRUnichar *message = nsnull; PRUnichar *checkboxMessage = nsnull; - rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginTitle"), + rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginTitle").get(), &title); if (NS_FAILED(rv)) return rv; - rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginMessage"), + rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginMessage").get(), &message); if (NS_FAILED(rv)) { nsMemory::Free((void *)title); return rv; } - rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginCheckboxMessage"), + rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginCheckboxMessage").get(), &checkboxMessage); if (NS_FAILED(rv)) { diff --git a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp index 3412ca90aa5..c15a5249355 100644 --- a/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/nglsrc/nsPluginHostImpl.cpp @@ -4202,19 +4202,19 @@ NS_IMETHODIMP nsPluginHostImpl::HandleBadPlugin(PRLibrary* aLibrary) PRUnichar *message = nsnull; PRUnichar *checkboxMessage = nsnull; - rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginTitle"), + rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginTitle").get(), &title); if (NS_FAILED(rv)) return rv; - rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginMessage"), + rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginMessage").get(), &message); if (NS_FAILED(rv)) { nsMemory::Free((void *)title); return rv; } - rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginCheckboxMessage"), + rv = bundle->GetStringFromName(NS_LITERAL_STRING("BadPluginCheckboxMessage").get(), &checkboxMessage); if (NS_FAILED(rv)) { diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index 22262939c5a..2b0f30ec00c 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -354,8 +354,8 @@ nsIOService::SetOffline(PRBool offline) // don't care if notification fails if (observerService) (void)observerService->Notify(this, - NS_LITERAL_STRING("network:offline-status-changed"), - NS_LITERAL_STRING("offline")); + NS_LITERAL_STRING("network:offline-status-changed").get(), + NS_LITERAL_STRING("offline").get()); } else if (!offline && mOffline) { // go online @@ -371,8 +371,8 @@ nsIOService::SetOffline(PRBool offline) // don't care if notification fails if (observerService) (void)observerService->Notify(this, - NS_LITERAL_STRING("network:offline-status-changed"), - NS_LITERAL_STRING("online")); + NS_LITERAL_STRING("network:offline-status-changed").get(), + NS_LITERAL_STRING("online").get()); } return NS_OK; } diff --git a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp index 1878ff72ed4..c62ad839b72 100644 --- a/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp +++ b/mozilla/netwerk/protocol/http/src/nsHTTPHandler.cpp @@ -693,7 +693,7 @@ nsHTTPHandler::InitUserAgentComponents() rv = mPrefs->GetLocalizedUnicharPref(UA_PREF_PREFIX "locale", getter_Copies(uval)); if (NS_SUCCEEDED(rv)) - mAppLanguage = (const char*) NS_ConvertUCS2toUTF8(uval); + mAppLanguage = NS_ConvertUCS2toUTF8(uval); // Gather platform. #if defined(XP_OS2) mAppPlatform = "OS/2"; @@ -1474,7 +1474,7 @@ nsHTTPHandler::PrefsChanged(const char* pref) rv = mPrefs->GetLocalizedUnicharPref(INTL_ACCEPT_LANGUAGES, getter_Copies(acceptLanguages)); if (NS_SUCCEEDED(rv)) - SetAcceptLanguages(NS_ConvertUCS2toUTF8(acceptLanguages)); + SetAcceptLanguages(NS_ConvertUCS2toUTF8(acceptLanguages).get()); #if defined(DEBUG_tao_) printf("\n--> nsHTTPHandler::PrefsChanged: intl.accept_languages=%s\n", (const char *)NS_ConvertUCS2toUTF8(acceptLanguages)); @@ -1499,11 +1499,11 @@ nsHTTPHandler::PrefsChanged(const char* pref) rv = mPrefs->GetLocalizedUnicharPref(UA_PREF_PREFIX "locale", getter_Copies(uval)); if (NS_SUCCEEDED(rv)) { - mAppLanguage = (const char*) NS_ConvertUCS2toUTF8(uval); + mAppLanguage = NS_ConvertUCS2toUTF8(uval); // #if defined(DEBUG_tao_) printf("\n--> nsHTTPHandler::PrefsChanged:general.useragent.locale=%s\n", - (const char*) NS_ConvertUCS2toUTF8(uval)); + NS_ConvertUCS2toUTF8(uval).get()); #endif BuildUserAgent(); } diff --git a/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp b/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp index 86c18e25fff..52181f26436 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp @@ -289,7 +289,7 @@ PRInt32 nsHTMLContentSinkStream::Write(const nsAReadableString& aString) { nsresult res; PRUnichar *encodedBuffer = nsnull; - res = mEntityConverter->ConvertToEntities(nsPromiseFlatString(aString), + res = mEntityConverter->ConvertToEntities(nsPromiseFlatString(aString).get(), nsIEntityConverter::html40Latin1, &encodedBuffer); if (NS_SUCCEEDED(res) && encodedBuffer) @@ -328,7 +328,7 @@ PRInt32 nsHTMLContentSinkStream::Write(const nsAReadableString& aString) { // Call the converter to convert to the target charset. // Convert() takes a char* output param even though it's writing unicode. - res = mCharsetEncoder->Convert(nsPromiseFlatString(aString), &encodedBuffer); + res = mCharsetEncoder->Convert(nsPromiseFlatString(aString).get(), &encodedBuffer); if (NS_SUCCEEDED(res) && encodedBuffer) { charsWritten = nsCRT::strlen(encodedBuffer); @@ -339,18 +339,16 @@ PRInt32 nsHTMLContentSinkStream::Write(const nsAReadableString& aString) // If it didn't work, just write the unicode else { - const PRUnichar* unicode = nsPromiseFlatString(aString); charsWritten = aString.Length(); - out.write(unicode, charsWritten); + out.write(nsPromiseFlatString(aString).get(), charsWritten); } } // If we couldn't get an encoder, just write the unicode else { - const PRUnichar* unicode = nsPromiseFlatString(aString); charsWritten = aString.Length(); - out.write(unicode, charsWritten); + out.write(nsPromiseFlatString(aString).get(), charsWritten); } return charsWritten; diff --git a/mozilla/parser/htmlparser/src/nsHTMLNullSink.cpp b/mozilla/parser/htmlparser/src/nsHTMLNullSink.cpp index 6156f32cd24..2ff3c2413ab 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLNullSink.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLNullSink.cpp @@ -134,10 +134,7 @@ static void DebugDump(const char* str1,const nsAReadableString& str2,PRInt32 tab PR_fprintf(PR_STDOUT, " "); //add some tabbing to debug output... } - const char* cp = NS_ConvertUCS2toUTF8(str2); - PR_fprintf(PR_STDOUT, "%s%s>\n", str1, cp); - // should this be deleted? - // delete[] cp; + PR_fprintf(PR_STDOUT, "%s%s>\n", str1, NS_ConvertUCS2toUTF8(str2).get()); } #endif diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp index 31294b781bb..5ca9f98a74c 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp @@ -580,7 +580,7 @@ nsresult nsHTMLTokenizer::ConsumeAttributes(PRUnichar aChar,CStartToken* aToken, const nsAReadableString& key=theToken->GetKey(); const nsAReadableString& text=theToken->GetValue(); // support XML like syntax to fix bugs like 44186 - if((kForwardSlash==key.CharAt(0)) && (0==text.Length())){ + if((kForwardSlash==key.First()) && (0==text.Length())){ aToken->SetEmpty(PR_TRUE); isUsableAttr=!mDoXMLEmptyTags; } diff --git a/mozilla/parser/htmlparser/src/nsLoggingSink.cpp b/mozilla/parser/htmlparser/src/nsLoggingSink.cpp index 7ea1600cc03..39fcbd13590 100644 --- a/mozilla/parser/htmlparser/src/nsLoggingSink.cpp +++ b/mozilla/parser/htmlparser/src/nsLoggingSink.cpp @@ -708,7 +708,11 @@ nsLoggingSink::LeafNode(const nsIParserNode& aNode) nsresult nsLoggingSink::QuoteText(const nsAReadableString& aValue, nsString& aResult) { aResult.Truncate(); - const PRUnichar* cp = nsPromiseFlatString(aValue); + /* + if you're stepping through the string anyway, why not use iterators instead of forcing the string to copy? + */ + nsPromiseFlatString flat(aValue); + const PRUnichar* cp = flat.get(); const PRUnichar* end = cp + aValue.Length(); while (cp < end) { PRUnichar ch = *cp++; diff --git a/mozilla/parser/htmlparser/src/nsToken.cpp b/mozilla/parser/htmlparser/src/nsToken.cpp index e730e8381f9..c0801b34425 100644 --- a/mozilla/parser/htmlparser/src/nsToken.cpp +++ b/mozilla/parser/htmlparser/src/nsToken.cpp @@ -108,7 +108,7 @@ void CToken::DebugDumpToken(nsOutputStream& anOutputStream) { PRUint32 i=0; PRUint32 theLen=GetStringValue().Length(); for(i=0;i<theLen;i++){ - anOutputStream << (const char*)NS_ConvertUCS2toUTF8(GetStringValue()); + anOutputStream << NS_ConvertUCS2toUTF8(GetStringValue()).get(); } anOutputStream << " TypeID: " << mTypeID << " AttrCount: " << mAttrCount << nsEndl; } @@ -121,7 +121,7 @@ void CToken::DebugDumpToken(nsOutputStream& anOutputStream) { * @param ostream -- output stream to accept output data */ void CToken::DebugDumpSource(nsOutputStream& anOutputStream) { - anOutputStream << (const char*)NS_ConvertUCS2toUTF8(GetStringValue()); + anOutputStream << NS_ConvertUCS2toUTF8(GetStringValue()).get(); } diff --git a/mozilla/profile/src/nsProfile.cpp b/mozilla/profile/src/nsProfile.cpp index e734600f81c..65e0ed0ffbc 100644 --- a/mozilla/profile/src/nsProfile.cpp +++ b/mozilla/profile/src/nsProfile.cpp @@ -1314,7 +1314,7 @@ nsProfile::CreateNewProfile(const PRUnichar* profileName, nsFileURL fileURL(fileSpec); const char* fileStr = fileURL.GetURLString(); rv = chromeRegistry->SelectLocaleForProfile(langcode, - NS_ConvertUTF8toUCS2(fileStr)); + NS_ConvertUTF8toUCS2(fileStr).get()); } } // Copy contents from defaults folder. @@ -1707,7 +1707,7 @@ nsProfile::DefineLocaleDefaultsDir() if (NS_SUCCEEDED(rv)) { nsXPIDLString localeName; - rv = chromeRegistry->GetSelectedLocale(NS_LITERAL_STRING("global-region"), getter_Copies(localeName)); + rv = chromeRegistry->GetSelectedLocale(NS_LITERAL_STRING("global-region").get(), getter_Copies(localeName)); if (NS_SUCCEEDED(rv)) rv = localeDefaults->AppendUnicode(localeName); } diff --git a/mozilla/profile/src/nsProfileAccess.cpp b/mozilla/profile/src/nsProfileAccess.cpp index 71f19133b5e..ab907817044 100644 --- a/mozilla/profile/src/nsProfileAccess.cpp +++ b/mozilla/profile/src/nsProfileAccess.cpp @@ -375,13 +375,13 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName) nsRegistryKey profilesTreeKey; rv = registry->GetKey(nsIRegistry::Common, - kRegistryProfileSubtreeString, + kRegistryProfileSubtreeString.get(), &profilesTreeKey); if (NS_FAILED(rv)) { rv = registry->AddKey(nsIRegistry::Common, - kRegistryProfileSubtreeString, + kRegistryProfileSubtreeString.get(), &profilesTreeKey); if (NS_FAILED(rv)) return rv; } @@ -401,7 +401,7 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName) // Get the current profile rv = registry->GetString(profilesTreeKey, - kRegistryCurrentProfileString, + kRegistryCurrentProfileString.get(), getter_Copies(tmpCurrentProfile)); if (tmpCurrentProfile) @@ -418,7 +418,7 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName) // Get the profile version rv = registry->GetString(profilesTreeKey, - kRegistryVersionString, + kRegistryVersionString.get(), getter_Copies(tmpVersion)); if (tmpVersion == nsnull) @@ -429,7 +429,7 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName) // Get the preg info rv = registry->GetString(profilesTreeKey, - kRegistryHavePREGInfoString, + kRegistryHavePREGInfoString.get(), getter_Copies(tmpPREGInfo)); if (tmpPREGInfo == nsnull) @@ -479,7 +479,7 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName) if (NS_FAILED(rv)) return rv; rv = registry->GetString(profKey, - kRegistryMigratedString, + kRegistryMigratedString.get(), getter_Copies(isMigrated)); if (NS_FAILED(rv)) return rv; nsLiteralString isMigratedString(isMigrated); @@ -488,19 +488,19 @@ nsProfileAccess::FillProfileInfo(nsIFile* regName) // are for activation, they are optional and their values // do not call for a return registry->GetString(profKey, - kRegistryNCProfileNameString, + kRegistryNCProfileNameString.get(), getter_Copies(NCProfileName)); registry->GetString(profKey, - kRegistryNCServiceDenialString, + kRegistryNCServiceDenialString.get(), getter_Copies(NCDeniedService)); registry->GetString(profKey, - kRegistryNCUserEmailString, + kRegistryNCUserEmailString.get(), getter_Copies(NCEmailAddress)); registry->GetString(profKey, - kRegistryNCHavePREGInfoString, + kRegistryNCHavePREGInfoString.get(), getter_Copies(NCHavePregInfo)); // Make sure that mCurrentProfile is valid @@ -763,7 +763,7 @@ nsProfileAccess::UpdateRegistry(nsIFile* regName) // Get the major subtree rv = registry->GetKey(nsIRegistry::Common, - kRegistryProfileSubtreeString, + kRegistryProfileSubtreeString.get(), &profilesTreeKey); if (NS_FAILED(rv)) return rv; @@ -771,20 +771,20 @@ nsProfileAccess::UpdateRegistry(nsIFile* regName) if (!mCurrentProfile.IsEmpty()) { rv = registry->SetString(profilesTreeKey, - kRegistryCurrentProfileString, + kRegistryCurrentProfileString.get(), mCurrentProfile.GetUnicode()); if (NS_FAILED(rv)) return rv; } // Set the registry version rv = registry->SetString(profilesTreeKey, - kRegistryVersionString, - kRegistryCurrentVersion); + kRegistryVersionString.get(), + kRegistryCurrentVersion.get()); if (NS_FAILED(rv)) return rv; // Set preg info rv = registry->SetString(profilesTreeKey, - kRegistryHavePREGInfoString, + kRegistryHavePREGInfoString.get(), mHavePREGInfo.GetUnicode()); if (NS_FAILED(rv)) return rv; @@ -836,24 +836,24 @@ nsProfileAccess::UpdateRegistry(nsIFile* regName) if (NS_FAILED(rv)) return rv; rv = registry->SetString(profKey, - kRegistryMigratedString, - profileItem->isMigrated ? kRegistryYesString : kRegistryNoString); + kRegistryMigratedString.get(), + profileItem->isMigrated ? kRegistryYesString.get() : kRegistryNoString.get()); if (NS_FAILED(rv)) return rv; registry->SetString(profKey, - kRegistryNCProfileNameString, + kRegistryNCProfileNameString.get(), profileItem->NCProfileName.GetUnicode()); registry->SetString(profKey, - kRegistryNCServiceDenialString, + kRegistryNCServiceDenialString.get(), profileItem->NCDeniedService.GetUnicode()); registry->SetString(profKey, - kRegistryNCUserEmailString, + kRegistryNCUserEmailString.get(), profileItem->NCEmailAddress.GetUnicode()); registry->SetString(profKey, - kRegistryNCHavePREGInfoString, + kRegistryNCHavePREGInfoString.get(), profileItem->NCHavePregInfo.GetUnicode()); rv = profileItem->ExternalizeLocation(registry, profKey); @@ -885,24 +885,24 @@ nsProfileAccess::UpdateRegistry(nsIFile* regName) if (NS_FAILED(rv)) return rv; rv = registry->SetString(profKey, - kRegistryMigratedString, - profileItem->isMigrated ? kRegistryYesString : kRegistryNoString); + kRegistryMigratedString.get(), + profileItem->isMigrated ? kRegistryYesString.get() : kRegistryNoString.get()); if (NS_FAILED(rv)) return rv; registry->SetString(profKey, - kRegistryNCProfileNameString, + kRegistryNCProfileNameString.get(), profileItem->NCProfileName.GetUnicode()); registry->SetString(profKey, - kRegistryNCServiceDenialString, + kRegistryNCServiceDenialString.get(), profileItem->NCDeniedService.GetUnicode()); registry->SetString(profKey, - kRegistryNCUserEmailString, + kRegistryNCUserEmailString.get(), profileItem->NCEmailAddress.GetUnicode()); registry->SetString(profKey, - kRegistryNCHavePREGInfoString, + kRegistryNCHavePREGInfoString.get(), profileItem->NCHavePregInfo.GetUnicode()); rv = profileItem->ExternalizeLocation(registry, profKey); @@ -1286,13 +1286,13 @@ nsProfileAccess::GetMozRegDataMovedFlag(PRBool *isDataMoved) if (NS_FAILED(rv)) return rv; rv = registry->GetKey(nsIRegistry::Common, - kRegistryProfileSubtreeString, + kRegistryProfileSubtreeString.get(), &profilesTreeKey); if (NS_SUCCEEDED(rv)) { rv = registry->GetString(profilesTreeKey, - kRegistryMozRegDataMovedString, + kRegistryMozRegDataMovedString.get(), getter_Copies(tmpRegDataMoved)); nsAutoString isDataMovedString(tmpRegDataMoved); @@ -1302,7 +1302,7 @@ nsProfileAccess::GetMozRegDataMovedFlag(PRBool *isDataMoved) else { rv = registry->AddKey(nsIRegistry::Common, - kRegistryProfileSubtreeString, + kRegistryProfileSubtreeString.get(), &profilesTreeKey); } return rv; @@ -1327,14 +1327,14 @@ nsProfileAccess::SetMozRegDataMovedFlag(nsIFile* regName) if (NS_FAILED(rv)) return rv; rv = registry->GetKey(nsIRegistry::Common, - kRegistryProfileSubtreeString, + kRegistryProfileSubtreeString.get(), &profilesTreeKey); if (NS_SUCCEEDED(rv)) { rv = registry->SetString(profilesTreeKey, - kRegistryMozRegDataMovedString, - kRegistryYesString); + kRegistryMozRegDataMovedString.get(), + kRegistryYesString.get()); } return rv; @@ -1435,7 +1435,7 @@ nsresult ProfileStruct::InternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe { nsXPIDLString profLoc; - rv = aRegistry->GetString( profKey, NS_LITERAL_STRING("ProfileLocation"), getter_Copies(profLoc)); + rv = aRegistry->GetString( profKey, NS_LITERAL_STRING("ProfileLocation").get(), getter_Copies(profLoc)); if (NS_FAILED(rv)) return rv; regLocationData = profLoc; @@ -1444,10 +1444,9 @@ nsresult ProfileStruct::InternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe // So, there is no need to decode into unicode further. // Unescape profile location - nsCAutoString tempLoc; - tempLoc = (const char*) NS_ConvertUCS2toUTF8(profLoc); + NS_ConvertUCS2toUTF8 tempLoc(profLoc); nsCAutoString profileLocation(nsUnescape( NS_CONST_CAST(char*, tempLoc.get()))); - nsAutoString convertedProfLoc((const PRUnichar*) NS_ConvertUTF8toUCS2(profileLocation)); + nsAutoString convertedProfLoc(NS_ConvertUTF8toUCS2(profileLocation).get()); #else nsAutoString charSet; rv = GetPlatformCharset(charSet); @@ -1473,7 +1472,7 @@ nsresult ProfileStruct::InternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe nsAutoString dirNameString; rv = aRegistry->GetString(profKey, - kRegistryDirectoryString, + kRegistryDirectoryString.get(), getter_Copies(regData)); if (NS_FAILED(rv)) return rv; @@ -1538,7 +1537,7 @@ nsresult ProfileStruct::InternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe else { rv = aRegistry->GetString(profKey, - kRegistryDirectoryString, + kRegistryDirectoryString.get(), getter_Copies(regData)); if (NS_FAILED(rv)) return rv; regLocationData = regData; @@ -1604,7 +1603,7 @@ nsresult ProfileStruct::ExternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe #endif rv = aRegistry->SetString(profKey, - kRegistryDirectoryString, + kRegistryDirectoryString.get(), regData.GetUnicode()); } @@ -1612,7 +1611,7 @@ nsresult ProfileStruct::ExternalizeLocation(nsIRegistry *aRegistry, nsRegistryKe { // Write the original data back out - maybe it can be resolved later. rv = aRegistry->SetString(profKey, - kRegistryDirectoryString, + kRegistryDirectoryString.get(), regLocationData.GetUnicode()); } else diff --git a/mozilla/rdf/base/src/nsRDFContentSink.cpp b/mozilla/rdf/base/src/nsRDFContentSink.cpp index 6ceb165c92c..48eb55e4d01 100644 --- a/mozilla/rdf/base/src/nsRDFContentSink.cpp +++ b/mozilla/rdf/base/src/nsRDFContentSink.cpp @@ -1018,7 +1018,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const nsIParserNode& aNode, nsAutoString uri(aNode.GetValueAt(i)); nsRDFParserUtils::StripAndConvert(uri); - rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(NS_STATIC_CAST(const char*, docURI)), uri); + rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(docURI), uri); return gRDFService->GetUnicodeResource(uri.GetUnicode(), aResource); } @@ -1039,7 +1039,7 @@ RDFContentSinkImpl::GetIdAboutAttribute(const nsIParserNode& aNode, // attribute. name.Insert(PRUnichar('#'), 0); - rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(NS_STATIC_CAST(const char*, docURI)), name); + rdf_MakeAbsoluteURI(NS_ConvertUTF8toUCS2(docURI), name); return gRDFService->GetUnicodeResource(name.GetUnicode(), aResource); } @@ -1625,7 +1625,7 @@ RDFContentSinkImpl::PushNameSpacesFrom(const nsIParserNode& aNode) nsRDFParserUtils::StripAndConvert(uri); // Open a local namespace - NameSpaceEntry* ns = new NameSpaceEntry(prefix, NS_ConvertUCS2toUTF8(uri.GetUnicode())); + NameSpaceEntry* ns = new NameSpaceEntry(prefix, NS_ConvertUCS2toUTF8(uri).get()); if (! ns) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/rdf/base/src/nsRDFService.cpp b/mozilla/rdf/base/src/nsRDFService.cpp index c6aeaae7aad..39a96fae94b 100644 --- a/mozilla/rdf/base/src/nsRDFService.cpp +++ b/mozilla/rdf/base/src/nsRDFService.cpp @@ -775,7 +775,7 @@ RDFServiceImpl::GetUnicodeResource(const PRUnichar* aURI, nsIRDFResource** aReso if (! aURI) return NS_ERROR_NULL_POINTER; - return GetResource(NS_ConvertUCS2toUTF8(aURI), aResource); + return GetResource(NS_ConvertUCS2toUTF8(aURI).get(), aResource); } diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index 208310271dc..116d13b0114 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -1430,7 +1430,7 @@ NS_IMETHODIMP nsChromeRegistry::SelectLocaleForProfile(const PRUnichar *aLocale, const PRUnichar *aProfilePath) { // to be changed to use given path - return SetProvider(nsCAutoString("locale"), mSelectedLocale, aLocale, PR_TRUE, NS_ConvertUCS2toUTF8(aProfilePath), PR_TRUE); + return SetProvider(nsCAutoString("locale"), mSelectedLocale, aLocale, PR_TRUE, NS_ConvertUCS2toUTF8(aProfilePath).get(), PR_TRUE); } /* wstring getSelectedLocale (); */ diff --git a/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp b/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp index 08ddeaa8409..6703b0e11d2 100644 --- a/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp +++ b/mozilla/rdf/datasource/src/nsFileSystemDataSource.cpp @@ -1525,7 +1525,7 @@ FileSystemDataSource::GetExtension(nsIRDFResource *source, nsIRDFLiteral **aResu nsAutoString filename(unicodeLeafName); PRInt32 lastDot = filename.RFindChar('.'); if (lastDot == -1) { - gRDFService->GetLiteral(NS_LITERAL_STRING(""), aResult); + gRDFService->GetLiteral(NS_LITERAL_STRING("").get(), aResult); } else { nsAutoString extension; filename.Right(extension, (filename.Length() - lastDot)); diff --git a/mozilla/string/obsolete/nsString.h b/mozilla/string/obsolete/nsString.h index 542290750fa..26c163306bd 100644 --- a/mozilla/string/obsolete/nsString.h +++ b/mozilla/string/obsolete/nsString.h @@ -64,6 +64,9 @@ protected: virtual const char* GetReadableFragment( nsReadableFragment<char>&, nsFragmentRequest, PRUint32 ) const; virtual char* GetWritableFragment( nsWritableFragment<char>&, nsFragmentRequest, PRUint32 ); +public: + virtual const char* get() const { return mStr; } + public: /** * Default constructor. @@ -125,13 +128,6 @@ public: Accessor methods... *********************************************************************/ - - /** - * Retrieve const ptr to internal buffer; DO NOT TRY TO FREE IT! - */ - - const char* get() const { return mStr; } - PRBool SetCharAt(PRUnichar aChar,PRUint32 anIndex); /********************************************************************** @@ -532,14 +528,16 @@ class NS_COM NS_ConvertUCS2toUTF8 explicit NS_ConvertUCS2toUTF8( const nsAReadableString& aString ); - const char* get() const + operator const char*() const // use |get()| { - return mStr; + NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |const char*| is deprecated, use |get()| instead."); + return get(); } - operator const char*() const // to be deprecated, prefer |get()| + operator char*() // use |get()| { - return get(); + NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |char*| is deprecated, use |NS_CONST_CAST()| and |get()| instead."); + return NS_CONST_CAST(char*, get()); } protected: diff --git a/mozilla/string/obsolete/nsString2.h b/mozilla/string/obsolete/nsString2.h index bb9740a0b42..6578fa27a4b 100644 --- a/mozilla/string/obsolete/nsString2.h +++ b/mozilla/string/obsolete/nsString2.h @@ -76,6 +76,8 @@ protected: virtual const PRUnichar* GetReadableFragment( nsReadableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) const; virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ); +public: + virtual const PRUnichar* get() const { return GetUnicode(); } public: /** @@ -123,7 +125,6 @@ public: */ virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const; - /** * Call this method if you want to force a different string length * @update gess7/30/98 @@ -588,14 +589,7 @@ class NS_COM NS_ConvertASCIItoUCS2 NS_ConvertASCIItoUCS2( const char*, PRUint32 ); explicit NS_ConvertASCIItoUCS2( char ); - const PRUnichar* get() const { return GetUnicode(); } - - operator const PRUnichar*() const - { - return GetUnicode(); - } - - operator nsLiteralString() const + operator const nsLiteralString() const { return nsLiteralString(mUStr, mLength); } @@ -649,11 +643,6 @@ class NS_COM NS_ConvertUTF8toUCS2 Init( &aChar, 1 ); } - operator const PRUnichar*() const - { - return GetUnicode(); - } - protected: void Init( const char* aCString, PRUint32 aLength ); diff --git a/mozilla/string/public/nsAReadableString.h b/mozilla/string/public/nsAReadableString.h index b36279dbd06..ffe22945c36 100644 --- a/mozilla/string/public/nsAReadableString.h +++ b/mozilla/string/public/nsAReadableString.h @@ -797,9 +797,9 @@ class basic_nsLiteralString virtual PRUint32 Length() const; + const CharT* get() const { return mStart; } - const CharT* get() const { return mStart; } - operator const CharT*() const { return get(); } // to be deprecated, prefer |get()| + // operator const CharT*() const; // use |get()| private: const CharT* mStart; @@ -1456,8 +1456,9 @@ class basic_nsPromiseFlatString virtual PRUint32 Length() const { return mLength; } virtual const CharT* GetReadableFragment( nsReadableFragment<CharT>&, nsFragmentRequest, PRUint32 = 0 ) const; - const CharT* get() const { return mBuffer; } - operator const CharT*() const { return get(); } // to be deprecated, prefer |get()| + const CharT* get() const { return mBuffer; } + + // operator const CharT*() const; // use |get()| protected: PRUint32 mLength; diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index 67e104b8dad..425f3cbe5a2 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -1355,7 +1355,7 @@ nsresult nsExternalHelperAppService::AddDefaultMimeTypesToCache() nsCOMPtr<nsIMIMEInfo> mimeInfo (do_CreateInstance(NS_MIMEINFO_CONTRACTID)); mimeInfo->SetFileExtensions(defaultMimeEntries[index].mFileExtensions); mimeInfo->SetMIMEType(defaultMimeEntries[index].mMimeType); - mimeInfo->SetDescription(NS_ConvertASCIItoUCS2(defaultMimeEntries[index].mDescription)); + mimeInfo->SetDescription(NS_ConvertASCIItoUCS2(defaultMimeEntries[index].mDescription).get()); mimeInfo->SetMacType(defaultMimeEntries[index].mMactype); mimeInfo->SetMacCreator(defaultMimeEntries[index].mMacCreator); AddMimeInfoToCache(mimeInfo); diff --git a/mozilla/widget/src/mac/nsFilePicker.cpp b/mozilla/widget/src/mac/nsFilePicker.cpp index e2d89fd2460..f1491b30ef8 100644 --- a/mozilla/widget/src/mac/nsFilePicker.cpp +++ b/mozilla/widget/src/mac/nsFilePicker.cpp @@ -227,7 +227,7 @@ nsFilePicker :: IsExtensionInFilterList ( StrFileName & inFileName ) // see if it is in our list for ( int i = 0; i < mFlatFilters.Count(); ++i ) { - if ( *mFlatFilters[i] == extension ) + if ( mFlatFilters[i]->Equals(extension) ) return true; } return false; diff --git a/mozilla/widget/src/mac/nsMimeMapper.cpp b/mozilla/widget/src/mac/nsMimeMapper.cpp index f3727671d40..53ecd9f54b2 100644 --- a/mozilla/widget/src/mac/nsMimeMapper.cpp +++ b/mozilla/widget/src/mac/nsMimeMapper.cpp @@ -63,7 +63,7 @@ nsMimeMapperMac :: MapMimeTypeToMacOSType ( const char* aMimeStr, PRBool inAddIf // first check if it is already in our list. for ( MimeMapConstIterator it = mMappings.begin(); it != mMappings.end(); ++it ) { - if ( it->second == aMimeStr ) { + if ( it->second.Equals(aMimeStr) ) { format = it->first; break; } diff --git a/mozilla/xpcom/string/obsolete/nsString.h b/mozilla/xpcom/string/obsolete/nsString.h index 542290750fa..26c163306bd 100644 --- a/mozilla/xpcom/string/obsolete/nsString.h +++ b/mozilla/xpcom/string/obsolete/nsString.h @@ -64,6 +64,9 @@ protected: virtual const char* GetReadableFragment( nsReadableFragment<char>&, nsFragmentRequest, PRUint32 ) const; virtual char* GetWritableFragment( nsWritableFragment<char>&, nsFragmentRequest, PRUint32 ); +public: + virtual const char* get() const { return mStr; } + public: /** * Default constructor. @@ -125,13 +128,6 @@ public: Accessor methods... *********************************************************************/ - - /** - * Retrieve const ptr to internal buffer; DO NOT TRY TO FREE IT! - */ - - const char* get() const { return mStr; } - PRBool SetCharAt(PRUnichar aChar,PRUint32 anIndex); /********************************************************************** @@ -532,14 +528,16 @@ class NS_COM NS_ConvertUCS2toUTF8 explicit NS_ConvertUCS2toUTF8( const nsAReadableString& aString ); - const char* get() const + operator const char*() const // use |get()| { - return mStr; + NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |const char*| is deprecated, use |get()| instead."); + return get(); } - operator const char*() const // to be deprecated, prefer |get()| + operator char*() // use |get()| { - return get(); + NS_WARNING("Implicit conversion from |NS_ConvertUCS2toUTF8| to |char*| is deprecated, use |NS_CONST_CAST()| and |get()| instead."); + return NS_CONST_CAST(char*, get()); } protected: diff --git a/mozilla/xpcom/string/obsolete/nsString2.h b/mozilla/xpcom/string/obsolete/nsString2.h index bb9740a0b42..6578fa27a4b 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.h +++ b/mozilla/xpcom/string/obsolete/nsString2.h @@ -76,6 +76,8 @@ protected: virtual const PRUnichar* GetReadableFragment( nsReadableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ) const; virtual PRUnichar* GetWritableFragment( nsWritableFragment<PRUnichar>&, nsFragmentRequest, PRUint32 ); +public: + virtual const PRUnichar* get() const { return GetUnicode(); } public: /** @@ -123,7 +125,6 @@ public: */ virtual void SizeOf(nsISizeOfHandler* aHandler, PRUint32* aResult) const; - /** * Call this method if you want to force a different string length * @update gess7/30/98 @@ -588,14 +589,7 @@ class NS_COM NS_ConvertASCIItoUCS2 NS_ConvertASCIItoUCS2( const char*, PRUint32 ); explicit NS_ConvertASCIItoUCS2( char ); - const PRUnichar* get() const { return GetUnicode(); } - - operator const PRUnichar*() const - { - return GetUnicode(); - } - - operator nsLiteralString() const + operator const nsLiteralString() const { return nsLiteralString(mUStr, mLength); } @@ -649,11 +643,6 @@ class NS_COM NS_ConvertUTF8toUCS2 Init( &aChar, 1 ); } - operator const PRUnichar*() const - { - return GetUnicode(); - } - protected: void Init( const char* aCString, PRUint32 aLength ); diff --git a/mozilla/xpcom/string/public/nsAReadableString.h b/mozilla/xpcom/string/public/nsAReadableString.h index b36279dbd06..ffe22945c36 100644 --- a/mozilla/xpcom/string/public/nsAReadableString.h +++ b/mozilla/xpcom/string/public/nsAReadableString.h @@ -797,9 +797,9 @@ class basic_nsLiteralString virtual PRUint32 Length() const; + const CharT* get() const { return mStart; } - const CharT* get() const { return mStart; } - operator const CharT*() const { return get(); } // to be deprecated, prefer |get()| + // operator const CharT*() const; // use |get()| private: const CharT* mStart; @@ -1456,8 +1456,9 @@ class basic_nsPromiseFlatString virtual PRUint32 Length() const { return mLength; } virtual const CharT* GetReadableFragment( nsReadableFragment<CharT>&, nsFragmentRequest, PRUint32 = 0 ) const; - const CharT* get() const { return mBuffer; } - operator const CharT*() const { return get(); } // to be deprecated, prefer |get()| + const CharT* get() const { return mBuffer; } + + // operator const CharT*() const; // use |get()| protected: PRUint32 mLength; diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index de3a9bd33b1..b20522bbb83 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -1866,7 +1866,7 @@ nsDOMWindowPrompter::AlertCheck(const PRUnichar* dialogTitle, if (dialogTitle == nsnull) { PRUnichar *title; - rv = GetLocaleString(NS_ConvertASCIItoUCS2("Alert"), &title); + rv = GetLocaleString(NS_LITERAL_STRING("Alert").get(), &title); if (NS_FAILED(rv)) return NS_ERROR_FAILURE; rv = mCommonDialogs->AlertCheck(mDOMWindow, title, text, checkMsg, checkValue); diff --git a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp index 96a1b6ac520..140791bee10 100644 --- a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp @@ -1342,7 +1342,7 @@ nsGlobalHistory::GetTarget(nsIRDFResource* aSource, if (aProperty == kNC_URL && !IsFindResource(aSource)) { nsCOMPtr<nsIRDFLiteral> uriLiteral; - rv = gRDFService->GetLiteral(NS_ConvertUTF8toUCS2(uri), getter_AddRefs(uriLiteral)); + rv = gRDFService->GetLiteral(NS_ConvertUTF8toUCS2(uri).get(), getter_AddRefs(uriLiteral)); if (NS_FAILED(rv)) return(rv); *aTarget = uriLiteral; NS_ADDREF(*aTarget); @@ -1356,7 +1356,7 @@ nsGlobalHistory::GetTarget(nsIRDFResource* aSource, // for sorting, we sort by uri, so just return the URI as a literal if (aProperty == kNC_NameSort) { nsCOMPtr<nsIRDFLiteral> uriLiteral; - rv = gRDFService->GetLiteral(NS_ConvertUTF8toUCS2(uri), + rv = gRDFService->GetLiteral(NS_ConvertUTF8toUCS2(uri).get(), getter_AddRefs(uriLiteral)); if (NS_FAILED(rv)) return(rv); diff --git a/mozilla/xpfe/components/search/src/nsLocalSearchService.cpp b/mozilla/xpfe/components/search/src/nsLocalSearchService.cpp index 486eadca034..415a98d6ea0 100755 --- a/mozilla/xpfe/components/search/src/nsLocalSearchService.cpp +++ b/mozilla/xpfe/components/search/src/nsLocalSearchService.cpp @@ -436,7 +436,7 @@ LocalSearchDataSource::parseDate(const nsAReadableString& aDate, // parse the time PRTime *outTime = NS_STATIC_CAST(PRTime*,aResult); PRStatus err; - err = PR_ParseTimeString(NS_ConvertUCS2toUTF8(aDate), + err = PR_ParseTimeString(NS_ConvertUCS2toUTF8(aDate).get(), PR_FALSE, // PR_FALSE == use current timezone outTime); NS_ENSURE_TRUE(err == 0, NS_ERROR_FAILURE); diff --git a/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp b/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp index 6e58c73ad83..6e7f7fc655d 100644 --- a/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp +++ b/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp @@ -554,7 +554,7 @@ nsUrlbarHistory::GetHostIndex(const PRUnichar * aPath, PRInt32 * aReturn) nsCOMPtr<nsIURL> pathURL=do_CreateInstance(kStandardURLCID, &rv); if (pathURL) { - pathURL->SetSpec(NS_ConvertUCS2toUTF8(aPath)); + pathURL->SetSpec(NS_ConvertUCS2toUTF8(aPath).get()); char * host=nsnull, *preHost = nsnull, * filePath = nsnull; pathURL->GetHost(&host); pathURL->GetFilePath(&filePath); @@ -637,7 +637,7 @@ nsUrlbarHistory::VerifyAndCreateEntry(const PRUnichar * aSearchItem, PRUnichar * nsresult rv; nsCOMPtr<nsIURL> searchURL = do_CreateInstance(kStandardURLCID, &rv); if (searchURL) { - searchURL->SetSpec(NS_ConvertUCS2toUTF8(aSearchItem)); + searchURL->SetSpec(NS_ConvertUCS2toUTF8(aSearchItem).get()); nsXPIDLCString filePath; searchURL->GetFilePath(getter_Copies(filePath)); // Don't bother checking for hostname if the search string @@ -649,7 +649,7 @@ nsUrlbarHistory::VerifyAndCreateEntry(const PRUnichar * aSearchItem, PRUnichar * nsCOMPtr<nsIURL> matchURL = do_CreateInstance(kStandardURLCID, &rv); if (matchURL) { - matchURL->SetSpec(NS_ConvertUCS2toUTF8(aMatchStr)); + matchURL->SetSpec(NS_ConvertUCS2toUTF8(aMatchStr).get()); nsXPIDLCString filePath; matchURL->GetFilePath(getter_Copies(filePath)); // If the match string doesn't have a filepath diff --git a/mozilla/xpinstall/src/nsInstall.cpp b/mozilla/xpinstall/src/nsInstall.cpp index 8e5f570b460..0eced672153 100644 --- a/mozilla/xpinstall/src/nsInstall.cpp +++ b/mozilla/xpinstall/src/nsInstall.cpp @@ -34,7 +34,6 @@ #include "nsIServiceManager.h" #include "nsHashtable.h" -#include "nsFileSpec.h" #include "nsFileStream.h" #include "nsSpecialSystemDirectory.h" #include "nsDirectoryService.h" @@ -780,8 +779,8 @@ nsInstall::FinalizeInstall(PRInt32* aReturn) { if ( mUninstallPackage ) { - VR_UninstallCreateNode( NS_ConvertUCS2toUTF8(mRegistryPackageName), - NS_ConvertUCS2toUTF8(mUIName)); + VR_UninstallCreateNode( NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(mRegistryPackageName).get()), + NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(mUIName).get())); } // Install the Component into the Version Registry. @@ -791,13 +790,15 @@ nsInstall::FinalizeInstall(PRInt32* aReturn) nsCString path; mVersionInfo->ToString(versionString); + nsCAutoString versionCString; + versionCString.AssignWithConversion(versionString); if (mPackageFolder) mPackageFolder->GetDirectoryPath(path); - VR_Install( NS_ConvertUCS2toUTF8(mRegistryPackageName), - (char*)path.get(), - (char*)(const char*)nsAutoCString(versionString), + VR_Install( NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(mRegistryPackageName).get()), + NS_CONST_CAST(char *, path.get()), + NS_CONST_CAST(char *, versionCString.get()), PR_TRUE ); } @@ -953,9 +954,9 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS NS_ConvertUCS2toUTF8 componentCString(tempString); - if((err = VR_GetDefaultDirectory( componentCString, sizeof(dir), dir )) != REGERR_OK) + if((err = VR_GetDefaultDirectory( NS_CONST_CAST(char *, componentCString.get()), sizeof(dir), dir )) != REGERR_OK) { - if((err = VR_GetPath( componentCString, sizeof(dir), dir )) == REGERR_OK) + if((err = VR_GetPath( NS_CONST_CAST(char *, componentCString.get()), sizeof(dir), dir )) == REGERR_OK) { int i; @@ -1425,7 +1426,7 @@ nsInstall::StartInstall(const nsString& aUserPackageName, const nsString& aRegis } if(REGERR_OK == VR_GetDefaultDirectory( - NS_ConvertUCS2toUTF8(mRegistryPackageName), + NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(mRegistryPackageName).get()), sizeof(szRegPackagePath), szRegPackagePath)) { nsInstallFolder* folder = new nsInstallFolder(); diff --git a/mozilla/xpinstall/src/nsInstallPatch.cpp b/mozilla/xpinstall/src/nsInstallPatch.cpp index d29a4f1efd7..b44d847f539 100644 --- a/mozilla/xpinstall/src/nsInstallPatch.cpp +++ b/mozilla/xpinstall/src/nsInstallPatch.cpp @@ -81,7 +81,7 @@ nsInstallPatch::nsInstallPatch( nsInstall* inInstall, char tempTargetFile[MAXREGPATHLEN]; - PRInt32 err = VR_GetPath( NS_ConvertUCS2toUTF8(inVRName), + PRInt32 err = VR_GetPath( NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(inVRName).get()), sizeof(tempTargetFile), tempTargetFile ); if (err != REGERR_OK) @@ -310,9 +310,9 @@ PRInt32 nsInstallPatch::Complete() // DO NOT propogate version registry errors, it will abort // FinalizeInstall() leaving things hosed. These piddly errors // aren't worth that. - VR_Install( NS_ConvertUCS2toUTF8(mRegistryName->GetUnicode()), - (char*)(const char*)tempPath, - NS_ConvertUCS2toUTF8(tempVersionString), + VR_Install( NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(*mRegistryName).get()), + NS_CONST_CAST(char *, tempPath.get()), + NS_CONST_CAST(char *, NS_ConvertUCS2toUTF8(tempVersionString).get()), PR_FALSE ); } else diff --git a/mozilla/xpinstall/src/nsInstallTrigger.cpp b/mozilla/xpinstall/src/nsInstallTrigger.cpp index 8e937b1f159..c2051325070 100644 --- a/mozilla/xpinstall/src/nsInstallTrigger.cpp +++ b/mozilla/xpinstall/src/nsInstallTrigger.cpp @@ -329,12 +329,12 @@ nsInstallTrigger::CompareVersion(const nsString& aRegName, nsIDOMInstallVersion* REGERR status; nsInstallVersion regNameVersion; - status = VR_GetVersion( regName, &cVersion ); + status = VR_GetVersion( NS_CONST_CAST(char *, regName.get()), &cVersion ); /* if we got the version */ if ( status == REGERR_OK ) { - if ( VR_ValidateComponent( regName ) == REGERR_NOFILE ) + if ( VR_ValidateComponent( NS_CONST_CAST(char *, regName.get()) ) == REGERR_NOFILE ) { regNameVersion.Init(0,0,0,0); } @@ -367,7 +367,7 @@ nsInstallTrigger::GetVersion(const nsString& component, nsString& version) NS_ConvertUCS2toUTF8 regName(component); REGERR status; - status = VR_GetVersion( regName, &cVersion ); + status = VR_GetVersion( NS_CONST_CAST(char *, regName.get()), &cVersion ); version.Truncate(); diff --git a/mozilla/xpinstall/src/nsJSInstall.cpp b/mozilla/xpinstall/src/nsJSInstall.cpp index cf1e93f841b..cef05f11e31 100644 --- a/mozilla/xpinstall/src/nsJSInstall.cpp +++ b/mozilla/xpinstall/src/nsJSInstall.cpp @@ -1467,7 +1467,7 @@ InstallRegisterChrome(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsv ConvertJSValToStr(path, cx, argv[2]); } - *rval = INT_TO_JSVAL(nativeThis->RegisterChrome(chrome, chromeType, NS_ConvertUCS2toUTF8(path))); + *rval = INT_TO_JSVAL(nativeThis->RegisterChrome(chrome, chromeType, NS_ConvertUCS2toUTF8(path).get())); return JS_TRUE; } diff --git a/mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp b/mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp index ad1d54d3094..62fbc63b07f 100644 --- a/mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp +++ b/mozilla/xpinstall/src/nsLoggingProgressNotifier.cpp @@ -157,7 +157,7 @@ nsLoggingProgressListener::BeforeJavascriptEvaluation(const PRUnichar *URL) mLogStream->seek(logFile->GetFileSize()); *mLogStream << "-------------------------------------------------------------------------------" << nsEndl; - *mLogStream << NS_ConvertUCS2toUTF8(URL) << " -- " << time << nsEndl; + *mLogStream << NS_ConvertUCS2toUTF8(URL).get() << " -- " << time << nsEndl; *mLogStream << "-------------------------------------------------------------------------------" << nsEndl; *mLogStream << nsEndl; @@ -225,7 +225,7 @@ nsLoggingProgressListener::FinalizeProgress(const PRUnichar* message, PRInt32 it { if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER; - *mLogStream << " [" << (itemNum) << "/" << totNum << "]\t" << NS_ConvertUCS2toUTF8(message) << nsEndl; + *mLogStream << " [" << (itemNum) << "/" << totNum << "]\t" << NS_ConvertUCS2toUTF8(message).get() << nsEndl; return NS_OK; } @@ -277,7 +277,7 @@ nsLoggingProgressListener::LogComment(const PRUnichar* comment) { if (mLogStream == nsnull) return NS_ERROR_NULL_POINTER; - *mLogStream << " ** " << NS_ConvertUCS2toUTF8(comment) << nsEndl; + *mLogStream << " ** " << NS_ConvertUCS2toUTF8(comment).get() << nsEndl; return NS_OK; }