diff --git a/mozilla/caps/src/nsBasePrincipal.cpp b/mozilla/caps/src/nsBasePrincipal.cpp index da4bfedccc8..aff01a186fb 100644 --- a/mozilla/caps/src/nsBasePrincipal.cpp +++ b/mozilla/caps/src/nsBasePrincipal.cpp @@ -24,6 +24,7 @@ #include "nsBasePrincipal.h" #include "nsScriptSecurityManager.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "plstr.h" #include "nsIPref.h" @@ -307,13 +308,13 @@ nsBasePrincipal::GetPreferences(char** aPrefName, char** aID, if (grantedListStr.Length() > 0) { grantedListStr.Truncate(grantedListStr.Length()-1); - *aGrantedList = grantedListStr.ToNewCString(); + *aGrantedList = ToNewCString(grantedListStr); if (!*aGrantedList) return NS_ERROR_OUT_OF_MEMORY; } if (deniedListStr.Length() > 0) { deniedListStr.Truncate(deniedListStr.Length()-1); - *aDeniedList = deniedListStr.ToNewCString(); + *aDeniedList = ToNewCString(deniedListStr); if (!*aDeniedList) return NS_ERROR_OUT_OF_MEMORY; } } diff --git a/mozilla/caps/src/nsCertificatePrincipal.cpp b/mozilla/caps/src/nsCertificatePrincipal.cpp index fcc09c103b5..9528dc8f755 100644 --- a/mozilla/caps/src/nsCertificatePrincipal.cpp +++ b/mozilla/caps/src/nsCertificatePrincipal.cpp @@ -41,6 +41,7 @@ #include "nsCertificatePrincipal.h" #include "prmem.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" static NS_DEFINE_IID(kICertificatePrincipalIID, NS_ICERTIFICATEPRINCIPAL_IID); @@ -116,7 +117,7 @@ nsCertificatePrincipal::GetPreferences(char** aPrefName, char** aID, s.Assign("capability.principal.certificate.p"); s.AppendInt(mCapabilitiesOrdinal++); s.Append(".id"); - mPrefName = s.ToNewCString(); + mPrefName = ToNewCString(s); } return nsBasePrincipal::GetPreferences(aPrefName, aID, aGrantedList, aDeniedList); diff --git a/mozilla/caps/src/nsCodebasePrincipal.cpp b/mozilla/caps/src/nsCodebasePrincipal.cpp index 9ba850ae024..5b640615bc5 100644 --- a/mozilla/caps/src/nsCodebasePrincipal.cpp +++ b/mozilla/caps/src/nsCodebasePrincipal.cpp @@ -46,6 +46,7 @@ #include "nsCOMPtr.h" #include "nsIPref.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" NS_IMPL_QUERY_INTERFACE3_CI(nsCodebasePrincipal, nsICodebasePrincipal, @@ -84,7 +85,7 @@ nsCodebasePrincipal::GetPreferences(char** aPrefName, char** aID, s.Assign("capability.principal.codebase.p"); s.AppendInt(mCapabilitiesOrdinal++); s.Append(".id"); - mPrefName = s.ToNewCString(); + mPrefName = ToNewCString(s); } return nsBasePrincipal::GetPreferences(aPrefName, aID, aGrantedList, aDeniedList); diff --git a/mozilla/caps/src/nsScriptSecurityManager.cpp b/mozilla/caps/src/nsScriptSecurityManager.cpp index 0d6f0d6a7cb..d095bdf6af1 100644 --- a/mozilla/caps/src/nsScriptSecurityManager.cpp +++ b/mozilla/caps/src/nsScriptSecurityManager.cpp @@ -50,6 +50,7 @@ #include "nsAggregatePrincipal.h" #include "nsCRT.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIJSContextStack.h" #include "nsDOMError.h" #include "nsDOMCID.h" @@ -218,7 +219,7 @@ nsScriptSecurityManager::CheckPropertyAccessImpl(PRUint32 aAction, propertyStr.AppendWithConversion((PRUnichar*)JSValIDToString(aJSContext, aName)); char* property; - property = propertyStr.ToNewCString(); + property = ToNewCString(propertyStr); printf("### CanAccess(%s, %i) ", property, aAction); PR_FREEIF(property); } @@ -939,14 +940,14 @@ nsScriptSecurityManager::ReportErrorToConsole(nsIURI* aTarget) nsCOMPtr console(do_GetService("@mozilla.org/consoleservice;1")); if (console) { - PRUnichar* messageUni = msg.ToNewUnicode(); + PRUnichar* messageUni = ToNewUnicode(msg); if (!messageUni) return NS_ERROR_FAILURE; console->LogStringMessage(messageUni); nsMemory::Free(messageUni); } #ifdef DEBUG - char* messageCstr = msg.ToNewCString(); + char* messageCstr = ToNewCString(msg); if (!messageCstr) return NS_ERROR_FAILURE; fprintf(stderr, "%s\n", messageCstr); @@ -2007,7 +2008,7 @@ nsScriptSecurityManager::Observe(nsISupports* aObject, const PRUnichar* aAction, nsresult rv = NS_OK; nsCAutoString prefNameStr; prefNameStr.AssignWithConversion(aPrefName); - char* prefName = prefNameStr.ToNewCString(); + char* prefName = ToNewCString(prefNameStr); if (!prefName) return NS_ERROR_OUT_OF_MEMORY; nsCOMPtr securityPref(do_QueryReferent(mPrefBranchWeakRef)); diff --git a/mozilla/caps/src/nsSystemPrincipal.cpp b/mozilla/caps/src/nsSystemPrincipal.cpp index 1ec30f9a89c..b08f9fc9ef9 100644 --- a/mozilla/caps/src/nsSystemPrincipal.cpp +++ b/mozilla/caps/src/nsSystemPrincipal.cpp @@ -45,6 +45,7 @@ #include "nsIURL.h" #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" NS_IMPL_QUERY_INTERFACE2_CI(nsSystemPrincipal, nsIPrincipal, nsISerializable) @@ -64,7 +65,7 @@ nsSystemPrincipal::ToString(char **result) nsAutoString buf; buf.AssignWithConversion("[System]"); - *result = buf.ToNewCString(); + *result = ToNewCString(buf); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/chrome/src/nsChromeRegistry.cpp b/mozilla/chrome/src/nsChromeRegistry.cpp index 44cdb7f6e2a..43da94733e8 100644 --- a/mozilla/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/chrome/src/nsChromeRegistry.cpp @@ -64,6 +64,7 @@ #include "nsIRDFContainerUtils.h" #include "nsHashtable.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsXPIDLString.h" #include "nsIStringBundle.h" #include "nsISimpleEnumerator.h" @@ -2751,7 +2752,7 @@ nsChromeRegistry::GetBackstopSheets(nsIDocShell* aDocShell, nsISupportsArray **a if (!sheets.IsEmpty()) { // Construct the URIs and try to load each sheet. nsCAutoString sheetsStr; sheetsStr.AssignWithConversion(sheets); - char* str = sheets.ToNewCString(); + char* str = ToNewCString(sheets); char* newStr; char* token = nsCRT::strtok( str, ", ", &newStr ); while (token) { diff --git a/mozilla/content/base/src/nsDocumentViewer.cpp b/mozilla/content/base/src/nsDocumentViewer.cpp index bf0028d47cf..3aebe4a4702 100644 --- a/mozilla/content/base/src/nsDocumentViewer.cpp +++ b/mozilla/content/base/src/nsDocumentViewer.cpp @@ -43,6 +43,7 @@ #include "nsCOMPtr.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsISupports.h" #include "nsIContent.h" #include "nsIContentViewerContainer.h" @@ -2110,23 +2111,17 @@ DocumentViewerImpl::GetWebShellTitleAndURL(nsIWebShell * aWebShell, presShell->GetDocument(getter_AddRefs(doc)); if (doc) { const nsString* docTitle = doc->GetDocumentTitle(); - if (docTitle != nsnull) { - nsAutoString title(docTitle->get()); - if (title.Length() > 0) { - *aTitle = title.ToNewUnicode(); - } + if (docTitle && !docTitle->IsEmpty()) { + *aTitle = ToNewUnicode(*docTitle); } nsCOMPtr url; doc->GetDocumentURL(getter_AddRefs(url)); if (url) { - char * urlCStr; - url->GetSpec(&urlCStr); - if (urlCStr) { - nsAutoString urlStr; - urlStr.AssignWithConversion(urlCStr); - *aURLStr = urlStr.ToNewUnicode(); - nsMemory::Free(urlCStr); + nsXPIDLCString urlCStr; + url->GetSpec(getter_Copies(urlCStr)); + if (urlCStr.get()) { + *aURLStr = ToNewUnicode(urlCStr); } } @@ -3297,8 +3292,7 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent, docTitleStr = docURLStr; docURLStr = nsnull; } else { - nsAutoString docStr(NS_LITERAL_STRING("Document")); - docTitleStr = docStr.ToNewUnicode(); + docTitleStr = ToNewUnicode(NS_LITERAL_STRING("Document")); } } // BeginDocument may pass back a FAILURE code @@ -3483,8 +3477,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a GetWebShellTitleAndURL(webShell, &docTitleStr, &docURLStr); if (!docTitleStr) { - nsAutoString emptyTitle(NS_LITERAL_STRING("")); - docTitleStr = emptyTitle.ToNewUnicode(); + docTitleStr = ToNewUnicode(NS_LITERAL_STRING("")); } if (docTitleStr) { @@ -4823,7 +4816,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCha else mDefaultCharacterSet.Assign(gDefCharset); } - *aDefaultCharacterSet = mDefaultCharacterSet.ToNewUnicode(); + *aDefaultCharacterSet = ToNewUnicode(mDefaultCharacterSet); return NS_OK; } @@ -4853,7 +4846,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetForceCharacterSet(PRUnichar** aForceCharact *aForceCharacterSet = nsnull; } else { - *aForceCharacterSet = mForceCharacterSet.ToNewUnicode(); + *aForceCharacterSet = ToNewUnicode(mForceCharacterSet); } return NS_OK; } @@ -4881,7 +4874,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetHintCharacterSet(PRUnichar * *aHintCharacte if(kCharsetUninitialized == mHintCharsetSource) { *aHintCharacterSet = nsnull; } else { - *aHintCharacterSet = mHintCharset.ToNewUnicode(); + *aHintCharacterSet = ToNewUnicode(mHintCharset); // this can't possibly be right. we can't set a value just because somebody got a related value! //mHintCharsetSource = kCharsetUninitialized; } diff --git a/mozilla/content/base/src/nsPlainTextSerializer.cpp b/mozilla/content/base/src/nsPlainTextSerializer.cpp index 52ab5bf9044..ee557ef870c 100644 --- a/mozilla/content/base/src/nsPlainTextSerializer.cpp +++ b/mozilla/content/base/src/nsPlainTextSerializer.cpp @@ -52,6 +52,7 @@ #include "nsTextFragment.h" #include "nsParserCIID.h" #include "nsContentUtils.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kLWBrkCID, NS_LWBRK_CID); static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID); @@ -1499,7 +1500,7 @@ nsPlainTextSerializer::Write(const nsAReadableString& aString) #ifdef DEBUG_wrapping nsAutoString remaining; str.Right(remaining, totLen - bol); - foo = remaining.ToNewCString(); + foo = ToNewCString(remaining); // printf("Next line: bol = %d, newlinepos = %d, totLen = %d, string = '%s'\n", // bol, nextpos, totLen, foo); nsMemory::Free(foo); diff --git a/mozilla/content/base/src/nsRange.cpp b/mozilla/content/base/src/nsRange.cpp index c532b134412..26ea43f31ae 100644 --- a/mozilla/content/base/src/nsRange.cpp +++ b/mozilla/content/base/src/nsRange.cpp @@ -43,6 +43,8 @@ #include "nscore.h" #include "nsRange.h" +#include "nsString.h" +#include "nsReadableUtils.h" #include "nsIDOMNode.h" #include "nsIDOMDocument.h" #include "nsIDOMNSDocument.h" @@ -2299,7 +2301,7 @@ nsRange::CreateContextualFragment(const nsAReadableString& aFragment, if (nsIDOMNode::ELEMENT_NODE == nodeType) { parent->GetNodeName(tagName); // XXX Wish we didn't have to allocate here - name = tagName.ToNewUnicode(); + name = ToNewUnicode(tagName); if (name) { tagStack->Push(name); temp = parent; diff --git a/mozilla/content/base/src/nsSelection.cpp b/mozilla/content/base/src/nsSelection.cpp index 18c7c9b06d8..b16e5b49cdd 100644 --- a/mozilla/content/base/src/nsSelection.cpp +++ b/mozilla/content/base/src/nsSelection.cpp @@ -44,6 +44,8 @@ #include "nsWeakReference.h" #include "nsIFactory.h" #include "nsIEnumerator.h" +#include "nsString.h" +#include "nsReadableUtils.h" #include "nsIDOMRange.h" #include "nsIFrameSelection.h" #include "nsISelection.h" @@ -1762,7 +1764,7 @@ nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags, nsAutoString tmp; rv = encoder->EncodeToString(tmp); - *aReturn = tmp.ToNewUnicode();//get the unicode pointer from it. this is temporary + *aReturn = ToNewUnicode(tmp);//get the unicode pointer from it. this is temporary return rv; } @@ -5814,7 +5816,7 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset) { nsAutoString tagString; tag->ToString(tagString); - char * tagCString = tagString.ToNewCString(); + char * tagCString = ToNewCString(tagString); printf ("Sel. Collapse to %p %s %d\n", content, tagCString, aOffset); delete [] tagCString; } @@ -6638,7 +6640,7 @@ nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) { nsAutoString tagString; tag->ToString(tagString); - char * tagCString = tagString.ToNewCString(); + char * tagCString = ToNewCString(tagString); printf ("Sel. Extend to %p %s %d\n", content, tagCString, aOffset); delete [] tagCString; } @@ -6736,7 +6738,8 @@ nsTypedSelection::ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aYe nsAutoString name, value; aNode->GetNodeName(name); aNode->GetNodeValue(value); - printf("%s [%s]: %d, %d\n", name.ToNewCString(), value.ToNewCString(), + printf("%s [%s]: %d, %d\n", NS_LossyConvertUCS2toASCII(name).get(), + NS_LossyConvertUCS2toASCII(value).get(), nodeStartsBeforeRange, nodeEndsAfterRange); #endif PRUint16 nodeType; diff --git a/mozilla/content/html/content/src/nsAttributeContent.cpp b/mozilla/content/html/content/src/nsAttributeContent.cpp index c52f51ac8d8..b85a4d5fc3f 100644 --- a/mozilla/content/html/content/src/nsAttributeContent.cpp +++ b/mozilla/content/html/content/src/nsAttributeContent.cpp @@ -386,9 +386,7 @@ nsAttributeContent::ValidateTextFragment() nsAutoString result; mContent->GetAttr(mNameSpaceID, mAttrName, result); - PRUnichar * text = result.ToNewUnicode(); - mText.SetTo(text, result.Length()); - nsCRT::free(text); + mText.SetTo(result.get(), result.Length()); } else { mText.SetTo("", 0); diff --git a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp index d26930c9acc..c042007a246 100644 --- a/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAnchorElement.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" #include "nsHTMLUtils.h" +#include "nsReadableUtils.h" #include "nsIDOMHTMLAnchorElement.h" #include "nsIDOMNSHTMLAnchorElement.h" #include "nsIDOMEventReceiver.h" @@ -773,7 +774,7 @@ nsHTMLAnchorElement::GetHrefCString(char* &aBuf) } else { // Absolute URL is same as relative URL. - aBuf = relURLSpec.ToNewUTF8String(); + aBuf = ToNewUTF8String(relURLSpec); } } else { diff --git a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp index 4b445f8a39e..8dc1b557938 100644 --- a/mozilla/content/html/content/src/nsHTMLAreaElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLAreaElement.cpp @@ -50,6 +50,7 @@ #include "nsIURL.h" #include "nsNetUtil.h" #include "nsHTMLUtils.h" +#include "nsReadableUtils.h" class nsHTMLAreaElement : public nsGenericHTMLLeafElement, @@ -512,7 +513,7 @@ nsHTMLAreaElement::GetHrefCString(char* &aBuf) } else { // Absolute URL is same as relative URL. - aBuf = relURLSpec.ToNewUTF8String(); + aBuf = ToNewUTF8String(relURLSpec); } } else { diff --git a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp index 24de3763a95..cf2f16852ae 100644 --- a/mozilla/content/html/content/src/nsHTMLLinkElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLLinkElement.cpp @@ -50,6 +50,7 @@ #include "nsIStyleSheet.h" #include "nsIStyleSheetLinkingElement.h" #include "nsStyleLinkElement.h" +#include "nsReadableUtils.h" #include "nsHTMLUtils.h" #include "nsIURL.h" #include "nsNetUtil.h" @@ -355,7 +356,7 @@ nsHTMLLinkElement::GetHrefCString(char* &aBuf) } else { // Absolute URL is same as relative URL. - aBuf = relURLSpec.ToNewUTF8String(); + aBuf = ToNewUTF8String(relURLSpec); } } else { diff --git a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp index ce47fe2ac31..0359672e5d2 100644 --- a/mozilla/content/html/content/src/nsHTMLStyleElement.cpp +++ b/mozilla/content/html/content/src/nsHTMLStyleElement.cpp @@ -52,6 +52,7 @@ #include "nsNetUtil.h" #include "nsIDocument.h" #include "nsHTMLUtils.h" +#include "nsReadableUtils.h" // XXX no SRC attribute @@ -285,7 +286,7 @@ nsHTMLStyleElement::GetHrefCString(char* &aBuf) } else { // Absolute URL is same as relative URL. - aBuf = relURLSpec.ToNewUTF8String(); + aBuf = ToNewUTF8String(relURLSpec); } } else { diff --git a/mozilla/content/html/document/src/nsHTMLContentSink.cpp b/mozilla/content/html/document/src/nsHTMLContentSink.cpp index fbcc1ecd293..c5261eb92ab 100644 --- a/mozilla/content/html/document/src/nsHTMLContentSink.cpp +++ b/mozilla/content/html/document/src/nsHTMLContentSink.cpp @@ -842,7 +842,7 @@ GetOptionText(const nsIParserNode& aNode, nsString& aText) break; } nsAutoString x; - char* y = aText.ToNewCString(); + char* y = ToNewCString(aText); printf("foo"); } #endif @@ -4002,7 +4002,7 @@ HTMLContentSink::ScrollToRef() // XXX Duplicate code in nsXMLContentSink. // XXX Be sure to change both places if you make changes here. if (!mRef.IsEmpty()) { - char* tmpstr = mRef.ToNewCString(); + char* tmpstr = ToNewCString(mRef); if(! tmpstr) return; nsUnescape(tmpstr); diff --git a/mozilla/content/html/document/src/nsHTMLDocument.cpp b/mozilla/content/html/document/src/nsHTMLDocument.cpp index 1a44aece7fb..6ff371ce62e 100644 --- a/mozilla/content/html/document/src/nsHTMLDocument.cpp +++ b/mozilla/content/html/document/src/nsHTMLDocument.cpp @@ -43,6 +43,7 @@ #include "nsCOMPtr.h" #include "nsIFileChannel.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsHTMLDocument.h" #include "nsIParser.h" #include "nsIParserFilter.h" @@ -500,7 +501,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, if (NS_SUCCEEDED(rv)) { #ifdef DEBUG_charset - char* cCharset = charset.ToNewCString(); + char* cCharset = ToNewCString(charset); printf("From HTTP Header, charset = %s\n", cCharset); Recycle(cCharset); #endif @@ -649,7 +650,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, { #ifdef DEBUG_charset nsAutoString d(requestCharset); - char* cCharset = d.ToNewCString(); + char* cCharset = ToNewCString(d); printf("From request charset, charset = %s req=%d->%d\n", cCharset, charsetSource, requestCharsetSource); Recycle(cCharset); @@ -668,7 +669,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, { #ifdef DEBUG_charset nsAutoString d(forceCharsetFromWebShell); - char* cCharset = d.ToNewCString(); + char* cCharset = ToNewCString(d); printf("From force, charset = %s \n", cCharset); Recycle(cCharset); #endif @@ -766,7 +767,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, csAtom->ToString(charset); charsetSource = kCharsetFromParentFrame; - // printf("### 0 >>> Having parent CS = %s\n", charset.ToNewCString()); + // printf("### 0 >>> Having parent CS = %s\n", NS_LossyConvertUCS2toASCII(charset).get()); } } } @@ -848,7 +849,7 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand, nsCOMPtr oldFilter = getter_AddRefs(mParser->SetParserFilter(cdetflt)); #ifdef DEBUG_charset - char* cCharset = charset.ToNewCString(); + char* cCharset = ToNewCString(charset); printf("set to parser charset = %s source %d\n", cCharset, charsetSource); Recycle(cCharset); diff --git a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp index 691874da8f3..b38ebad5b11 100644 --- a/mozilla/content/html/style/src/nsCSSStyleSheet.cpp +++ b/mozilla/content/html/style/src/nsCSSStyleSheet.cpp @@ -62,6 +62,7 @@ #include "nsLayoutAtoms.h" #include "nsIFrame.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsVoidArray.h" #include "nsIUnicharInputStream.h" #include "nsHTMLIIDs.h" @@ -2284,7 +2285,7 @@ CSSStyleSheetImpl::CheckRuleForAttributes(nsICSSRule *aRule) #ifdef DEBUG_shaver_off nsAutoString str; sel->mAttr->ToString(str); - char * chars = str.ToNewCString(); + char * chars = ToNewCString(str); fprintf(stderr, "[%s@%p]", chars, this); nsMemory::Free(chars); #endif diff --git a/mozilla/content/html/style/src/nsStyleUtil.cpp b/mozilla/content/html/style/src/nsStyleUtil.cpp index 16d04383cd1..a67d12e5ec3 100644 --- a/mozilla/content/html/style/src/nsStyleUtil.cpp +++ b/mozilla/content/html/style/src/nsStyleUtil.cpp @@ -55,6 +55,7 @@ #include "nsIServiceManager.h" #include "nsIPref.h" +#include "nsReadableUtils.h" // XXX This is here because nsCachedStyleData is accessed outside of // the content module; e.g., by nsCSSFrameConstructor. @@ -717,7 +718,7 @@ PRBool nsStyleUtil::IsSimpleXlink(nsIContent *aContent, nsIPresContext *aPresCon // convert here, rather than twice in NS_MakeAbsoluteURI and // back again - char * href = val.ToNewCString(); + char * href = ToNewCString(val); char * absHREF = nsnull; (void) NS_MakeAbsoluteURI(&absHREF, href, baseURI); nsCRT::free(href); diff --git a/mozilla/content/shared/src/nsStyleUtil.cpp b/mozilla/content/shared/src/nsStyleUtil.cpp index 16d04383cd1..a67d12e5ec3 100644 --- a/mozilla/content/shared/src/nsStyleUtil.cpp +++ b/mozilla/content/shared/src/nsStyleUtil.cpp @@ -55,6 +55,7 @@ #include "nsIServiceManager.h" #include "nsIPref.h" +#include "nsReadableUtils.h" // XXX This is here because nsCachedStyleData is accessed outside of // the content module; e.g., by nsCSSFrameConstructor. @@ -717,7 +718,7 @@ PRBool nsStyleUtil::IsSimpleXlink(nsIContent *aContent, nsIPresContext *aPresCon // convert here, rather than twice in NS_MakeAbsoluteURI and // back again - char * href = val.ToNewCString(); + char * href = ToNewCString(val); char * absHREF = nsnull; (void) NS_MakeAbsoluteURI(&absHREF, href, baseURI); nsCRT::free(href); diff --git a/mozilla/content/xbl/src/nsXBLBinding.cpp b/mozilla/content/xbl/src/nsXBLBinding.cpp index 636e659150f..100c2e76993 100644 --- a/mozilla/content/xbl/src/nsXBLBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLBinding.cpp @@ -50,6 +50,7 @@ #include "nsIDOMEventReceiver.h" #include "nsIChannel.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIParser.h" #include "nsParserCIID.h" #include "nsNetUtil.h" diff --git a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp index b15ead37eda..62a121fdb5c 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeBinding.cpp @@ -48,6 +48,7 @@ #include "nsIDOMEventReceiver.h" #include "nsIChannel.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIParser.h" #include "nsParserCIID.h" #include "nsNetUtil.h" @@ -1045,7 +1046,7 @@ nsXBLPrototypeBinding::InitClass(const nsCString& aClassName, nsIScriptContext * // Change the class name and we're done. nsMemory::Free((void*) c->name); - c->name = aClassName.ToNewCString(); + c->name = ToNewCString(aClassName); } // Add c to our table. @@ -1336,7 +1337,7 @@ nsXBLPrototypeBinding::ConstructAttributeTable(nsIContent* aElement) } // The user specified at least one attribute. - char* str = inherits.ToNewCString(); + char* str = ToNewCString(inherits); char* newStr; // XXX We should use a strtok function that tokenizes PRUnichars // so that we don't have to convert from Unicode to ASCII and then back @@ -1442,7 +1443,7 @@ nsXBLPrototypeBinding::ConstructInsertionTable(nsIContent* aContent) } else { // The user specified at least one attribute. - char* str = includes.ToNewCString(); + char* str = ToNewCString(includes); char* newStr; // XXX We should use a strtok function that tokenizes PRUnichar's // so that we don't have to convert from Unicode to ASCII and then back @@ -1514,7 +1515,7 @@ nsXBLPrototypeBinding::ConstructInterfaceTable(nsIContent* aElement) mInterfaceTable = new nsSupportsHashtable(4); // The user specified at least one attribute. - char* str = impls.ToNewCString(); + char* str = ToNewCString(impls); char* newStr; // XXX We should use a strtok function that tokenizes PRUnichars // so that we don't have to convert from Unicode to ASCII and then back diff --git a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp index 8b363960908..37ade01864f 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -68,6 +68,7 @@ #include "nsIPref.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsXULAtoms.h" #include "nsGUIEvent.h" #include "nsIXPConnect.h" @@ -980,7 +981,7 @@ nsXBLPrototypeHandler::ConstructMask() nsAutoString modifiers; mHandlerElement->GetAttr(kNameSpaceID_None, kModifiersAtom, modifiers); if (!modifiers.IsEmpty()) { - char* str = modifiers.ToNewCString(); + char* str = ToNewCString(modifiers); char* newStr; char* token = nsCRT::strtok( str, ", ", &newStr ); while( token != NULL ) { diff --git a/mozilla/content/xbl/src/nsXBLPrototypeProperty.cpp b/mozilla/content/xbl/src/nsXBLPrototypeProperty.cpp index 519c44d745e..7732e5caf96 100644 --- a/mozilla/content/xbl/src/nsXBLPrototypeProperty.cpp +++ b/mozilla/content/xbl/src/nsXBLPrototypeProperty.cpp @@ -49,6 +49,7 @@ #include "nsIPref.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsXULAtoms.h" #include "nsIXPConnect.h" #include "nsIDOMScriptObjectFactory.h" @@ -575,7 +576,7 @@ nsresult nsXBLPrototypeProperty::ParseMethod(nsIScriptContext * aContext) // Get the argname and add it to the array. nsAutoString argName; arg->GetAttr(kNameSpaceID_None, kNameAtom, argName); - char* argStr = argName.ToNewCString(); + char* argStr = ToNewCString(argName); args[argCount] = argStr; argCount++; } diff --git a/mozilla/content/xml/document/src/nsXMLContentSink.cpp b/mozilla/content/xml/document/src/nsXMLContentSink.cpp index 4f7f5c30605..e0f2d0f817b 100644 --- a/mozilla/content/xml/document/src/nsXMLContentSink.cpp +++ b/mozilla/content/xml/document/src/nsXMLContentSink.cpp @@ -37,6 +37,7 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsXMLContentSink.h" #include "nsIElementFactory.h" #include "nsIParser.h" @@ -276,7 +277,7 @@ nsXMLContentSink::ScrollToRef() // XXX Duplicate code in nsHTMLContentSink. // XXX Be sure to change both places if you make changes here. if (!mRef.IsEmpty()) { - char* tmpstr = mRef.ToNewCString(); + char* tmpstr = ToNewCString(mRef); if(! tmpstr) return; nsUnescape(tmpstr); diff --git a/mozilla/content/xsl/document/src/nsTransformMediator.cpp b/mozilla/content/xsl/document/src/nsTransformMediator.cpp index 7077d28d6b2..1101aa3c9ad 100644 --- a/mozilla/content/xsl/document/src/nsTransformMediator.cpp +++ b/mozilla/content/xsl/document/src/nsTransformMediator.cpp @@ -39,8 +39,7 @@ #include "nsTransformMediator.h" #include "nsIComponentManager.h" #include "nsString.h" - -const char* kTransformerContractIDPrefix = "@mozilla.org/document-transformer;1?type="; +#include "nsReadableUtils.h" nsresult NS_NewTransformMediator(nsITransformMediator** aResult, @@ -74,10 +73,10 @@ nsTransformMediator::~nsTransformMediator() } static -nsresult ConstructContractID(nsString& aContractID, const nsString& aMimeType) +nsresult ConstructContractID(nsCString& aContractID, const nsString& aMimeType) { - aContractID.AssignWithConversion(kTransformerContractIDPrefix); - aContractID.Append(aMimeType); + aContractID.Assign(NS_LITERAL_CSTRING("@mozilla.org/document-transformer;1?type=")); + aContractID.AppendWithConversion(aMimeType); return NS_OK; } @@ -85,20 +84,14 @@ nsresult ConstructContractID(nsString& aContractID, const nsString& aMimeType) nsresult nsTransformMediator::Init(const nsString& aMimeType) { - nsString contractID; + nsCString contractID; nsresult rv = NS_OK; // Construct prog ID for the document tranformer component rv = ConstructContractID(contractID, aMimeType); if (NS_SUCCEEDED(rv)) { - nsCID cid; - char* contractIDStr = (char*)contractID.ToNewCString(); - rv = nsComponentManager::ContractIDToClassID((const char*)contractIDStr, &cid); - if (NS_SUCCEEDED(rv)) { - // Try to find a component that implements the nsIDocumentTransformer interface - mTransformer = do_CreateInstance(cid, &rv); - } - delete [] contractIDStr; + // Try to find a component that implements the nsIDocumentTransformer interface + mTransformer = do_CreateInstance(contractID.get(), &rv); } return rv; diff --git a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp index 243b7dc0102..f34561b602c 100644 --- a/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp +++ b/mozilla/content/xul/document/src/nsXULCommandDispatcher.cpp @@ -66,6 +66,7 @@ #include "nsIDOMEventTarget.h" #include "nsGUIEvent.h" #include "nsContentUtils.h" +#include "nsReadableUtils.h" #ifdef PR_LOGGING static PRLogModuleInfo* gLog; @@ -321,7 +322,7 @@ nsXULCommandDispatcher::UpdateCommands(const nsAReadableString& aEventName) #if 0 { - char* actionString = aEventName.ToNewCString(); + char* actionString = ToNewCString(aEventName); printf("Doing UpdateCommands(\"%s\")\n", actionString); free(actionString); } diff --git a/mozilla/content/xul/document/src/nsXULContentSink.cpp b/mozilla/content/xul/document/src/nsXULContentSink.cpp index 8bc3cbffc1c..ae0aad33899 100644 --- a/mozilla/content/xul/document/src/nsXULContentSink.cpp +++ b/mozilla/content/xul/document/src/nsXULContentSink.cpp @@ -95,6 +95,7 @@ #include "nsVoidArray.h" #include "nsWeakPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsXULElement.h" #include "prlog.h" #include "prmem.h" @@ -425,8 +426,8 @@ XULContentSinkImpl::~XULContentSinkImpl() prefix.AssignWithConversion(""); } - char* prefixStr = prefix.ToNewCString(); - char* uriStr = uri.ToNewCString(); + char* prefixStr = ToNewCString(prefix); + char* uriStr = ToNewCString(uri); PR_LOG(gLog, PR_LOG_ALWAYS, ("xul: warning: unclosed namespace '%s' (%s)", diff --git a/mozilla/content/xul/document/src/nsXULDocument.cpp b/mozilla/content/xul/document/src/nsXULDocument.cpp index 633694e8634..25b1baa690b 100644 --- a/mozilla/content/xul/document/src/nsXULDocument.cpp +++ b/mozilla/content/xul/document/src/nsXULDocument.cpp @@ -6592,7 +6592,7 @@ nsXULDocument::InsertElement(nsIContent* aParent, nsIContent* aChild) nsCOMPtr xulDocument(do_QueryInterface(document)); nsCOMPtr domElement; - char* str = posStr.ToNewCString(); + char* str = ToNewCString(posStr); char* rest; char* token = nsCRT::strtok(str, ", ", &rest); diff --git a/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp b/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp index 754afde4eca..36f8f4f76a1 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPChannel.cpp @@ -37,6 +37,7 @@ #include "nsLDAPConnection.h" #include "nsLDAPChannel.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsMimeTypes.h" #include "nsIPipe.h" #include "nsXPIDLString.h" @@ -926,7 +927,7 @@ nsLDAPChannel::OnLDAPSearchEntry(nsILDAPMessage *aMessage) // print all values of this attribute // for ( PRUint32 j=0 ; j < valueCount; j++ ) { - entry.Append(NS_ConvertASCIItoUCS2(attrs[i]).ToNewUnicode()); + entry.Append(NS_ConvertASCIItoUCS2(attrs[i])); entry.Append(NS_LITERAL_STRING(": ")); entry.Append(vals[j]); entry.Append(NS_LITERAL_STRING("\n")); diff --git a/mozilla/directory/xpcom/base/src/nsLDAPConnection.cpp b/mozilla/directory/xpcom/base/src/nsLDAPConnection.cpp index b41c4e36e83..7ccafbe45f2 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPConnection.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPConnection.cpp @@ -40,6 +40,7 @@ #include "nsLDAPInternal.h" #include "nsIServiceManager.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIComponentManager.h" #include "nsLDAPConnection.h" #include "nsLDAPMessage.h" @@ -307,7 +308,7 @@ nsLDAPConnection::GetBindName(PRUnichar **_retval) // otherwise, hand out a copy of the bind name // - *_retval = mBindName->ToNewUnicode(); + *_retval = ToNewUnicode(*mBindName); if (!(*_retval)) { return NS_ERROR_OUT_OF_MEMORY; } @@ -328,8 +329,8 @@ nsLDAPConnection::GetLdErrno(PRUnichar **matched, PRUnichar **errString, NS_ENSURE_ARG_POINTER(_retval); *_retval = ldap_get_lderrno(mConnectionHandle, &match, &err); - *matched = NS_ConvertUTF8toUCS2(match).ToNewUnicode(); - *errString = NS_ConvertUTF8toUCS2(err).ToNewUnicode(); + *matched = ToNewUnicode(NS_ConvertUTF8toUCS2(match)); + *errString = ToNewUnicode(NS_ConvertUTF8toUCS2(err)); return NS_OK; } @@ -353,7 +354,7 @@ nsLDAPConnection::GetErrorString(PRUnichar **_retval) // make a copy using the XPCOM shared allocator // - *_retval = NS_ConvertUTF8toUCS2(rv).ToNewUnicode(); + *_retval = ToNewUnicode(NS_ConvertUTF8toUCS2(rv)); if (!*_retval) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/directory/xpcom/base/src/nsLDAPMessage.cpp b/mozilla/directory/xpcom/base/src/nsLDAPMessage.cpp index dea950f97cd..db11c391ab9 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPMessage.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPMessage.cpp @@ -38,6 +38,7 @@ #include "nsDebug.h" #include "nsCRT.h" #include "nsLDAPConnection.h" +#include "nsReadableUtils.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsLDAPMessage, nsILDAPMessage); @@ -457,7 +458,7 @@ NS_IMETHODIMP nsLDAPMessage::GetDn(PRUnichar **aDn) // get a copy made with the shared allocator, and dispose of the original // - *aDn = NS_ConvertUTF8toUCS2(rawDn).ToNewUnicode(); + *aDn = ToNewUnicode(NS_ConvertUTF8toUCS2(rawDn)); ldap_memfree(rawDn); if (!*aDn) { @@ -521,7 +522,7 @@ nsLDAPMessage::GetValues(const char *aAttr, PRUint32 *aCount, // PRUint32 i; for ( i = 0 ; i < numVals ; i++ ) { - (*aValues)[i] = NS_ConvertUTF8toUCS2(values[i]).ToNewUnicode(); + (*aValues)[i] = ToNewUnicode(NS_ConvertUTF8toUCS2(values[i])); if ( ! (*aValues)[i] ) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(i, aValues); return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/directory/xpcom/base/src/nsLDAPServer.cpp b/mozilla/directory/xpcom/base/src/nsLDAPServer.cpp index f026f12b1d0..b0cfb8818b6 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPServer.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPServer.cpp @@ -33,6 +33,7 @@ */ #include "nsLDAPServer.h" +#include "nsReadableUtils.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsLDAPServer, nsILDAPServer) @@ -55,7 +56,7 @@ NS_IMETHODIMP nsLDAPServer::GetKey(PRUnichar **_retval) return NS_ERROR_NULL_POINTER; } - *_retval = mKey.ToNewUnicode(); + *_retval = ToNewUnicode(mKey); if (!*_retval) { return NS_ERROR_OUT_OF_MEMORY; } @@ -76,7 +77,7 @@ NS_IMETHODIMP nsLDAPServer::GetUsername(PRUnichar **_retval) return NS_ERROR_NULL_POINTER; } - *_retval = mUsername.ToNewUnicode(); + *_retval = ToNewUnicode(mUsername); if (!*_retval) { return NS_ERROR_OUT_OF_MEMORY; } @@ -97,7 +98,7 @@ NS_IMETHODIMP nsLDAPServer::GetPassword(PRUnichar **_retval) return NS_ERROR_NULL_POINTER; } - *_retval = mPassword.ToNewUnicode(); + *_retval = ToNewUnicode(mPassword); if (!*_retval) { return NS_ERROR_OUT_OF_MEMORY; } @@ -118,7 +119,7 @@ NS_IMETHODIMP nsLDAPServer::GetBinddn(PRUnichar **_retval) return NS_ERROR_NULL_POINTER; } - *_retval = mBindDN.ToNewUnicode(); + *_retval = ToNewUnicode(mBindDN); if (!*_retval) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/directory/xpcom/base/src/nsLDAPService.cpp b/mozilla/directory/xpcom/base/src/nsLDAPService.cpp index 4088ebc958c..1c6dc03d66a 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPService.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPService.cpp @@ -37,6 +37,7 @@ #include "nsLDAPConnection.h" #include "nsLDAPOperation.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIConsoleService.h" #include "nsILDAPURL.h" @@ -1006,22 +1007,21 @@ char * nsLDAPService::NextToken(nsReadingIterator & aIter, nsReadingIterator & aIterEnd) { - nsAutoString token; - // move past any leading whitespace // while ( aIter != aIterEnd && nsCRT::IsAsciiSpace(*aIter) ) { ++aIter; } + nsAString::const_iterator start(aIter); + // copy the token into our local variable // while ( aIter != aIterEnd && !nsCRT::IsAsciiSpace(*aIter) ) { - token.Append(*aIter); ++aIter; } - return NS_ConvertUCS2toUTF8(token).ToNewCString(); + return ToNewUTF8String(Substring(start, aIter)); } // Note that these 2 functions might go away in the future, see bug 84186. @@ -1038,7 +1038,7 @@ nsLDAPService::UCS2toUTF8(const nsAReadableString &aString, return NS_ERROR_NULL_POINTER; } - str = NS_ConvertUCS2toUTF8(aString).ToNewCString(); + str = ToNewUTF8String(aString); if (!str) { NS_ERROR("nsLDAPService::UCS2toUTF8: out of memory "); return NS_ERROR_OUT_OF_MEMORY; @@ -1053,14 +1053,6 @@ NS_IMETHODIMP nsLDAPService::UTF8toUCS2(const char *aString, nsAWritableString &_retval) { - PRUnichar *str; - - str = NS_ConvertUTF8toUCS2(aString).ToNewUnicode(); - if (!str) { - NS_ERROR("nsLDAPService::UTF8toUCS2: out of memory "); - return NS_ERROR_OUT_OF_MEMORY; - } - - _retval = str; + _retval = NS_ConvertUTF8toUCS2(aString); return NS_OK; } diff --git a/mozilla/directory/xpcom/base/src/nsLDAPURL.cpp b/mozilla/directory/xpcom/base/src/nsLDAPURL.cpp index f4f1d45e2d3..8082f8c3620 100644 --- a/mozilla/directory/xpcom/base/src/nsLDAPURL.cpp +++ b/mozilla/directory/xpcom/base/src/nsLDAPURL.cpp @@ -34,6 +34,7 @@ */ #include "nsLDAPURL.h" +#include "nsReadableUtils.h" // The two schemes we support, LDAP and LDAPS // @@ -109,7 +110,7 @@ nsLDAPURL::GetSpec(char **_retval) spec.Append('?'); while (index < count) { - spec.Append((mAttributes->CStringAt(index++))->ToNewCString()); + spec.Append(*(mAttributes->CStringAt(index++))); if (index < count) { spec.Append(','); } @@ -131,7 +132,7 @@ nsLDAPURL::GetSpec(char **_retval) } } - *_retval = spec.ToNewCString(); + *_retval = ToNewCString(spec); if (!*_retval) { NS_ERROR("nsLDAPURL::GetSpec: out of memory "); return NS_ERROR_OUT_OF_MEMORY; @@ -291,7 +292,7 @@ nsLDAPURL::GetHost(char **_retval) return NS_ERROR_NULL_POINTER; } - *_retval = mHost.ToNewCString(); + *_retval = ToNewCString(mHost); if (!*_retval) { NS_ERROR("nsLDAPURL::GetHost: out of memory "); return NS_ERROR_OUT_OF_MEMORY; @@ -350,7 +351,7 @@ NS_IMETHODIMP nsLDAPURL::GetPath(char **_retval) return NS_ERROR_NULL_POINTER; } - *_retval = mDN.ToNewCString(); + *_retval = ToNewCString(mDN); if (!*_retval) { NS_ERROR("nsLDAPURL::GetPath: out of memory "); return NS_ERROR_OUT_OF_MEMORY; @@ -411,7 +412,7 @@ NS_IMETHODIMP nsLDAPURL::GetDn(char **_retval) return NS_ERROR_NULL_POINTER; } - *_retval = mDN.ToNewCString(); + *_retval = ToNewCString(mDN); if (!*_retval) { NS_ERROR("nsLDAPURL::GetDN: out of memory "); return NS_ERROR_OUT_OF_MEMORY; @@ -449,7 +450,7 @@ NS_IMETHODIMP nsLDAPURL::GetAttributes(PRUint32 *aCount, char ***_retval) // Loop through the string array, and build up the C-array. // while (index < count) { - if (!(cArray[index] = (mAttributes->CStringAt(index))->ToNewCString())) { + if (!(cArray[index] = ToNewCString(*(mAttributes->CStringAt(index))))) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(index, cArray); NS_ERROR("nsLDAPURL::GetAttributes: out of memory "); return NS_ERROR_OUT_OF_MEMORY; @@ -567,7 +568,7 @@ NS_IMETHODIMP nsLDAPURL::GetFilter(char **_retval) return NS_ERROR_NULL_POINTER; } - *_retval = mFilter.ToNewCString(); + *_retval = ToNewCString(mFilter); if (!*_retval) { NS_ERROR("nsLDAPURL::GetFilter: out of memory "); return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/docshell/base/nsDefaultURIFixup.cpp b/mozilla/docshell/base/nsDefaultURIFixup.cpp index ed97bdd46dc..be864e08bd5 100644 --- a/mozilla/docshell/base/nsDefaultURIFixup.cpp +++ b/mozilla/docshell/base/nsDefaultURIFixup.cpp @@ -21,6 +21,7 @@ */ #include "nsString.h" +#include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsEscape.h" @@ -304,7 +305,7 @@ nsresult nsDefaultURIFixup::KeywordURIFixup(const PRUnichar* aStringURI, if(keyword) { nsCAutoString keywordSpec("keyword:"); - char *utf8Spec = uriString.ToNewUTF8String(); + char *utf8Spec = ToNewUTF8String(uriString); if(utf8Spec) { char* escapedUTF8Spec = nsEscape(utf8Spec, url_Path); diff --git a/mozilla/docshell/base/nsDocShell.cpp b/mozilla/docshell/base/nsDocShell.cpp index f662a5d4022..88bcee93cef 100644 --- a/mozilla/docshell/base/nsDocShell.cpp +++ b/mozilla/docshell/base/nsDocShell.cpp @@ -40,6 +40,7 @@ #include "prprf.h" #include "nsIMarkupDocumentViewer.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIChromeEventHandler.h" #include "nsIDOMWindowInternal.h" #include "nsIWebBrowserChrome.h" @@ -1126,7 +1127,7 @@ nsDocShell::GetCharset(PRUnichar** aCharset) NS_ENSURE_TRUE(doc, NS_ERROR_FAILURE); nsAutoString charset; NS_ENSURE_SUCCESS(doc->GetDocumentCharacterSet(charset), NS_ERROR_FAILURE); - *aCharset = charset.ToNewUnicode(); + *aCharset = ToNewUnicode(charset); return NS_OK; } @@ -1416,7 +1417,7 @@ NS_IMETHODIMP nsDocShell::GetName(PRUnichar ** aName) { NS_ENSURE_ARG_POINTER(aName); - *aName = mName.ToNewUnicode(); + *aName = ToNewUnicode(mName); return NS_OK; } @@ -1864,7 +1865,7 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild) if (NS_FAILED(res)) return NS_OK; - // printf("### 1 >>> Adding child. Parent CS = %s. ItemType = %d.\n", parentCS.ToNewCString(), mItemType); + // printf("### 1 >>> Adding child. Parent CS = %s. ItemType = %d.\n", NS_LossyConvertUCS2toASCII(parentCS).get(), mItemType); return NS_OK; } @@ -3083,7 +3084,7 @@ nsDocShell::GetTitle(PRUnichar ** aTitle) { NS_ENSURE_ARG_POINTER(aTitle); - *aTitle = mTitle.ToNewUnicode(); + *aTitle = ToNewUnicode(mTitle); return NS_OK; } @@ -4936,7 +4937,7 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor) if (NS_SUCCEEDED(rv) && shell) { *aWasAnchor = PR_TRUE; - char *str = sNewRef.ToNewCString(); + char *str = ToNewCString(sNewRef); // nsUnescape modifies the string that is passed into it. nsUnescape(str); @@ -4965,11 +4966,11 @@ nsDocShell::ScrollIfAnchor(nsIURI * aURI, PRBool * aWasAnchor) nsAutoString aCharset; rv = doc->GetDocumentCharacterSet(aCharset); NS_ENSURE_SUCCESS(rv, NS_ERROR_FAILURE); - char *charsetStr = aCharset.ToNewCString(); + char *charsetStr = ToNewCString(aCharset); NS_ENSURE_TRUE(charsetStr, NS_ERROR_OUT_OF_MEMORY); // Use the saved string - char *uriStr = savedNewRef.ToNewCString(); + char *uriStr = ToNewCString(savedNewRef); if (!uriStr) { nsMemory::Free(charsetStr); return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/docshell/base/nsDocShellLoadInfo.cpp b/mozilla/docshell/base/nsDocShellLoadInfo.cpp index a8319aef410..4cf2e0cea7b 100644 --- a/mozilla/docshell/base/nsDocShellLoadInfo.cpp +++ b/mozilla/docshell/base/nsDocShellLoadInfo.cpp @@ -23,6 +23,7 @@ // Local Includes #include "nsDocShellLoadInfo.h" +#include "nsReadableUtils.h" //***************************************************************************** //*** nsDocShellLoadInfo: Object Management @@ -133,7 +134,7 @@ NS_IMETHODIMP nsDocShellLoadInfo::GetTarget(char** aTarget) { NS_ENSURE_ARG_POINTER(aTarget); - *aTarget = mTarget.ToNewCString(); + *aTarget = ToNewCString(mTarget); return NS_OK; } diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index 310203fe770..aa7ac5c34c7 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -74,6 +74,7 @@ typedef unsigned long HMTX; #include "nsCRT.h" #include "nsVoidArray.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsWidgetsCID.h" #include "nsGfxCIID.h" #include "plevent.h" @@ -524,7 +525,7 @@ nsWebShell::GetURL(PRInt32 aIndex, const PRUnichar** aURLResult) nsXPIDLCString spec; uri->GetSpec(getter_Copies(spec)); - *aURLResult = NS_ConvertASCIItoUCS2(spec).ToNewUnicode(); + *aURLResult = ToNewUnicode(NS_ConvertASCIItoUCS2(spec)); return NS_OK; } diff --git a/mozilla/dom/src/base/nsJSEnvironment.cpp b/mozilla/dom/src/base/nsJSEnvironment.cpp index ea84c3c112d..e398db27f7a 100644 --- a/mozilla/dom/src/base/nsJSEnvironment.cpp +++ b/mozilla/dom/src/base/nsJSEnvironment.cpp @@ -60,6 +60,7 @@ #include "nsIJSRuntimeService.h" #include "nsIPref.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsJSUtils.h" #include "nsIDocShell.h" #include "nsIDocShellTreeItem.h" @@ -216,7 +217,7 @@ NS_ScriptErrorReporter(JSContext *cx, error.AppendWithConversion("Error was suppressed by event handler\n"); #ifdef DEBUG - char *errorStr = error.ToNewCString(); + char *errorStr = ToNewCString(error); if (errorStr) { fprintf(stderr, "%s\n", errorStr); fflush(stderr); diff --git a/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp b/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp index 8a2dec2cb01..dce94804996 100644 --- a/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp +++ b/mozilla/dom/src/jsurl/nsJSProtocolHandler.cpp @@ -41,6 +41,7 @@ #include "nsCRT.h" #include "nsDOMError.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsJSProtocolHandler.h" #include "nsNetUtil.h" @@ -267,7 +268,7 @@ nsresult nsJSThunk::EvaluateScript() } else { // XXXbe this should not decimate! pass back UCS-2 to necko - mResult = result.ToNewCString(); + mResult = ToNewCString(result); mLength = result.Length(); } return rv; diff --git a/mozilla/editor/base/CreateElementTxn.cpp b/mozilla/editor/base/CreateElementTxn.cpp index 3852306711b..81b1f5c6b26 100644 --- a/mozilla/editor/base/CreateElementTxn.cpp +++ b/mozilla/editor/base/CreateElementTxn.cpp @@ -43,6 +43,7 @@ #include "nsISelection.h" #include "nsIDOMText.h" #include "nsIDOMElement.h" +#include "nsReadableUtils.h" //included for new nsEditor::CreateContent() #include "nsIContent.h" @@ -90,7 +91,7 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void) { if (gNoisy) { - char* nodename = mTag.ToNewCString(); + char* nodename = ToNewCString(mTag); printf("Do Create Element parent = %p <%s>, offset = %d\n", mParent.get(), nodename, mOffsetInParent); nsMemory::Free(nodename); diff --git a/mozilla/editor/base/DeleteElementTxn.cpp b/mozilla/editor/base/DeleteElementTxn.cpp index d73f86cb651..9d27da2c58c 100644 --- a/mozilla/editor/base/DeleteElementTxn.cpp +++ b/mozilla/editor/base/DeleteElementTxn.cpp @@ -36,6 +36,8 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsReadableUtils.h" + #include "DeleteElementTxn.h" #ifdef NS_DEBUG #include "nsIDOMElement.h" @@ -90,8 +92,8 @@ NS_IMETHODIMP DeleteElementTxn::DoTransaction(void) if (parentElement) parentElement->GetTagName(parentElementTag); char *c, *p; - c = elementTag.ToNewCString(); - p = parentElementTag.ToNewCString(); + c = ToNewCString(elementTag); + p = ToNewCString(parentElementTag); if (c&&p) { if (gNoisy) @@ -129,8 +131,8 @@ NS_IMETHODIMP DeleteElementTxn::UndoTransaction(void) if (parentElement) parentElement->GetTagName(parentElementTag); char *c, *p; - c = elementTag.ToNewCString(); - p = parentElementTag.ToNewCString(); + c = ToNewCString(elementTag); + p = ToNewCString(parentElementTag); if (c&&p) { if (gNoisy) diff --git a/mozilla/editor/base/InsertElementTxn.cpp b/mozilla/editor/base/InsertElementTxn.cpp index 033a9d6786b..0893b4c7553 100644 --- a/mozilla/editor/base/InsertElementTxn.cpp +++ b/mozilla/editor/base/InsertElementTxn.cpp @@ -40,6 +40,7 @@ #include "nsISelection.h" #include "nsIContent.h" #include "nsIDOMNodeList.h" +#include "nsReadableUtils.h" #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; @@ -84,7 +85,7 @@ NS_IMETHODIMP InsertElementTxn::DoTransaction(void) nsCOMPtrparentAsContent = do_QueryInterface(mParent); nsString namestr; mNode->GetNodeName(namestr); - char* nodename = namestr.ToNewCString(); + char* nodename = ToNewCString(namestr); printf("%p Do Insert Element of %p <%s> into parent %p at offset %d\n", this, nodeAsContent.get(), nodename, parentAsContent.get(), mOffset); diff --git a/mozilla/editor/base/nsEditorService.cpp b/mozilla/editor/base/nsEditorService.cpp index 9becca2ef7b..dcd9ccf380c 100644 --- a/mozilla/editor/base/nsEditorService.cpp +++ b/mozilla/editor/base/nsEditorService.cpp @@ -38,6 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsEditorService.h" +#include "nsReadableUtils.h" nsEditorService::nsEditorService() { diff --git a/mozilla/editor/base/nsEditorShell.cpp b/mozilla/editor/base/nsEditorShell.cpp index de0676581d2..8bed8592fc6 100644 --- a/mozilla/editor/base/nsEditorShell.cpp +++ b/mozilla/editor/base/nsEditorShell.cpp @@ -82,6 +82,7 @@ #include "nsIWindowMediator.h" #include "plevent.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIAppShell.h" #include "nsIAppShellService.h" @@ -887,7 +888,7 @@ nsEditorShell::SetWebShellWindow(nsIDOMWindowInternal* aWin) docShellAsItem->GetName(getter_Copies(name)); nsAutoString str(name); - char* cstr = str.ToNewCString(); + char* cstr = ToNewCString(str); printf("Attaching to WebShellWindow[%s]\n", cstr); nsCRT::free(cstr); #endif @@ -941,7 +942,7 @@ nsEditorShell::GetEditorType(PRUnichar **_retval) if (!_retval) return NS_ERROR_NULL_POINTER; - *_retval = mEditorTypeString.ToNewUnicode(); + *_retval = ToNewUnicode(mEditorTypeString); return NS_OK; } @@ -951,7 +952,7 @@ NS_IMETHODIMP nsEditorShell::GetContentsMIMEType(char * *aContentsMIMEType) { NS_ENSURE_ARG_POINTER(aContentsMIMEType); - *aContentsMIMEType = mContentMIMEType.ToNewCString(); + *aContentsMIMEType = ToNewCString(mContentMIMEType); return NS_OK; } @@ -1014,7 +1015,7 @@ nsEditorShell::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell) nsAutoString errorMsg; errorMsg.AssignWithConversion("Failed to init editor. Unknown editor type \""); errorMsg += mEditorTypeString; errorMsg.AppendWithConversion("\"\n"); - char *errorMsgCString = errorMsg.ToNewCString(); + char *errorMsgCString = ToNewCString(errorMsg); NS_WARNING(errorMsgCString); nsCRT::free(errorMsgCString); #endif @@ -1324,7 +1325,7 @@ nsEditorShell::GetParagraphState(PRBool *aMixed, PRUnichar **_retval) nsAutoString state; err = htmlEditor->GetParagraphState(&bMixed, state); if (!bMixed) - *_retval = state.ToNewUnicode(); + *_retval = ToNewUnicode(state); } return err; } @@ -1350,7 +1351,7 @@ nsEditorShell::GetListState(PRBool *aMixed, PRUnichar **_retval) if (bOL) tagStr.AssignWithConversion("ol"); else if (bUL) tagStr.AssignWithConversion("ul"); else if (bDL) tagStr.AssignWithConversion("dl"); - *_retval = tagStr.ToNewUnicode(); + *_retval = ToNewUnicode(tagStr); } } } @@ -1378,7 +1379,7 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval) if (bLI) tagStr.AssignWithConversion("li"); else if (bDT) tagStr.AssignWithConversion("dt"); else if (bDD) tagStr.AssignWithConversion("dd"); - *_retval = tagStr.ToNewUnicode(); + *_retval = ToNewUnicode(tagStr); } } } @@ -1409,7 +1410,7 @@ nsEditorShell::GetAlignment(PRBool *aMixed, PRUnichar **_retval) tagStr.AssignWithConversion("right"); else if (firstAlign == nsIHTMLEditor::eJustify) tagStr.AssignWithConversion("justify"); - *_retval = tagStr.ToNewUnicode(); + *_retval = ToNewUnicode(tagStr); } } return err; @@ -2220,7 +2221,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi nsAutoString returnVal; returnVal.AssignWithConversion((const char*) url); - *_retval = returnVal.ToNewUnicode(); + *_retval = ToNewUnicode(returnVal); if (!*_retval) res = NS_ERROR_OUT_OF_MEMORY; @@ -2337,11 +2338,11 @@ nsEditorShell::GetDocumentTitle(PRUnichar **title) nsresult res = GetDocumentTitleString(titleStr); if (NS_SUCCEEDED(res)) { - *title = titleStr.ToNewUnicode(); + *title = ToNewUnicode(titleStr); } else { // Don't fail, just return an empty string nsAutoString empty; - *title = empty.ToNewUnicode(); + *title = ToNewUnicode(empty); res = NS_OK; } return res; @@ -3004,7 +3005,7 @@ nsEditorShell::GetContentsAs(const PRUnichar *format, PRUint32 flags, if (editor) err = editor->OutputToString(contentsAs, aFormat, flags); - *aContentsAs = contentsAs.ToNewUnicode(); + *aContentsAs = ToNewUnicode(contentsAs); return err; } @@ -3020,7 +3021,7 @@ nsEditorShell::GetHeadContentsAsHTML(PRUnichar **aHeadContents) if (editor) err = editor->GetHeadContentsAsHTML(headContents); - *aHeadContents = headContents.ToNewUnicode(); + *aHeadContents = ToNewUnicode(headContents); return err; } @@ -4291,7 +4292,7 @@ nsEditorShell::GetSelectedOrParentTableElement(PRUnichar **aTagName, PRInt32 *aS nsAutoString TagName(*aTagName); if (tableEditor) result = tableEditor->GetSelectedOrParentTableElement(*_retval, TagName, *aSelectedCount); - *aTagName = TagName.ToNewUnicode(); + *aTagName = ToNewUnicode(TagName); } break; default: @@ -4457,7 +4458,7 @@ nsEditorShell::GetNextMisspelledWord(PRUnichar **aNextMisspelledWord) DeleteSuggestedWordList(); result = mSpellChecker->NextMisspelledWord(&nextMisspelledWord, &mSuggestedWordList); } - *aNextMisspelledWord = nextMisspelledWord.ToNewUnicode(); + *aNextMisspelledWord = ToNewUnicode(nextMisspelledWord); return result; } @@ -4479,7 +4480,7 @@ nsEditorShell::GetSuggestedWord(PRUnichar **aSuggestedWord) } result = NS_OK; } - *aSuggestedWord = word.ToNewUnicode(); + *aSuggestedWord = ToNewUnicode(word); return result; } @@ -4553,7 +4554,7 @@ nsEditorShell::GetPersonalDictionaryWord(PRUnichar **aDictionaryWord) } result = NS_OK; } - *aDictionaryWord = word.ToNewUnicode(); + *aDictionaryWord = ToNewUnicode(word); return result; } @@ -4635,7 +4636,7 @@ nsEditorShell::GetDictionaryList(PRUnichar ***aDictionaryList, PRUint32 *aCount) for (i = 0; i < *aCount; i++) { dictList.StringAt(i, dictStr); - tmpPtr[i] = dictStr.ToNewUnicode(); + tmpPtr[i] = ToNewUnicode(dictStr); } } @@ -4660,7 +4661,7 @@ nsEditorShell::GetCurrentDictionary(PRUnichar **aDictionary) if (NS_FAILED(result)) return result; - *aDictionary = dictStr.ToNewUnicode(); + *aDictionary = ToNewUnicode(dictStr); } return result; diff --git a/mozilla/editor/base/nsHTMLEditor.cpp b/mozilla/editor/base/nsHTMLEditor.cpp index bfe7e2613af..0b0c1499655 100644 --- a/mozilla/editor/base/nsHTMLEditor.cpp +++ b/mozilla/editor/base/nsHTMLEditor.cpp @@ -38,6 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsICaret.h" +#include "nsReadableUtils.h" #include "nsHTMLEditor.h" #include "nsHTMLEditRules.h" @@ -545,7 +546,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock) { nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: ")); assertmsg.Append(tagName); - char* assertstr = assertmsg.ToNewCString(); + char* assertstr = ToNewCString(assertmsg); NS_ASSERTION(*aIsBlock, assertstr); Recycle(assertstr); } diff --git a/mozilla/editor/base/nsHTMLEditorStyle.cpp b/mozilla/editor/base/nsHTMLEditorStyle.cpp index d68ccb86252..5747ffa07f1 100644 --- a/mozilla/editor/base/nsHTMLEditorStyle.cpp +++ b/mozilla/editor/base/nsHTMLEditorStyle.cpp @@ -37,6 +37,8 @@ * ***** END LICENSE BLOCK ***** */ #include "nsICaret.h" +#include "nsReadableUtils.h" + #include "nsHTMLEditor.h" #include "nsHTMLEditRules.h" #include "nsTextEditUtils.h" @@ -827,7 +829,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty, { nsAutoString propString; aProperty->ToString(propString); - char *propCString = propString.ToNewCString(); + char *propCString = ToNewCString(propString); if (gNoisy) { printf("nsTextEditor::GetTextProperty %s\n", propCString); } nsCRT::free(propCString); } diff --git a/mozilla/editor/base/nsInternetCiter.cpp b/mozilla/editor/base/nsInternetCiter.cpp index 37893f5248f..eb53a611e07 100644 --- a/mozilla/editor/base/nsInternetCiter.cpp +++ b/mozilla/editor/base/nsInternetCiter.cpp @@ -39,6 +39,7 @@ #include "nsString.h" +#include "nsReadableUtils.h" #include "nsInternetCiter.h" #include "nsCOMPtr.h" @@ -229,7 +230,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, { #ifdef DEBUG_wrapping nsAutoString debug (Substring(tString, posInString, length-posInString)); - printf("Outer loop: '%s'\n", debug.ToNewCString()); + printf("Outer loop: '%s'\n", NS_LossyConvertUCS2toASCII(debug).get()); #endif // Get the new cite level here since we're at the beginning of a line @@ -309,7 +310,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, #ifdef DEBUG_wrapping nsAutoString debug (Substring(tString, posInString, nextNewline-posInString)); - printf("Unquoted: appending '%s'\n", debug.ToNewCString()); + printf("Unquoted: appending '%s'\n", NS_LossyConvertUCS2toASCII(debug).get()); #endif aOutString.Append(Substring(tString, posInString, nextNewline-posInString)); @@ -332,7 +333,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, { #ifdef DEBUG_wrapping nsAutoString debug (Substring(tString, posInString, nextNewline-posInString)); - printf("Inner loop: '%s'\n", debug.ToNewCString()); + printf("Inner loop: '%s'\n", NS_LossyConvertUCS2toASCII(debug).get()); #endif // If this is a short line, just append it and continue: @@ -344,7 +345,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, ++nextNewline; #ifdef DEBUG_wrapping nsAutoString debug (Substring(tString, posInString, nextNewline - posInString)); - printf("Short line: '%s'\n", debug.ToNewCString()); + printf("Short line: '%s'\n", NS_LossyConvertUCS2toASCII(debug).get()); #endif aOutString += Substring(tString, posInString, nextNewline - posInString); @@ -401,7 +402,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, } // end inner loop within one line of aInString #ifdef DEBUG_wrapping printf("---------\nEnd inner loop: out string is now '%s'\n-----------\n", - aOutString.ToNewCString()); + NS_LossyConvertUCS2toASCII(aOutString).get()); #endif } // end outer loop over lines of aInString diff --git a/mozilla/editor/composer/src/nsEditorShell.cpp b/mozilla/editor/composer/src/nsEditorShell.cpp index de0676581d2..8bed8592fc6 100644 --- a/mozilla/editor/composer/src/nsEditorShell.cpp +++ b/mozilla/editor/composer/src/nsEditorShell.cpp @@ -82,6 +82,7 @@ #include "nsIWindowMediator.h" #include "plevent.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIAppShell.h" #include "nsIAppShellService.h" @@ -887,7 +888,7 @@ nsEditorShell::SetWebShellWindow(nsIDOMWindowInternal* aWin) docShellAsItem->GetName(getter_Copies(name)); nsAutoString str(name); - char* cstr = str.ToNewCString(); + char* cstr = ToNewCString(str); printf("Attaching to WebShellWindow[%s]\n", cstr); nsCRT::free(cstr); #endif @@ -941,7 +942,7 @@ nsEditorShell::GetEditorType(PRUnichar **_retval) if (!_retval) return NS_ERROR_NULL_POINTER; - *_retval = mEditorTypeString.ToNewUnicode(); + *_retval = ToNewUnicode(mEditorTypeString); return NS_OK; } @@ -951,7 +952,7 @@ NS_IMETHODIMP nsEditorShell::GetContentsMIMEType(char * *aContentsMIMEType) { NS_ENSURE_ARG_POINTER(aContentsMIMEType); - *aContentsMIMEType = mContentMIMEType.ToNewCString(); + *aContentsMIMEType = ToNewCString(mContentMIMEType); return NS_OK; } @@ -1014,7 +1015,7 @@ nsEditorShell::InstantiateEditor(nsIDOMDocument *aDoc, nsIPresShell *aPresShell) nsAutoString errorMsg; errorMsg.AssignWithConversion("Failed to init editor. Unknown editor type \""); errorMsg += mEditorTypeString; errorMsg.AppendWithConversion("\"\n"); - char *errorMsgCString = errorMsg.ToNewCString(); + char *errorMsgCString = ToNewCString(errorMsg); NS_WARNING(errorMsgCString); nsCRT::free(errorMsgCString); #endif @@ -1324,7 +1325,7 @@ nsEditorShell::GetParagraphState(PRBool *aMixed, PRUnichar **_retval) nsAutoString state; err = htmlEditor->GetParagraphState(&bMixed, state); if (!bMixed) - *_retval = state.ToNewUnicode(); + *_retval = ToNewUnicode(state); } return err; } @@ -1350,7 +1351,7 @@ nsEditorShell::GetListState(PRBool *aMixed, PRUnichar **_retval) if (bOL) tagStr.AssignWithConversion("ol"); else if (bUL) tagStr.AssignWithConversion("ul"); else if (bDL) tagStr.AssignWithConversion("dl"); - *_retval = tagStr.ToNewUnicode(); + *_retval = ToNewUnicode(tagStr); } } } @@ -1378,7 +1379,7 @@ nsEditorShell::GetListItemState(PRBool *aMixed, PRUnichar **_retval) if (bLI) tagStr.AssignWithConversion("li"); else if (bDT) tagStr.AssignWithConversion("dt"); else if (bDD) tagStr.AssignWithConversion("dd"); - *_retval = tagStr.ToNewUnicode(); + *_retval = ToNewUnicode(tagStr); } } } @@ -1409,7 +1410,7 @@ nsEditorShell::GetAlignment(PRBool *aMixed, PRUnichar **_retval) tagStr.AssignWithConversion("right"); else if (firstAlign == nsIHTMLEditor::eJustify) tagStr.AssignWithConversion("justify"); - *_retval = tagStr.ToNewUnicode(); + *_retval = ToNewUnicode(tagStr); } } return err; @@ -2220,7 +2221,7 @@ nsEditorShell::GetLocalFileURL(nsIDOMWindowInternal *parent, const PRUnichar *fi nsAutoString returnVal; returnVal.AssignWithConversion((const char*) url); - *_retval = returnVal.ToNewUnicode(); + *_retval = ToNewUnicode(returnVal); if (!*_retval) res = NS_ERROR_OUT_OF_MEMORY; @@ -2337,11 +2338,11 @@ nsEditorShell::GetDocumentTitle(PRUnichar **title) nsresult res = GetDocumentTitleString(titleStr); if (NS_SUCCEEDED(res)) { - *title = titleStr.ToNewUnicode(); + *title = ToNewUnicode(titleStr); } else { // Don't fail, just return an empty string nsAutoString empty; - *title = empty.ToNewUnicode(); + *title = ToNewUnicode(empty); res = NS_OK; } return res; @@ -3004,7 +3005,7 @@ nsEditorShell::GetContentsAs(const PRUnichar *format, PRUint32 flags, if (editor) err = editor->OutputToString(contentsAs, aFormat, flags); - *aContentsAs = contentsAs.ToNewUnicode(); + *aContentsAs = ToNewUnicode(contentsAs); return err; } @@ -3020,7 +3021,7 @@ nsEditorShell::GetHeadContentsAsHTML(PRUnichar **aHeadContents) if (editor) err = editor->GetHeadContentsAsHTML(headContents); - *aHeadContents = headContents.ToNewUnicode(); + *aHeadContents = ToNewUnicode(headContents); return err; } @@ -4291,7 +4292,7 @@ nsEditorShell::GetSelectedOrParentTableElement(PRUnichar **aTagName, PRInt32 *aS nsAutoString TagName(*aTagName); if (tableEditor) result = tableEditor->GetSelectedOrParentTableElement(*_retval, TagName, *aSelectedCount); - *aTagName = TagName.ToNewUnicode(); + *aTagName = ToNewUnicode(TagName); } break; default: @@ -4457,7 +4458,7 @@ nsEditorShell::GetNextMisspelledWord(PRUnichar **aNextMisspelledWord) DeleteSuggestedWordList(); result = mSpellChecker->NextMisspelledWord(&nextMisspelledWord, &mSuggestedWordList); } - *aNextMisspelledWord = nextMisspelledWord.ToNewUnicode(); + *aNextMisspelledWord = ToNewUnicode(nextMisspelledWord); return result; } @@ -4479,7 +4480,7 @@ nsEditorShell::GetSuggestedWord(PRUnichar **aSuggestedWord) } result = NS_OK; } - *aSuggestedWord = word.ToNewUnicode(); + *aSuggestedWord = ToNewUnicode(word); return result; } @@ -4553,7 +4554,7 @@ nsEditorShell::GetPersonalDictionaryWord(PRUnichar **aDictionaryWord) } result = NS_OK; } - *aDictionaryWord = word.ToNewUnicode(); + *aDictionaryWord = ToNewUnicode(word); return result; } @@ -4635,7 +4636,7 @@ nsEditorShell::GetDictionaryList(PRUnichar ***aDictionaryList, PRUint32 *aCount) for (i = 0; i < *aCount; i++) { dictList.StringAt(i, dictStr); - tmpPtr[i] = dictStr.ToNewUnicode(); + tmpPtr[i] = ToNewUnicode(dictStr); } } @@ -4660,7 +4661,7 @@ nsEditorShell::GetCurrentDictionary(PRUnichar **aDictionary) if (NS_FAILED(result)) return result; - *aDictionary = dictStr.ToNewUnicode(); + *aDictionary = ToNewUnicode(dictStr); } return result; diff --git a/mozilla/editor/libeditor/base/CreateElementTxn.cpp b/mozilla/editor/libeditor/base/CreateElementTxn.cpp index 3852306711b..81b1f5c6b26 100644 --- a/mozilla/editor/libeditor/base/CreateElementTxn.cpp +++ b/mozilla/editor/libeditor/base/CreateElementTxn.cpp @@ -43,6 +43,7 @@ #include "nsISelection.h" #include "nsIDOMText.h" #include "nsIDOMElement.h" +#include "nsReadableUtils.h" //included for new nsEditor::CreateContent() #include "nsIContent.h" @@ -90,7 +91,7 @@ NS_IMETHODIMP CreateElementTxn::DoTransaction(void) { if (gNoisy) { - char* nodename = mTag.ToNewCString(); + char* nodename = ToNewCString(mTag); printf("Do Create Element parent = %p <%s>, offset = %d\n", mParent.get(), nodename, mOffsetInParent); nsMemory::Free(nodename); diff --git a/mozilla/editor/libeditor/base/DeleteElementTxn.cpp b/mozilla/editor/libeditor/base/DeleteElementTxn.cpp index d73f86cb651..9d27da2c58c 100644 --- a/mozilla/editor/libeditor/base/DeleteElementTxn.cpp +++ b/mozilla/editor/libeditor/base/DeleteElementTxn.cpp @@ -36,6 +36,8 @@ * * ***** END LICENSE BLOCK ***** */ +#include "nsReadableUtils.h" + #include "DeleteElementTxn.h" #ifdef NS_DEBUG #include "nsIDOMElement.h" @@ -90,8 +92,8 @@ NS_IMETHODIMP DeleteElementTxn::DoTransaction(void) if (parentElement) parentElement->GetTagName(parentElementTag); char *c, *p; - c = elementTag.ToNewCString(); - p = parentElementTag.ToNewCString(); + c = ToNewCString(elementTag); + p = ToNewCString(parentElementTag); if (c&&p) { if (gNoisy) @@ -129,8 +131,8 @@ NS_IMETHODIMP DeleteElementTxn::UndoTransaction(void) if (parentElement) parentElement->GetTagName(parentElementTag); char *c, *p; - c = elementTag.ToNewCString(); - p = parentElementTag.ToNewCString(); + c = ToNewCString(elementTag); + p = ToNewCString(parentElementTag); if (c&&p) { if (gNoisy) diff --git a/mozilla/editor/libeditor/base/InsertElementTxn.cpp b/mozilla/editor/libeditor/base/InsertElementTxn.cpp index 033a9d6786b..0893b4c7553 100644 --- a/mozilla/editor/libeditor/base/InsertElementTxn.cpp +++ b/mozilla/editor/libeditor/base/InsertElementTxn.cpp @@ -40,6 +40,7 @@ #include "nsISelection.h" #include "nsIContent.h" #include "nsIDOMNodeList.h" +#include "nsReadableUtils.h" #ifdef NS_DEBUG static PRBool gNoisy = PR_FALSE; @@ -84,7 +85,7 @@ NS_IMETHODIMP InsertElementTxn::DoTransaction(void) nsCOMPtrparentAsContent = do_QueryInterface(mParent); nsString namestr; mNode->GetNodeName(namestr); - char* nodename = namestr.ToNewCString(); + char* nodename = ToNewCString(namestr); printf("%p Do Insert Element of %p <%s> into parent %p at offset %d\n", this, nodeAsContent.get(), nodename, parentAsContent.get(), mOffset); diff --git a/mozilla/editor/libeditor/base/nsEditorService.cpp b/mozilla/editor/libeditor/base/nsEditorService.cpp index 9becca2ef7b..dcd9ccf380c 100644 --- a/mozilla/editor/libeditor/base/nsEditorService.cpp +++ b/mozilla/editor/libeditor/base/nsEditorService.cpp @@ -38,6 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsEditorService.h" +#include "nsReadableUtils.h" nsEditorService::nsEditorService() { diff --git a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp index bfe7e2613af..0b0c1499655 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditor.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditor.cpp @@ -38,6 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsICaret.h" +#include "nsReadableUtils.h" #include "nsHTMLEditor.h" #include "nsHTMLEditRules.h" @@ -545,7 +546,7 @@ nsHTMLEditor::NodeIsBlockStatic(nsIDOMNode *aNode, PRBool *aIsBlock) { nsAutoString assertmsg (NS_LITERAL_STRING("Parser and editor disagree on blockness: ")); assertmsg.Append(tagName); - char* assertstr = assertmsg.ToNewCString(); + char* assertstr = ToNewCString(assertmsg); NS_ASSERTION(*aIsBlock, assertstr); Recycle(assertstr); } diff --git a/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp b/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp index d68ccb86252..5747ffa07f1 100644 --- a/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp +++ b/mozilla/editor/libeditor/html/nsHTMLEditorStyle.cpp @@ -37,6 +37,8 @@ * ***** END LICENSE BLOCK ***** */ #include "nsICaret.h" +#include "nsReadableUtils.h" + #include "nsHTMLEditor.h" #include "nsHTMLEditRules.h" #include "nsTextEditUtils.h" @@ -827,7 +829,7 @@ nsHTMLEditor::GetInlinePropertyBase(nsIAtom *aProperty, { nsAutoString propString; aProperty->ToString(propString); - char *propCString = propString.ToNewCString(); + char *propCString = ToNewCString(propString); if (gNoisy) { printf("nsTextEditor::GetTextProperty %s\n", propCString); } nsCRT::free(propCString); } diff --git a/mozilla/editor/libeditor/text/nsInternetCiter.cpp b/mozilla/editor/libeditor/text/nsInternetCiter.cpp index 37893f5248f..eb53a611e07 100644 --- a/mozilla/editor/libeditor/text/nsInternetCiter.cpp +++ b/mozilla/editor/libeditor/text/nsInternetCiter.cpp @@ -39,6 +39,7 @@ #include "nsString.h" +#include "nsReadableUtils.h" #include "nsInternetCiter.h" #include "nsCOMPtr.h" @@ -229,7 +230,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, { #ifdef DEBUG_wrapping nsAutoString debug (Substring(tString, posInString, length-posInString)); - printf("Outer loop: '%s'\n", debug.ToNewCString()); + printf("Outer loop: '%s'\n", NS_LossyConvertUCS2toASCII(debug).get()); #endif // Get the new cite level here since we're at the beginning of a line @@ -309,7 +310,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, #ifdef DEBUG_wrapping nsAutoString debug (Substring(tString, posInString, nextNewline-posInString)); - printf("Unquoted: appending '%s'\n", debug.ToNewCString()); + printf("Unquoted: appending '%s'\n", NS_LossyConvertUCS2toASCII(debug).get()); #endif aOutString.Append(Substring(tString, posInString, nextNewline-posInString)); @@ -332,7 +333,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, { #ifdef DEBUG_wrapping nsAutoString debug (Substring(tString, posInString, nextNewline-posInString)); - printf("Inner loop: '%s'\n", debug.ToNewCString()); + printf("Inner loop: '%s'\n", NS_LossyConvertUCS2toASCII(debug).get()); #endif // If this is a short line, just append it and continue: @@ -344,7 +345,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, ++nextNewline; #ifdef DEBUG_wrapping nsAutoString debug (Substring(tString, posInString, nextNewline - posInString)); - printf("Short line: '%s'\n", debug.ToNewCString()); + printf("Short line: '%s'\n", NS_LossyConvertUCS2toASCII(debug).get()); #endif aOutString += Substring(tString, posInString, nextNewline - posInString); @@ -401,7 +402,7 @@ nsInternetCiter::Rewrap(const nsAReadableString& aInString, } // end inner loop within one line of aInString #ifdef DEBUG_wrapping printf("---------\nEnd inner loop: out string is now '%s'\n-----------\n", - aOutString.ToNewCString()); + NS_LossyConvertUCS2toASCII(aOutString).get()); #endif } // end outer loop over lines of aInString diff --git a/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp b/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp index 714a6b6277b..155584dcf31 100644 --- a/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp +++ b/mozilla/embedding/browser/activex/src/control/WebBrowserContainer.cpp @@ -45,6 +45,7 @@ #include "WebBrowserContainer.h" #include "nsICategoryManager.h" +#include "nsReadableUtils.h" CWebBrowserContainer::CWebBrowserContainer(CMozillaBrowser *pOwner) { @@ -491,7 +492,7 @@ CWebBrowserContainer::GetTitle(PRUnichar * *aTitle) if (!aTitle) return E_INVALIDARG; - *aTitle = m_sTitle.ToNewUnicode(); + *aTitle = ToNewUnicode(m_sTitle); return NS_OK; } diff --git a/mozilla/embedding/browser/gtk/src/EmbedPrompter.cpp b/mozilla/embedding/browser/gtk/src/EmbedPrompter.cpp index 2a673cbcc16..c4ac4275aec 100644 --- a/mozilla/embedding/browser/gtk/src/EmbedPrompter.cpp +++ b/mozilla/embedding/browser/gtk/src/EmbedPrompter.cpp @@ -20,6 +20,7 @@ */ #include "EmbedPrompter.h" +#include "nsReadableUtils.h" // call backs from gtk widgets @@ -152,19 +153,19 @@ EmbedPrompter::GetConfirmValue(PRBool *aConfirmValue) void EmbedPrompter::GetTextValue(PRUnichar **aTextValue) { - *aTextValue = mTextValue.ToNewUnicode(); + *aTextValue = ToNewUnicode(mTextValue); } void EmbedPrompter::GetUser(PRUnichar **aUser) { - *aUser = mUser.ToNewUnicode(); + *aUser = ToNewUnicode(mUser); } void EmbedPrompter::GetPassword(PRUnichar **aPass) { - *aPass = mPass.ToNewUnicode(); + *aPass = ToNewUnicode(mPass); } void diff --git a/mozilla/embedding/browser/gtk/src/EmbedWindow.cpp b/mozilla/embedding/browser/gtk/src/EmbedWindow.cpp index cfd06ccb54c..1d26234886f 100644 --- a/mozilla/embedding/browser/gtk/src/EmbedWindow.cpp +++ b/mozilla/embedding/browser/gtk/src/EmbedWindow.cpp @@ -25,6 +25,7 @@ #include #include #include "nsIWidget.h" +#include "nsReadableUtils.h" #include "EmbedWindow.h" #include "EmbedPrivate.h" @@ -316,7 +317,7 @@ EmbedWindow::SetFocus(void) NS_IMETHODIMP EmbedWindow::GetTitle(PRUnichar **aTitle) { - *aTitle = mTitle.ToNewUnicode(); + *aTitle = ToNewUnicode(mTitle); return NS_OK; } @@ -370,7 +371,7 @@ EmbedWindow::OnShowTooltip(PRInt32 aXCoords, PRInt32 aYCoords, { nsAutoString tipText ( aTipText ); - const char* tipString = tipText.ToNewCString(); + const char* tipString = ToNewCString(tipText); if (sTipWindow) gtk_widget_destroy(sTipWindow); diff --git a/mozilla/embedding/browser/gtk/src/gtkmozembed2.cpp b/mozilla/embedding/browser/gtk/src/gtkmozembed2.cpp index c4df30842c8..adaf07065c4 100644 --- a/mozilla/embedding/browser/gtk/src/gtkmozembed2.cpp +++ b/mozilla/embedding/browser/gtk/src/gtkmozembed2.cpp @@ -1078,7 +1078,7 @@ gtk_moz_embed_get_title_unichar (GtkMozEmbed *embed) embedPrivate = (EmbedPrivate *)embed->data; if (embedPrivate->mWindow) - retval = embedPrivate->mWindow->mTitle.ToNewUnicode(); + retval = ToNewUnicode(embedPrivate->mWindow->mTitle); return retval; } diff --git a/mozilla/embedding/browser/photon/src/PromptService.cpp b/mozilla/embedding/browser/photon/src/PromptService.cpp index 7cd19e34122..d9ec7aadc83 100644 --- a/mozilla/embedding/browser/photon/src/PromptService.cpp +++ b/mozilla/embedding/browser/photon/src/PromptService.cpp @@ -46,6 +46,7 @@ #include "nsCOMPtr.h" #include "nsMemory.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIDOMWindow.h" #include "nsIEmbeddingSiteWindow.h" #include "nsIFactory.h" @@ -119,7 +120,7 @@ NS_IMETHODIMP CPromptService::Alert(nsIDOMWindow *parent, const PRUnichar *dialo nsString mTitle(dialogTitle); nsString mText(text); CWebBrowserContainer *w = GetWebBrowser( parent ); - w->InvokeDialogCallback(Pt_MOZ_DIALOG_ALERT, mTitle.ToNewCString(), mText.ToNewCString(), nsnull, nsnull); + w->InvokeDialogCallback(Pt_MOZ_DIALOG_ALERT, ToNewCString(mTitle), ToNewCString(mText), nsnull, nsnull); return NS_OK; } @@ -136,8 +137,8 @@ NS_IMETHODIMP CPromptService::AlertCheck(nsIDOMWindow *parent, int ret; CWebBrowserContainer *w = GetWebBrowser( parent ); - w->InvokeDialogCallback(Pt_MOZ_DIALOG_ALERT, mTitle.ToNewCString(), mText.ToNewCString(), \ - mMsg.ToNewCString(), &ret); + w->InvokeDialogCallback(Pt_MOZ_DIALOG_ALERT, ToNewCString(mTitle), ToNewCString(mText), \ + ToNewCString(mMsg), &ret); *checkValue = ret; return NS_OK; @@ -153,7 +154,7 @@ NS_IMETHODIMP CPromptService::Confirm(nsIDOMWindow *parent, nsString mText(text); CWebBrowserContainer *w = GetWebBrowser( parent ); - if (w->InvokeDialogCallback(Pt_MOZ_DIALOG_CONFIRM, mTitle.ToNewCString(), mText.ToNewCString(), nsnull, nsnull) == Pt_CONTINUE) + if (w->InvokeDialogCallback(Pt_MOZ_DIALOG_CONFIRM, ToNewCString(mTitle), ToNewCString(mText), nsnull, nsnull) == Pt_CONTINUE) *_retval = PR_TRUE; else *_retval = PR_FALSE; @@ -187,8 +188,8 @@ NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent, CWebBrowserContainer *w = GetWebBrowser( parent ); - if (w->InvokeDialogCallback(Pt_MOZ_DIALOG_CONFIRM, mTitle.ToNewCString(), mText.ToNewCString(), \ - mMsg.ToNewCString(), &ret) == Pt_CONTINUE) + if (w->InvokeDialogCallback(Pt_MOZ_DIALOG_CONFIRM, ToNewCString(mTitle), ToNewCString(mText), \ + ToNewCString(mMsg), &ret) == Pt_CONTINUE) *_retval = PR_TRUE; else *_retval = PR_FALSE; @@ -225,15 +226,15 @@ NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, cbinfo.cbdata = &auth; memset(&auth, 0, sizeof(PtMozillaAuthenticateCb_t)); - auth.title = mTitle.ToNewCString(); - auth.realm = mRealm.ToNewCString(); + auth.title = ToNewCString(mTitle); + auth.realm = ToNewCString(mRealm); if (PtInvokeCallbackList(cb, (PtWidget_t *)moz, &cbinfo) == Pt_CONTINUE) { nsCString mUser(auth.user); nsCString mPass(auth.pass); - *username = mUser.ToNewUnicode(); - *password = mPass.ToNewUnicode(); + *username = ToNewUnicode(mUser); + *password = ToNewUnicode(mPass); *_retval = PR_TRUE; } else diff --git a/mozilla/embedding/browser/photon/src/PtMozilla.cpp b/mozilla/embedding/browser/photon/src/PtMozilla.cpp index 9f44010a54c..596ac6e2c0e 100644 --- a/mozilla/embedding/browser/photon/src/PtMozilla.cpp +++ b/mozilla/embedding/browser/photon/src/PtMozilla.cpp @@ -57,6 +57,7 @@ #include "nsIFocusController.h" #include "PromptService.h" +#include "nsReadableUtils.h" #include "nsIViewManager.h" #include "nsIPresShell.h" @@ -547,8 +548,7 @@ static void mozilla_modify( PtWidget_t *widget, PtArg_t const *argt ) { case Pt_ARG_MOZ_ENCODING: { nsCString mStr( (char*)argt->value ); - PRUnichar *ustring = mStr.ToNewUnicode(); - moz->MyBrowser->mPrefs->SetUnicharPref( "intl.charset.default", ustring ); + moz->MyBrowser->mPrefs->SetUnicharPref( "intl.charset.default", mStr.get() ); } break; @@ -596,8 +596,7 @@ static void mozilla_modify( PtWidget_t *widget, PtArg_t const *argt ) { nsCString searchString( wdata->FindInfo.szString ); nsCOMPtr finder( do_GetInterface( moz->MyBrowser->WebBrowser ) ); - PRUnichar *u = searchString.ToNewUnicode( ); - finder->SetSearchString( u ); + finder->SetSearchString( searchString.get() ); finder->SetMatchCase( wdata->FindInfo.flags & FINDFLAG_MATCH_CASE ); finder->SetFindBackwards( wdata->FindInfo.flags & FINDFLAG_GO_BACKWARDS ); @@ -740,10 +739,7 @@ static int mozilla_get_info(PtWidget_t *widget, PtArg_t *argt) PRUnichar *charset = nsnull; moz->MyBrowser->mPrefs->GetLocalizedUnicharPref( "intl.charset.default", &charset ); - nsAutoString str( charset ); - const char *s=NS_ConvertUCS2toUTF8(str).get(); - - strcpy( (char*)argt->value, s ); + strcpy( (char*)argt->value, NS_ConvertUCS2toUTF8(charset).get() ); } break; @@ -764,7 +760,7 @@ static int mozilla_get_info(PtWidget_t *widget, PtArg_t *argt) entry->GetURI( &url ); nsString stitle( title ); - strncpy( HistoryReplyBuf[j].title, stitle.ToNewCString(), 127 ); + strncpy( HistoryReplyBuf[j].title, ToNewCString(stitle), 127 ); HistoryReplyBuf[j].title[127] = '\0'; char *urlspec; @@ -796,32 +792,22 @@ static void mozilla_set_pref( PtWidget_t *widget, char *option, char *value ) { /* HTML Options */ if( !strcmp( option, "A:visited color" ) ) { - nsCString mStr( value ); - PRUnichar *ustring = mStr.ToNewUnicode(); - moz->MyBrowser->mPrefs->SetUnicharPref( "browser.visited_color", ustring ); + moz->MyBrowser->mPrefs->SetUnicharPref( "browser.visited_color", NS_ConvertASCIItoUCS2(value).get() ); } else if( !strcmp( option, "A:link color" ) ) { - nsCString mStr( value ); - PRUnichar *ustring = mStr.ToNewUnicode(); - moz->MyBrowser->mPrefs->SetUnicharPref( "browser.anchor_color", ustring ); + moz->MyBrowser->mPrefs->SetUnicharPref( "browser.anchor_color", NS_ConvertASCIItoUCS2(value).get() ); } /* the mozserver already has A:link color == browser.anchor_color for this */ // else if( !strcmp( option, "A:active color" ) ) { -// nsCString mStr( value ); -// PRUnichar *ustring = mStr.ToNewUnicode(); -// moz->MyBrowser->mPrefs->SetUnicharPref( "browser.anchor_color", ustring ); +// moz->MyBrowser->mPrefs->SetUnicharPref( "browser.anchor_color", NS_ConvertASCIItoUCS2(value).get() ); // } else if( !strcmp( option, "BODY color" ) ) { - nsCString mStr( value ); - PRUnichar *ustring = mStr.ToNewUnicode(); - moz->MyBrowser->mPrefs->SetUnicharPref( "browser.display.foreground_color", ustring ); + moz->MyBrowser->mPrefs->SetUnicharPref( "browser.display.foreground_color", NS_ConvertASCIItoUCS2(value).get() ); } else if( !strcmp( option, "BODY background" ) ) { - nsCString mStr( value ); - PRUnichar *ustring = mStr.ToNewUnicode(); - moz->MyBrowser->mPrefs->SetUnicharPref( "browser.display.background_color", ustring ); + moz->MyBrowser->mPrefs->SetUnicharPref( "browser.display.background_color", NS_ConvertASCIItoUCS2(value).get() ); } else if( !strcmp( option, "bIgnoreDocumentAttributes" ) ) moz->MyBrowser->mPrefs->SetBoolPref( "browser.display.use_document_colors", stricmp( value, "TRUE" ) ? PR_FALSE : PR_TRUE ); diff --git a/mozilla/embedding/browser/photon/src/WebBrowserContainer.cpp b/mozilla/embedding/browser/photon/src/WebBrowserContainer.cpp index ac8cd9d751d..00a9a42143b 100644 --- a/mozilla/embedding/browser/photon/src/WebBrowserContainer.cpp +++ b/mozilla/embedding/browser/photon/src/WebBrowserContainer.cpp @@ -47,6 +47,7 @@ #include "nsIDOMNamedNodeMap.h" #include "nsIWindowCreator.h" #include "nsIWindowWatcher.h" +#include "nsReadableUtils.h" CWebBrowserContainer::CWebBrowserContainer(PtWidget_t *pOwner) { @@ -202,7 +203,7 @@ NS_IMETHODIMP CWebBrowserContainer::OnShowContextMenu(PRUint32 aContextFlags, ns } if( moz->rightClickUrl ) free( moz->rightClickUrl ); - moz->rightClickUrl = strdup( rightClickUrl.ToNewCString() ); + moz->rightClickUrl = ToNewCString(rightClickUrl); return NS_OK; } @@ -854,7 +855,7 @@ NS_IMETHODIMP CWebBrowserContainer::GetTitle(PRUnichar * *aTitle) } NS_IMETHODIMP CWebBrowserContainer::SetTitle(const PRUnichar * aTitle) { nsString mTitleString(aTitle); - InvokeInfoCallback(Pt_MOZ_INFO_TITLE, (unsigned int) 0, mTitleString.ToNewCString()); + InvokeInfoCallback(Pt_MOZ_INFO_TITLE, (unsigned int) 0, ToNewCString(mTitleString)); return NS_OK; } @@ -913,7 +914,7 @@ CWebBrowserContainer::SetStatus(PRUint32 statusType, const PRUnichar *status) if (type != 0) - InvokeInfoCallback(type, (unsigned int) 0, mStatus.ToNewCString()); + InvokeInfoCallback(type, (unsigned int) 0, ToNewCString(mStatus)); return NS_OK; } diff --git a/mozilla/embedding/browser/powerplant/source/CWebBrowserChrome.cpp b/mozilla/embedding/browser/powerplant/source/CWebBrowserChrome.cpp index 4ca7283398d..62de46dbdc8 100644 --- a/mozilla/embedding/browser/powerplant/source/CWebBrowserChrome.cpp +++ b/mozilla/embedding/browser/powerplant/source/CWebBrowserChrome.cpp @@ -29,6 +29,7 @@ #include "nsIGenericFactory.h" #include "nsString.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIURI.h" #include "nsIWebProgress.h" #include "nsIDocShellTreeItem.h" @@ -454,7 +455,7 @@ NS_IMETHODIMP CWebBrowserChrome::GetTitle(PRUnichar * *aTitle) mBrowserWindow->GetDescriptor(pStr); CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, titleStr); - *aTitle = titleStr.ToNewUnicode(); + *aTitle = ToNewUnicode(titleStr); return NS_OK; } diff --git a/mozilla/embedding/browser/powerplant/source/PromptService.cpp b/mozilla/embedding/browser/powerplant/source/PromptService.cpp index 422457fd0f7..176837630c8 100644 --- a/mozilla/embedding/browser/powerplant/source/PromptService.cpp +++ b/mozilla/embedding/browser/powerplant/source/PromptService.cpp @@ -41,6 +41,7 @@ #include "nsIPromptService.h" #include "nsIFactory.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIWindowWatcher.h" #include "nsIServiceManager.h" #include "nsIWebBrowserChrome.h" @@ -344,7 +345,7 @@ NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent, const PRUnichar *dial } responseText->GetDescriptor(pStr); CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr); - *value = ucStr.ToNewUnicode(); + *value = ToNewUnicode(ucStr); if (*value == nsnull) resultErr = NS_ERROR_OUT_OF_MEMORY; @@ -428,7 +429,7 @@ NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, co } userText->GetDescriptor(pStr); CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr); - *username = ucStr.ToNewUnicode(); + *username = ToNewUnicode(ucStr); if (*username == nsnull) resultErr = NS_ERROR_OUT_OF_MEMORY; @@ -438,7 +439,7 @@ NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, co } pwdText->GetDescriptor(pStr); CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr); - *password = ucStr.ToNewUnicode(); + *password = ToNewUnicode(ucStr); if (*password == nsnull) resultErr = NS_ERROR_OUT_OF_MEMORY; @@ -518,7 +519,7 @@ NS_IMETHODIMP CPromptService::PromptPassword(nsIDOMWindow *parent, const PRUnich } pwdText->GetDescriptor(pStr); CPlatformUCSConversion::GetInstance()->PlatformToUCS(pStr, ucStr); - *password = ucStr.ToNewUnicode(); + *password = ToNewUnicode(ucStr); if (*password == nsnull) resultErr = NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp index 0b4d26130ad..608bf8f1b5b 100644 --- a/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp +++ b/mozilla/embedding/browser/webBrowser/nsDocShellTreeOwner.cpp @@ -35,6 +35,7 @@ #include "nsHTMLReflowState.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" // Interfaces needed to be included #include "nsIContextMenuListener.h" @@ -884,7 +885,7 @@ NS_IMETHODIMP DefaultTooltipTextProvider::GetNodeText(nsIDOMNode *aNode, PRUnich } // while not found *_retval = found; - *aText = (found) ? outText.ToNewUnicode() : nsnull; + *aText = (found) ? ToNewUnicode(outText) : nsnull; return NS_OK; } diff --git a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp index 128fb46343e..4940bf49655 100644 --- a/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp +++ b/mozilla/embedding/browser/webBrowser/nsWebBrowser.cpp @@ -29,6 +29,7 @@ #include "nsWidgetsCID.h" //Interfaces Needed +#include "nsReadableUtils.h" #include "nsIComponentManager.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" @@ -375,7 +376,7 @@ NS_IMETHODIMP nsWebBrowser::GetName(PRUnichar** aName) if(mDocShell) mDocShellAsItem->GetName(aName); else - *aName = mInitInfo->name.ToNewUnicode(); + *aName = ToNewUnicode(mInitInfo->name); return NS_OK; } diff --git a/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp b/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp index 79a3e211efb..38a3476424c 100644 --- a/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp +++ b/mozilla/embedding/components/find/src/nsWebBrowserFind.cpp @@ -41,6 +41,7 @@ #include "nsIDOMDocument.h" #include "nsIFocusController.h" #include "nsISelection.h" +#include "nsReadableUtils.h" #if DEBUG #include "nsIWebNavigation.h" @@ -199,7 +200,7 @@ NS_IMETHODIMP nsWebBrowserFind::FindNext(PRBool *outDidFind) NS_IMETHODIMP nsWebBrowserFind::GetSearchString(PRUnichar * *aSearchString) { NS_ENSURE_ARG_POINTER(aSearchString); - *aSearchString = mSearchString.ToNewUnicode(); + *aSearchString = ToNewUnicode(mSearchString); return NS_OK; } diff --git a/mozilla/embedding/components/windowwatcher/src/nsDialogParamBlock.cpp b/mozilla/embedding/components/windowwatcher/src/nsDialogParamBlock.cpp index afaa1639ddd..ea79d49d81d 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsDialogParamBlock.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsDialogParamBlock.cpp @@ -38,6 +38,7 @@ #include "nsDialogParamBlock.h" #include "nsString.h" +#include "nsReadableUtils.h" NS_IMPL_ISUPPORTS1(nsDialogParamBlock, nsIDialogParamBlock) @@ -90,7 +91,7 @@ NS_IMETHODIMP nsDialogParamBlock::GetString(PRInt32 inIndex, PRUnichar **_retval SetNumberStrings(kNumStrings); nsresult rv = InBounds(inIndex, mNumStrings); if (rv == NS_OK) - *_retval = mString[inIndex].ToNewUnicode(); + *_retval = ToNewUnicode(mString[inIndex]); return rv; } diff --git a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp index c14ce8b6ac6..d77cf0ea582 100644 --- a/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp +++ b/mozilla/embedding/components/windowwatcher/src/nsWindowWatcher.cpp @@ -74,6 +74,7 @@ #include "nsIWebNavigation.h" #include "nsIWindowCreator.h" #include "nsIXPConnect.h" +#include "nsReadableUtils.h" #ifdef XP_UNIX // please see bug 78421 for the eventual "right" fix for this @@ -1036,7 +1037,7 @@ void nsWindowWatcher::CheckWindowName(nsString& aName) nsAutoString warn; warn.AssignWithConversion("Illegal character in window name "); warn.Append(aName); - char *cp = warn.ToNewCString(); + char *cp = ToNewCString(warn); NS_WARNING(cp); nsCRT::free(cp); break; diff --git a/mozilla/embedding/qa/testembed/BrowserFrameGlue.cpp b/mozilla/embedding/qa/testembed/BrowserFrameGlue.cpp index 095c09ce207..2ffdd849f07 100644 --- a/mozilla/embedding/qa/testembed/BrowserFrameGlue.cpp +++ b/mozilla/embedding/qa/testembed/BrowserFrameGlue.cpp @@ -64,6 +64,7 @@ #include "TestEmbed.h" #include "BrowserFrm.h" #include "Dialogs.h" +#include "nsReadableUtils.h" ///////////////////////////////////////////////////////////////////////////// // IBrowserFrameGlue implementation @@ -129,7 +130,7 @@ void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameTitle(PRUnichar **aTitle nsString nsTitle; nsTitle.AssignWithConversion(title.GetBuffer(0)); - *aTitle = nsTitle.ToNewUnicode(); + *aTitle = ToNewUnicode(nsTitle); } } diff --git a/mozilla/embedding/qa/testembed/components/PromptService.cpp b/mozilla/embedding/qa/testembed/components/PromptService.cpp index 920bfeccadb..be81880678e 100644 --- a/mozilla/embedding/qa/testembed/components/PromptService.cpp +++ b/mozilla/embedding/qa/testembed/components/PromptService.cpp @@ -48,6 +48,7 @@ #include "nsCOMPtr.h" #include "nsMemory.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIDOMWindow.h" #include "nsIEmbeddingSiteWindow.h" #include "nsIFactory.h" @@ -211,7 +212,7 @@ NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent, nsString csPromptEditValue; csPromptEditValue.AssignWithConversion(dlg.m_csPromptAnswer.GetBuffer(0)); - *value = csPromptEditValue.ToNewUnicode(); + *value = ToNewUnicode(csPromptEditValue); *_retval = PR_TRUE; } else @@ -247,7 +248,7 @@ NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, } nsString csUserName; csUserName.AssignWithConversion(dlg.m_csUserName.GetBuffer(0)); - *username = csUserName.ToNewUnicode(); + *username = ToNewUnicode(csUserName); // Get the password entered if (password && *password) { @@ -256,7 +257,7 @@ NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, } nsString csPassword; csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0)); - *password = csPassword.ToNewUnicode(); + *password = ToNewUnicode(csPassword); if(checkValue) *checkValue = dlg.m_bCheckBoxValue; @@ -292,7 +293,7 @@ NS_IMETHODIMP CPromptService::PromptPassword(nsIDOMWindow *parent, } nsString csPassword; csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0)); - *password = csPassword.ToNewUnicode(); + *password = ToNewUnicode(csPassword); if(checkValue) *checkValue = dlg.m_bCheckBoxValue; diff --git a/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp b/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp index 97d39ad4557..c4a648875ec 100644 --- a/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp +++ b/mozilla/embedding/tests/mfcembed/BrowserFrameGlue.cpp @@ -64,6 +64,7 @@ #include "MfcEmbed.h" #include "BrowserFrm.h" #include "Dialogs.h" +#include "nsReadableUtils.h" ///////////////////////////////////////////////////////////////////////////// // IBrowserFrameGlue implementation @@ -129,7 +130,7 @@ void CBrowserFrame::BrowserFrameGlueObj::GetBrowserFrameTitle(PRUnichar **aTitle nsString nsTitle; nsTitle.AssignWithConversion(title.GetBuffer(0)); - *aTitle = nsTitle.ToNewUnicode(); + *aTitle = ToNewUnicode(nsTitle); } } diff --git a/mozilla/embedding/tests/mfcembed/components/PromptService.cpp b/mozilla/embedding/tests/mfcembed/components/PromptService.cpp index f8f96ca3fc1..42a4a8ac592 100644 --- a/mozilla/embedding/tests/mfcembed/components/PromptService.cpp +++ b/mozilla/embedding/tests/mfcembed/components/PromptService.cpp @@ -48,6 +48,7 @@ #include "nsCOMPtr.h" #include "nsMemory.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIDOMWindow.h" #include "nsIEmbeddingSiteWindow.h" #include "nsIFactory.h" @@ -236,7 +237,7 @@ NS_IMETHODIMP CPromptService::Prompt(nsIDOMWindow *parent, nsString csPromptEditValue; csPromptEditValue.AssignWithConversion(dlg.m_csPromptAnswer.GetBuffer(0)); - *value = csPromptEditValue.ToNewUnicode(); + *value = ToNewUnicode(csPromptEditValue); *_retval = PR_TRUE; } else @@ -272,7 +273,7 @@ NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, } nsString csUserName; csUserName.AssignWithConversion(dlg.m_csUserName.GetBuffer(0)); - *username = csUserName.ToNewUnicode(); + *username = ToNewUnicode(csUserName); // Get the password entered if (password && *password) { @@ -281,7 +282,7 @@ NS_IMETHODIMP CPromptService::PromptUsernameAndPassword(nsIDOMWindow *parent, } nsString csPassword; csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0)); - *password = csPassword.ToNewUnicode(); + *password = ToNewUnicode(csPassword); if(checkValue) *checkValue = dlg.m_bCheckBoxValue; @@ -317,7 +318,7 @@ NS_IMETHODIMP CPromptService::PromptPassword(nsIDOMWindow *parent, } nsString csPassword; csPassword.AssignWithConversion(dlg.m_csPassword.GetBuffer(0)); - *password = csPassword.ToNewUnicode(); + *password = ToNewUnicode(csPassword); if(checkValue) *checkValue = dlg.m_bCheckBoxValue; diff --git a/mozilla/embedding/tests/winEmbed/WebBrowserChrome.cpp b/mozilla/embedding/tests/winEmbed/WebBrowserChrome.cpp index 3c4e547ef96..477446646ff 100644 --- a/mozilla/embedding/tests/winEmbed/WebBrowserChrome.cpp +++ b/mozilla/embedding/tests/winEmbed/WebBrowserChrome.cpp @@ -35,7 +35,6 @@ #include "nsIChannel.h" #include "nsCWebBrowser.h" #include "nsWidgetsCID.h" -#include "nsXPIDLString.h" #include "nsIProfileChangeStatus.h" // Local includes @@ -458,10 +457,7 @@ WebBrowserChrome::SendHistoryStatusMessage(nsIURI * aURI, char * operation, PRIn uriAStr.Append(NS_ConvertASCIItoUCS2(" purged from Session History")); } - PRUnichar * uriStr = nsnull; - uriStr = uriAStr.ToNewUnicode(); - WebBrowserChromeUI::UpdateStatusBarText(this, uriStr); - nsCRT::free(uriStr); + WebBrowserChromeUI::UpdateStatusBarText(this, uriAStr.get()); return NS_OK; } diff --git a/mozilla/extensions/cookie/nsCookies.cpp b/mozilla/extensions/cookie/nsCookies.cpp index 8c5cd7d9c9e..daf17ff44ad 100644 --- a/mozilla/extensions/cookie/nsCookies.cpp +++ b/mozilla/extensions/cookie/nsCookies.cpp @@ -47,6 +47,7 @@ #include "xp_core.h" #include "prmem.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPref.h" #include "nsTextFormatter.h" #include "nsAppDirectoryServiceDefs.h" @@ -1461,10 +1462,10 @@ COOKIE_Read() { return NS_ERROR_OUT_OF_MEMORY; } memset(new_cookie, 0, sizeof(cookie_CookieStruct)); - new_cookie->name = name.ToNewCString(); - new_cookie->cookie = cookie.ToNewCString(); - new_cookie->host = host.ToNewCString(); - new_cookie->path = path.ToNewCString(); + new_cookie->name = ToNewCString(name); + new_cookie->cookie = ToNewCString(cookie); + new_cookie->host = ToNewCString(host); + new_cookie->path = ToNewCString(path); if (isDomain.EqualsWithConversion("TRUE")) { new_cookie->isDomain = PR_TRUE; } else { @@ -1475,7 +1476,7 @@ COOKIE_Read() { } else { new_cookie->isSecure = PR_FALSE; } - char * expiresCString = expires.ToNewCString(); + char * expiresCString = ToNewCString(expires); new_cookie->expires = strtoul(expiresCString, nsnull, 10); nsCRT::free(expiresCString); diff --git a/mozilla/extensions/cookie/nsPermissions.cpp b/mozilla/extensions/cookie/nsPermissions.cpp index 6298c93cf7c..66ca342ac5e 100644 --- a/mozilla/extensions/cookie/nsPermissions.cpp +++ b/mozilla/extensions/cookie/nsPermissions.cpp @@ -43,6 +43,7 @@ #include "nsPermissions.h" #include "nsUtils.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIFileSpec.h" #include "nsIPrompt.h" #include "nsIWindowWatcher.h" @@ -526,7 +527,7 @@ PERMISSION_Read() { } } else { if (!permissionString.IsEmpty()) { - rv = Permission_AddHost(host.ToNewCString(), permission, type, PR_FALSE); + rv = Permission_AddHost(ToNewCString(host), permission, type, PR_FALSE); if (NS_FAILED(rv)) { strm.close(); return rv; diff --git a/mozilla/extensions/inspector/base/src/inBitmap.cpp b/mozilla/extensions/inspector/base/src/inBitmap.cpp index d35019ec9b7..de5f32ad289 100644 --- a/mozilla/extensions/inspector/base/src/inBitmap.cpp +++ b/mozilla/extensions/inspector/base/src/inBitmap.cpp @@ -40,6 +40,7 @@ #include "nsCOMPtr.h" #include "nsString.h" +#include "nsReadableUtils.h" /////////////////////////////////////////////////////////////////////////////// @@ -119,7 +120,7 @@ inBitmap::GetPixelHex(PRUint32 aX, PRUint32 aY, PRUnichar **_retval) str.AssignWithConversion(s); delete s; - *_retval = str.ToNewUnicode(); + *_retval = ToNewUnicode(str); return NS_OK; } diff --git a/mozilla/extensions/inspector/base/src/inBitmapURI.cpp b/mozilla/extensions/inspector/base/src/inBitmapURI.cpp index 8f60e69780c..efdf4479050 100644 --- a/mozilla/extensions/inspector/base/src/inBitmapURI.cpp +++ b/mozilla/extensions/inspector/base/src/inBitmapURI.cpp @@ -24,6 +24,7 @@ #include "nsIIOService.h" #include "nsIURL.h" #include "nsCRT.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #define DEFAULT_IMAGE_SIZE 16 @@ -52,7 +53,7 @@ inBitmapURI::~inBitmapURI() NS_IMETHODIMP inBitmapURI::GetBitmapName(PRUnichar** aBitmapName) { - *aBitmapName = mBitmapName.ToNewUnicode(); + *aBitmapName = ToNewUnicode(mBitmapName); return NS_OK; } diff --git a/mozilla/extensions/inspector/base/src/inCSSValueSearch.cpp b/mozilla/extensions/inspector/base/src/inCSSValueSearch.cpp index 38b8b565828..36f27364dd9 100644 --- a/mozilla/extensions/inspector/base/src/inCSSValueSearch.cpp +++ b/mozilla/extensions/inspector/base/src/inCSSValueSearch.cpp @@ -40,6 +40,7 @@ #include "nsIComponentManager.h" #include "nsVoidArray.h" +#include "nsReadableUtils.h" /////////////////////////////////////////////////////////////////////////////// @@ -146,9 +147,9 @@ inCSSValueSearch::GetStringResultAt(PRInt32 aIndex, PRUnichar **_retval) { if (mHoldResults) { nsAutoString* result = (nsAutoString*)mResults->ElementAt(aIndex); - *_retval = result->ToNewUnicode(); + *_retval = ToNewUnicode(*result); } else if (aIndex == mResultCount-1) { - *_retval = mLastResult->ToNewUnicode(); + *_retval = ToNewUnicode(*mLastResult); } else { return NS_ERROR_FAILURE; } @@ -188,7 +189,7 @@ inCSSValueSearch::SetDocument(nsIDOMDocument* aDocument) NS_IMETHODIMP inCSSValueSearch::GetBaseURL(PRUnichar** aBaseURL) { - *aBaseURL = mBaseURL->ToNewUnicode(); + *aBaseURL = ToNewUnicode(*mBaseURL); return NS_OK; } @@ -243,7 +244,7 @@ inCSSValueSearch::AddPropertyCriteria(const PRUnichar *aPropName) NS_IMETHODIMP inCSSValueSearch::GetTextCriteria(PRUnichar** aTextCriteria) { - *aTextCriteria = mTextCriteria->ToNewUnicode(); + *aTextCriteria = ToNewUnicode(*mTextCriteria); return NS_OK; } @@ -352,7 +353,7 @@ inCSSValueSearch::EqualizeURL(nsAutoString* aURL) if (aURL->Find("chrome://", PR_FALSE, 0, 1) >= 0) { PRUint32 len = aURL->Length(); char* result = new char[len-8]; - char* buffer = aURL->ToNewCString(); + char* buffer = ToNewCString(*aURL); PRUint32 i = 9; PRUint32 milestone = 0; PRUint32 s = 0; diff --git a/mozilla/extensions/inspector/base/src/inDOMDataSource.cpp b/mozilla/extensions/inspector/base/src/inDOMDataSource.cpp index 7cffac1bb70..bd3d8e8fff6 100644 --- a/mozilla/extensions/inspector/base/src/inDOMDataSource.cpp +++ b/mozilla/extensions/inspector/base/src/inDOMDataSource.cpp @@ -54,6 +54,7 @@ #include "nsIServiceManager.h" #include "nsEnumeratorUtils.h" #include "prprf.h" +#include "nsReadableUtils.h" //////////////////////////////////////////////////////////////////////// // globals and constants @@ -685,7 +686,7 @@ inDOMDataSource::ContentRemoved(nsIDocument *aDocument, nsIContent* aContainer, nsAutoString nodeName; nsCOMPtr node = do_QueryInterface(aContainer); node->GetNodeName(nodeName); - //printf("=== CONTENT REMOVED (%s) ===\n", nodeName.ToNewCString()); + //printf("=== CONTENT REMOVED (%s) ===\n", NS_LossyConvertUCS2toASCII(nodeName).get()); nsresult rv; nsCOMPtr containerRes; @@ -936,10 +937,8 @@ inDOMDataSource::CreateLiteral(nsString& str, nsIRDFNode **aResult) nsresult rv; nsCOMPtr literal; - PRUnichar* uniStr = str.ToNewUnicode(); - rv = GetRDFService()->GetLiteral(uniStr, getter_AddRefs(literal)); - nsMemory::Free(uniStr); - + rv = GetRDFService()->GetLiteral(str.get(), getter_AddRefs(literal)); + *aResult = literal; NS_IF_ADDREF(*aResult); return NS_OK; diff --git a/mozilla/extensions/inspector/base/src/inFileSearch.cpp b/mozilla/extensions/inspector/base/src/inFileSearch.cpp index a0c36c2112d..bc32634da68 100644 --- a/mozilla/extensions/inspector/base/src/inFileSearch.cpp +++ b/mozilla/extensions/inspector/base/src/inFileSearch.cpp @@ -40,6 +40,7 @@ #include "nsCOMPtr.h" #include "nsString.h" +#include "nsReadableUtils.h" /////////////////////////////////////////////////////////////////////////////// @@ -125,7 +126,7 @@ inFileSearch::SearchAsync(inISearchObserver *aObserver) } else { nsAutoString msg; msg.AssignWithConversion("No search path has been provided"); - mObserver->OnSearchError(this, msg.ToNewUnicode()); + mObserver->OnSearchError(this, ToNewUnicode(msg)); KillSearch(inISearchObserver::ERROR); } @@ -176,7 +177,7 @@ inFileSearch::GetStringResultAt(PRInt32 aIndex, PRUnichar **_retval) path.AssignWithConversion(temp); if (mReturnRelativePaths) MakePathRelative(&path); - *_retval = path.ToNewUnicode(); + *_retval = ToNewUnicode(path); } else { return NS_ERROR_FAILURE; } @@ -203,7 +204,7 @@ NS_IMETHODIMP inFileSearch::GetBasePath(PRUnichar** aBasePath) { if (mBasePath) { - *aBasePath = mBasePath->ToNewUnicode(); + *aBasePath = ToNewUnicode(*mBasePath); } else { return NS_ERROR_FAILURE; } @@ -282,7 +283,7 @@ inFileSearch::SetFilenameCriteria(const PRUnichar* aFilenameCriteria) NS_IMETHODIMP inFileSearch::GetTextCriteria(PRUnichar** aTextCriteria) { - *aTextCriteria = mTextCriteria->ToNewUnicode(); + *aTextCriteria = ToNewUnicode(*mTextCriteria); return NS_OK; } @@ -550,7 +551,7 @@ inFileSearch::MatchFile(nsIFile* aFile) nsAutoString temp; temp.AssignWithConversion(fileName); - PRUnichar* fileNameUnicode = temp.ToNewUnicode(); + PRUnichar* fileNameUnicode = ToNewUnicode(temp); PRBool match; diff --git a/mozilla/extensions/inspector/base/src/inPNGEncoder.cpp b/mozilla/extensions/inspector/base/src/inPNGEncoder.cpp index bea8a79c826..70723f40e9a 100644 --- a/mozilla/extensions/inspector/base/src/inPNGEncoder.cpp +++ b/mozilla/extensions/inspector/base/src/inPNGEncoder.cpp @@ -41,6 +41,7 @@ #include "nsISupportsArray.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIPresShell.h" #include "nsIPresContext.h" #include "nsIRenderingContext.h" @@ -84,7 +85,7 @@ inPNGEncoder::WritePNG(inIBitmap *aBitmap, const PRUnichar *aURL, PRInt16 aType) nsAutoString str; str.Assign(aURL); - FILE *file = fopen(str.ToNewCString(), "wb"); + FILE *file = fopen(ToNewCString(str), "wb"); if (file) { pngStruct = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, gPNGErrorHandler, NULL); infoStruct = png_create_info_struct(pngStruct); diff --git a/mozilla/extensions/pics/src/nsPICS.cpp b/mozilla/extensions/pics/src/nsPICS.cpp index ae1e9581518..b3dc9937ddd 100644 --- a/mozilla/extensions/pics/src/nsPICS.cpp +++ b/mozilla/extensions/pics/src/nsPICS.cpp @@ -75,6 +75,7 @@ #include "plstr.h" #include "prmem.h" #include "nsString.h" +#include "nsReadableUtils.h" #include static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); @@ -398,7 +399,7 @@ nsPICS::ProcessPICSLabel(char *label) char* quoteValue = PL_strndup(label, 1); // nsString value2(theValue2); theLabel.Trim(quoteValue); - char *lab = theLabel.ToNewCString(); + char *lab = ToNewCString(theLabel); PL_strcpy(label, lab); } // rv = GetRootURL(); diff --git a/mozilla/extensions/pics/src/nsPICSElementObserver.cpp b/mozilla/extensions/pics/src/nsPICSElementObserver.cpp index 60e44ee814c..195ae5a64b8 100644 --- a/mozilla/extensions/pics/src/nsPICSElementObserver.cpp +++ b/mozilla/extensions/pics/src/nsPICSElementObserver.cpp @@ -50,6 +50,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "nsPICSElementObserver.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIPICS.h" #include "nspics.h" #include "nsIWebShellServices.h" @@ -154,19 +155,19 @@ NS_IMETHODIMP nsPICSElementObserver::Notify(PRUint32 aDocumentID, int status; nsIWebShellServices* ws; // nsString theURL(aSpec); -// char* url = aSpec.ToNewCString(); +// char* url = ToNewCString(aSpec); nsIURI* uaURL = nsnull; // rv = NS_NewURL(&uaURL, nsString(aSpec)); if(numOfAttributes >= 2) { const nsString& theValue1=valueArray[0]; - char *val1 = theValue1.ToNewCString(); + char *val1 = ToNewCString(theValue1); if(theValue1.EqualsIgnoreCase("\"PICS-LABEL\"")) { #ifdef DEBUG printf("\nReceived notification for a PICS-LABEl\n"); #endif const nsString& theValue2=valueArray[1]; - char *label = theValue2.ToNewCString(); + char *label = ToNewCString(theValue2); if (valueArray[numOfAttributes]) { const nsString& theURLValue=valueArray[numOfAttributes]; nsCOMPtr service(do_GetService(kIOServiceCID, &rv)); diff --git a/mozilla/extensions/wallet/cookieviewer/nsCookieViewer.cpp b/mozilla/extensions/wallet/cookieviewer/nsCookieViewer.cpp index ed2c20bfe43..7cffec95020 100644 --- a/mozilla/extensions/wallet/cookieviewer/nsCookieViewer.cpp +++ b/mozilla/extensions/wallet/cookieviewer/nsCookieViewer.cpp @@ -44,6 +44,7 @@ #include "nsIServiceManager.h" #include "nsIDOMWindowInternal.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIScriptGlobalObject.h" #include "nsCookieViewer.h" #include "nsIDocShell.h" @@ -80,7 +81,7 @@ CookieViewerImpl::GetCookieValue(char** aValue) nsAutoString cookieList; res = cookieservice->Cookie_GetCookieListForViewer(cookieList); if (NS_SUCCEEDED(res)) { - *aValue = cookieList.ToNewCString(); + *aValue = ToNewCString(cookieList); } return res; } @@ -100,7 +101,7 @@ CookieViewerImpl::GetPermissionValue(PRInt32 type, char** aValue) nsAutoString PermissionList; res = cookieservice->Cookie_GetPermissionListForViewer(PermissionList, type); if (NS_SUCCEEDED(res)) { - *aValue = PermissionList.ToNewCString(); + *aValue = ToNewCString(PermissionList); } return res; } diff --git a/mozilla/extensions/wallet/editor/nsWalletEditor.cpp b/mozilla/extensions/wallet/editor/nsWalletEditor.cpp index ed9e796273a..80a829416c4 100644 --- a/mozilla/extensions/wallet/editor/nsWalletEditor.cpp +++ b/mozilla/extensions/wallet/editor/nsWalletEditor.cpp @@ -44,6 +44,7 @@ #include "nsIServiceManager.h" #include "nsIDOMWindowInternal.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIDocShell.h" #include "nsIScriptGlobalObject.h" #include "nsWalletEditor.h" @@ -77,7 +78,7 @@ WalletEditorImpl::GetValue(PRUnichar** aValue) nsAutoString walletList; res = walletservice->WALLET_PreEdit(walletList); if (NS_SUCCEEDED(res)) { - *aValue = walletList.ToNewUnicode(); + *aValue = ToNewUnicode(walletList); } return res; } diff --git a/mozilla/extensions/wallet/signonviewer/nsSignonViewer.cpp b/mozilla/extensions/wallet/signonviewer/nsSignonViewer.cpp index 7c474593a19..ec8d4525773 100644 --- a/mozilla/extensions/wallet/signonviewer/nsSignonViewer.cpp +++ b/mozilla/extensions/wallet/signonviewer/nsSignonViewer.cpp @@ -45,6 +45,7 @@ #include "nsIServiceManager.h" #include "nsIDOMWindowInternal.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIScriptGlobalObject.h" #include "nsSignonViewer.h" @@ -77,7 +78,7 @@ SignonViewerImpl::GetNopreviewValue(PRUnichar** aValue) nsAutoString nopreviewList; res = walletservice->WALLET_GetNopreviewListForViewer(nopreviewList); if (NS_SUCCEEDED(res)) { - *aValue = nopreviewList.ToNewUnicode(); + *aValue = ToNewUnicode(nopreviewList); } return res; } @@ -96,7 +97,7 @@ SignonViewerImpl::GetNocaptureValue(PRUnichar** aValue) nsAutoString nocaptureList; res = walletservice->WALLET_GetNocaptureListForViewer(nocaptureList); if (NS_SUCCEEDED(res)) { - *aValue = nocaptureList.ToNewUnicode(); + *aValue = ToNewUnicode(nocaptureList); } return res; } diff --git a/mozilla/extensions/wallet/src/nsWalletService.cpp b/mozilla/extensions/wallet/src/nsWalletService.cpp index 5fad2e724be..939d99a449d 100644 --- a/mozilla/extensions/wallet/src/nsWalletService.cpp +++ b/mozilla/extensions/wallet/src/nsWalletService.cpp @@ -64,6 +64,7 @@ #include "nsIWindowWatcher.h" #include "nsIWebProgress.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsICategoryManager.h" // for making the leap from nsIDOMWindowInternal -> nsIPresShell @@ -137,7 +138,7 @@ nsWalletlibService::WALLET_PrefillOneElement { nsAutoString compositeValue; nsresult rv = ::WLLT_PrefillOneElement(aWin, elementNode, compositeValue); - *value = compositeValue.ToNewUnicode(); + *value = ToNewUnicode(compositeValue); return rv; } @@ -429,7 +430,7 @@ nsWalletlibService::OnStateChange(nsIWebProgress* aWebProgress, nsAutoString field; rv = inputElement->GetName(field); if (NS_SUCCEEDED(rv)) { - PRUnichar* nameString = field.ToNewUnicode(); + PRUnichar* nameString = ToNewUnicode(field); if (nameString) { /* note: we do not want to prefill if there is a default value */ nsAutoString value; @@ -535,7 +536,7 @@ nsWalletlibService::WALLET_Encrypt (const PRUnichar *text, char **crypt) { nsAutoString textAutoString( text ); nsAutoString cryptAutoString; PRBool rv = ::Wallet_Encrypt(textAutoString, cryptAutoString); - *crypt = cryptAutoString.ToNewCString(); + *crypt = ToNewCString(cryptAutoString); return rv; } @@ -544,7 +545,7 @@ nsWalletlibService::WALLET_Decrypt (const char *crypt, PRUnichar **text) { nsAutoString cryptAutoString; cryptAutoString.AssignWithConversion(crypt); nsAutoString textAutoString; PRBool rv = ::Wallet_Decrypt(cryptAutoString, textAutoString); - *text = textAutoString.ToNewUnicode(); + *text = ToNewUnicode(textAutoString); return rv; } diff --git a/mozilla/extensions/wallet/src/singsign.cpp b/mozilla/extensions/wallet/src/singsign.cpp index aea99601082..bccd070ed36 100644 --- a/mozilla/extensions/wallet/src/singsign.cpp +++ b/mozilla/extensions/wallet/src/singsign.cpp @@ -970,7 +970,7 @@ si_GetUser(nsIPrompt* dialog, const char* passwordRealm, PRBool pickFirstUser, c } nsAutoString userName; if (NS_SUCCEEDED(si_Decrypt (data->value, userName))) { - *(list2++) = userName.ToNewUnicode(); + *(list2++) = ToNewUnicode(userName); *(users2++) = user; user_count++; } else { @@ -1141,7 +1141,7 @@ si_GetURLAndUserForChangeForm(nsIPrompt* dialog, const nsString& password) temp.AppendWithConversion(":"); temp.Append(userName); - *list2 = temp.ToNewUnicode(); + *list2 = ToNewUnicode(temp); list2++; *(users2++) = user; *(urls2++) = url; @@ -1688,7 +1688,7 @@ SI_LoadSignonData() { break; /* end of reject list */ } si_StripLF(buffer); - passwordRealm = buffer.ToNewCString(); + passwordRealm = ToNewCString(buffer); si_PutReject(passwordRealm, buffer, PR_FALSE); /* middle parameter is obsolete */ Recycle (passwordRealm); } @@ -1697,7 +1697,7 @@ SI_LoadSignonData() { while (NS_SUCCEEDED(si_ReadLine(strm, buffer))) { si_StripLF(buffer); /* a blank line is perfectly valid here -- corresponds to a local file */ - passwordRealm = buffer.ToNewCString(); + passwordRealm = ToNewCString(buffer); if (!passwordRealm) { si_unlock_signon_list(); return -1; @@ -2132,7 +2132,7 @@ si_RestoreSignonData(nsIPrompt* dialog, const char* passwordRealm, const PRUnich if (data->isPassword) { nsAutoString password; if (NS_SUCCEEDED(si_Decrypt(data->value, password))) { - *value = password.ToNewUnicode(); + *value = ToNewUnicode(password); } si_unlock_signon_list(); return; @@ -2153,7 +2153,7 @@ si_RestoreSignonData(nsIPrompt* dialog, const char* passwordRealm, const PRUnich if(correctedName.Length() && (data->name == correctedName)) { nsAutoString password; if (NS_SUCCEEDED(si_Decrypt(data->value, password))) { - *value = password.ToNewUnicode(); + *value = ToNewUnicode(password); } si_unlock_signon_list(); return; @@ -2350,10 +2350,10 @@ SINGSIGN_PromptUsernameAndPassword si_RestoreOldSignonDataFromBrowser(dialog, passwordRealm, PR_FALSE, username, password); /* get new username/password from user */ - if (!(*user = username.ToNewUnicode())) { + if (!(*user = ToNewUnicode(username))) { return NS_ERROR_OUT_OF_MEMORY; } - if (!(*pwd = password.ToNewUnicode())) { + if (!(*pwd = ToNewUnicode(password))) { PR_Free(*user); return NS_ERROR_OUT_OF_MEMORY; } @@ -2410,13 +2410,13 @@ SINGSIGN_PromptPassword /* return if a password was found */ if (password.Length() != 0) { - *pwd = password.ToNewUnicode(); + *pwd = ToNewUnicode(password); *pressedOK = PR_TRUE; return NS_OK; } /* no password found, get new password from user */ - *pwd = password.ToNewUnicode(); + *pwd = ToNewUnicode(password); PRBool checked = PR_FALSE; res = si_CheckGetPassword(pwd, dialogTitle, text, dialog, savePassword, &checked); if (NS_FAILED(res)) { @@ -2463,14 +2463,14 @@ SINGSIGN_Prompt /* return if data was found */ if (data.Length() != 0) { - *resultText = data.ToNewUnicode(); + *resultText = ToNewUnicode(data); *pressedOK = PR_TRUE; return NS_OK; } /* no data found, get new data from user */ data = defaultText; - *resultText = data.ToNewUnicode(); + *resultText = ToNewUnicode(data); PRBool checked = PR_FALSE; res = si_CheckGetData(resultText, dialogTitle, text, dialog, savePassword, &checked); if (NS_FAILED(res)) { @@ -2665,7 +2665,7 @@ SINGSIGN_Enumerate /* don't display saved signons if user couldn't unlock the database */ return NS_ERROR_FAILURE; } - if (!(*user = userName.ToNewUnicode())) { + if (!(*user = ToNewUnicode(userName))) { return NS_ERROR_OUT_OF_MEMORY; } @@ -2683,7 +2683,7 @@ SINGSIGN_Enumerate Recycle(*user); return NS_ERROR_FAILURE; } - if (!(*pswd = passWord.ToNewUnicode())) { + if (!(*pswd = ToNewUnicode(passWord))) { Recycle(*user); return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/extensions/wallet/src/wallet.cpp b/mozilla/extensions/wallet/src/wallet.cpp index 97205463eab..6686b5c983a 100644 --- a/mozilla/extensions/wallet/src/wallet.cpp +++ b/mozilla/extensions/wallet/src/wallet.cpp @@ -47,6 +47,7 @@ #include "singsign.h" #include "nsNetUtil.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIDocument.h" @@ -476,7 +477,7 @@ Wallet_Localize(char* genericString) { #ifdef DEBUG printf("cannot get string service\n"); #endif - return v.ToNewUnicode(); + return ToNewUnicode(v); } nsCOMPtr bundle; ret = pStringService->CreateBundle(PROPERTIES_URL, getter_AddRefs(bundle)); @@ -484,7 +485,7 @@ Wallet_Localize(char* genericString) { #ifdef DEBUG printf("cannot create instance\n"); #endif - return v.ToNewUnicode(); + return ToNewUnicode(v); } /* localize the given string */ @@ -496,7 +497,7 @@ Wallet_Localize(char* genericString) { #ifdef DEBUG printf("cannot get string from name\n"); #endif - return v.ToNewUnicode(); + return ToNewUnicode(v); } v = ptrv; nsCRT::free(ptrv); @@ -509,7 +510,7 @@ Wallet_Localize(char* genericString) { } } - return v.ToNewUnicode(); + return ToNewUnicode(v); } /**********************/ @@ -784,7 +785,7 @@ Wallet_Encrypt (const nsString& text, nsString& crypt) { /* encrypt text to crypt */ char * cryptCString = nsnull; - char * UTF8textCString = UTF8text.ToNewCString(); + char * UTF8textCString = ToNewCString(UTF8text); nsresult rv = EncryptString(UTF8textCString, cryptCString); Recycle (UTF8textCString); if NS_FAILED(rv) { @@ -799,7 +800,7 @@ PUBLIC nsresult Wallet_Decrypt(const nsString& crypt, nsString& text) { /* decrypt crypt to text */ - char * cryptCString = crypt.ToNewCString(); + char * cryptCString = ToNewCString(crypt); char * UTF8textCString = nsnull; nsresult rv = DecryptString(cryptCString, UTF8textCString); @@ -2676,7 +2677,7 @@ WLLT_GetPrefillListForViewer(nsString& aPrefillList) buffer.Append(mapElementPtr->value); } - PRUnichar * urlUnichar = wallet_url.ToNewUnicode(); + PRUnichar * urlUnichar = ToNewUnicode(wallet_url); buffer.AppendWithConversion(BREAK); buffer.AppendInt(NS_PTR_TO_INT32(wallet_list)); buffer.AppendWithConversion(BREAK); @@ -3819,7 +3820,7 @@ WLLT_OnSubmit(nsIContent* currentForm, nsIDOMWindowInternal* window) { } (void)docURL->GetSpec(&URLName); wallet_GetHostFile(docURL, strippedURLNameAutoString); - strippedURLName = strippedURLNameAutoString.ToNewCString(); + strippedURLName = ToNewCString(strippedURLNameAutoString); /* get to the form elements */ nsCOMPtr htmldoc(do_QueryInterface(doc)); diff --git a/mozilla/extensions/wallet/walletpreview/nsWalletPreview.cpp b/mozilla/extensions/wallet/walletpreview/nsWalletPreview.cpp index dd8664d9286..cf85d20ab8f 100644 --- a/mozilla/extensions/wallet/walletpreview/nsWalletPreview.cpp +++ b/mozilla/extensions/wallet/walletpreview/nsWalletPreview.cpp @@ -40,6 +40,7 @@ #include "nsIMemory.h" #include "plstr.h" #include "stdio.h" +#include "nsReadableUtils.h" #include "nsIWalletService.h" #include "nsIServiceManager.h" #include "nsIDOMWindowInternal.h" @@ -80,7 +81,7 @@ WalletPreviewImpl::GetPrefillValue(PRUnichar** aValue) nsAutoString walletList; res = walletservice->WALLET_GetPrefillListForViewer(walletList); if (NS_SUCCEEDED(res)) { - *aValue = walletList.ToNewUnicode(); + *aValue = ToNewUnicode(walletList); } return res; } diff --git a/mozilla/extensions/webservices/soap/src/nsSOAPCall.cpp b/mozilla/extensions/webservices/soap/src/nsSOAPCall.cpp index 70b09402ee3..c451873344e 100644 --- a/mozilla/extensions/webservices/soap/src/nsSOAPCall.cpp +++ b/mozilla/extensions/webservices/soap/src/nsSOAPCall.cpp @@ -48,6 +48,7 @@ #include "nsIServiceManager.h" #include "nsIComponentManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIXPConnect.h" #include "nsIJSContextStack.h" #include "nsIURI.h" @@ -269,7 +270,7 @@ NS_IMETHODIMP nsSOAPCall::GetEncodingStyleURI(char * *aEncodingStyleURI) value); if (value.Length() > 0) { - *aEncodingStyleURI = value.ToNewCString(); + *aEncodingStyleURI = ToNewCString(value); if (nsnull == *aEncodingStyleURI) { return NS_ERROR_OUT_OF_MEMORY; } @@ -374,7 +375,7 @@ NS_IMETHODIMP nsSOAPCall::GetTargetObjectURI(char * *aTargetObjectURI) NS_ENSURE_ARG_POINTER(aTargetObjectURI); if (mTargetObjectURI.Length() > 0) { - *aTargetObjectURI = mTargetObjectURI.ToNewCString(); + *aTargetObjectURI = ToNewCString(mTargetObjectURI); } else { *aTargetObjectURI = nsnull; @@ -400,7 +401,7 @@ NS_IMETHODIMP nsSOAPCall::GetMethodName(PRUnichar * *aMethodName) NS_ENSURE_ARG_POINTER(aMethodName); if (mMethodName.Length() > 0) { - *aMethodName = mMethodName.ToNewUnicode(); + *aMethodName = ToNewUnicode(mMethodName); } else { *aMethodName = nsnull; @@ -426,7 +427,7 @@ NS_IMETHODIMP nsSOAPCall::GetDestinationURI(char * *aDestinationURI) NS_ENSURE_ARG_POINTER(aDestinationURI); if (mDestinationURI.Length() > 0) { - *aDestinationURI = mDestinationURI.ToNewCString(); + *aDestinationURI = ToNewCString(mDestinationURI); } else { *aDestinationURI = nsnull; @@ -452,7 +453,7 @@ NS_IMETHODIMP nsSOAPCall::GetActionURI(char * *aActionURI) NS_ENSURE_ARG_POINTER(aActionURI); if (mActionURI.Length() > 0) { - *aActionURI = mActionURI.ToNewCString(); + *aActionURI = ToNewCString(mActionURI); } else { *aActionURI = nsnull; diff --git a/mozilla/extensions/webservices/soap/src/nsSOAPFault.cpp b/mozilla/extensions/webservices/soap/src/nsSOAPFault.cpp index 45f6141e185..90ccbf6787c 100644 --- a/mozilla/extensions/webservices/soap/src/nsSOAPFault.cpp +++ b/mozilla/extensions/webservices/soap/src/nsSOAPFault.cpp @@ -39,6 +39,7 @@ #include "nsSOAPFault.h" #include "nsSOAPUtils.h" #include "nsIDOMNodeList.h" +#include "nsReadableUtils.h" nsSOAPFault::nsSOAPFault(nsIDOMElement* aElement) { @@ -85,7 +86,7 @@ NS_IMETHODIMP nsSOAPFault::GetFaultCode(PRUnichar * *aFaultCode) nsAutoString text; nsSOAPUtils::GetElementTextContent(element, text); if (text.Length() > 0) { - *aFaultCode = text.ToNewUnicode(); + *aFaultCode = ToNewUnicode(text); if (!*aFaultCode) return NS_ERROR_OUT_OF_MEMORY; } } @@ -118,7 +119,7 @@ NS_IMETHODIMP nsSOAPFault::GetFaultString(PRUnichar * *aFaultString) nsAutoString text; nsSOAPUtils::GetElementTextContent(element, text); if (text.Length() > 0) { - *aFaultString = text.ToNewUnicode(); + *aFaultString = ToNewUnicode(text); if (!*aFaultString) return NS_ERROR_OUT_OF_MEMORY; } } @@ -151,7 +152,7 @@ NS_IMETHODIMP nsSOAPFault::GetFaultActor(PRUnichar * *aFaultActor) nsAutoString text; nsSOAPUtils::GetElementTextContent(element, text); if (text.Length() > 0) { - *aFaultActor = text.ToNewUnicode(); + *aFaultActor = ToNewUnicode(text); if (!*aFaultActor) return NS_ERROR_OUT_OF_MEMORY; } } diff --git a/mozilla/extensions/webservices/soap/src/nsSOAPParameter.cpp b/mozilla/extensions/webservices/soap/src/nsSOAPParameter.cpp index 09ba60ed4de..fa343b65983 100644 --- a/mozilla/extensions/webservices/soap/src/nsSOAPParameter.cpp +++ b/mozilla/extensions/webservices/soap/src/nsSOAPParameter.cpp @@ -40,6 +40,7 @@ #include "nsSOAPUtils.h" #include "nsIXPConnect.h" #include "nsIServiceManager.h" +#include "nsReadableUtils.h" nsSOAPParameter::nsSOAPParameter() { @@ -73,7 +74,7 @@ NS_IMETHODIMP nsSOAPParameter::GetEncodingStyleURI(char * *aEncodingStyleURI) { NS_ENSURE_ARG_POINTER(aEncodingStyleURI); if (mEncodingStyleURI.Length() > 0) { - *aEncodingStyleURI = mEncodingStyleURI.ToNewCString(); + *aEncodingStyleURI = ToNewCString(mEncodingStyleURI); } else { *aEncodingStyleURI = nsnull; @@ -97,7 +98,7 @@ NS_IMETHODIMP nsSOAPParameter::GetName(PRUnichar * *aName) { NS_ENSURE_ARG_POINTER(aName); if (mName.Length() > 0) { - *aName = mName.ToNewUnicode(); + *aName = ToNewUnicode(mName); } else { *aName = nsnull; diff --git a/mozilla/extensions/webservices/soap/src/nsSOAPResponse.cpp b/mozilla/extensions/webservices/soap/src/nsSOAPResponse.cpp index da2df2c0813..0b5f4475e35 100644 --- a/mozilla/extensions/webservices/soap/src/nsSOAPResponse.cpp +++ b/mozilla/extensions/webservices/soap/src/nsSOAPResponse.cpp @@ -44,6 +44,7 @@ #include "nsISOAPParameter.h" #include "nsIComponentManager.h" #include "nsMemory.h" +#include "nsReadableUtils.h" nsSOAPResponse::nsSOAPResponse(nsIDOMDocument* aEnvelopeDocument) { @@ -165,7 +166,7 @@ NS_IMETHODIMP nsSOAPResponse::GetTargetObjectURI(char * *aTargetObjectURI) nsAutoString ns; mResultElement->GetNamespaceURI(ns); if (ns.Length() > 0) { - *aTargetObjectURI = ns.ToNewCString(); + *aTargetObjectURI = ToNewCString(ns); } } return NS_OK; @@ -180,7 +181,7 @@ NS_IMETHODIMP nsSOAPResponse::GetMethodName(char * *aMethodName) nsAutoString localName; mResultElement->GetLocalName(localName); if (localName.Length() > 0) { - *aMethodName = localName.ToNewCString(); + *aMethodName = ToNewCString(localName); } } return NS_OK; diff --git a/mozilla/extensions/webservices/soap/src/nsSOAPUtils.cpp b/mozilla/extensions/webservices/soap/src/nsSOAPUtils.cpp index 9994357a4db..c052544a588 100644 --- a/mozilla/extensions/webservices/soap/src/nsSOAPUtils.cpp +++ b/mozilla/extensions/webservices/soap/src/nsSOAPUtils.cpp @@ -45,6 +45,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsISupportsArray.h" const char* nsSOAPUtils::kSOAPEnvURI = "http://schemas.xmlsoap.org/soap/envelope/"; @@ -160,7 +161,7 @@ nsSOAPUtils::GetInheritedEncodingStyle(nsIDOMElement* aEntry, NS_ConvertASCIItoUCS2(nsSOAPUtils::kEncodingStyleAttribute), value); if (value.Length() > 0) { - *aEncodingStyle = value.ToNewCString(); + *aEncodingStyle = ToNewCString(value); return; } } diff --git a/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp b/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp index 04fa92969fd..b27bb592363 100644 --- a/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsDOMParser.cpp @@ -56,6 +56,7 @@ #include "nsIScriptSecurityManager.h" #include "nsICodebasePrincipal.h" #include "nsIDOMClassInfo.h" +#include "nsReadableUtils.h" #ifdef IMPLEMENT_SYNC_LOAD #include "nsIScriptContext.h" @@ -191,7 +192,7 @@ NS_IMETHODIMP nsDOMParserChannel::GetURI(nsIURI * *aURI) NS_IMETHODIMP nsDOMParserChannel::GetContentType(char * *aContentType) { NS_ENSURE_ARG_POINTER(aContentType); - *aContentType = mContentType.ToNewCString(); + *aContentType = ToNewCString(mContentType); return NS_OK; } NS_IMETHODIMP nsDOMParserChannel::SetContentType(const char * aContentType) diff --git a/mozilla/extensions/xmlextras/base/src/nsDOMSerializer.cpp b/mozilla/extensions/xmlextras/base/src/nsDOMSerializer.cpp index 16686d547d0..9a7276d1467 100644 --- a/mozilla/extensions/xmlextras/base/src/nsDOMSerializer.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsDOMSerializer.cpp @@ -47,6 +47,7 @@ #include "nsIComponentManager.h" #include "nsIContentSerializer.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsLayoutCID.h" // XXX Need range CID static NS_DEFINE_CID(kRangeCID,NS_RANGE_CID); @@ -145,7 +146,7 @@ nsDOMSerializer::SerializeToString(nsIDOMNode *root, PRUnichar **_retval) if (NS_FAILED(rv)) return rv; - *_retval = str.ToNewUnicode(); + *_retval = ToNewUnicode(str); if (!*_retval) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp index 8b5fba38272..bbc47e6a257 100644 --- a/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp +++ b/mozilla/extensions/xmlextras/base/src/nsXMLHttpRequest.cpp @@ -47,6 +47,7 @@ #include "nsIDOMDOMImplementation.h" #include "nsIPrivateDOMImplementation.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIURI.h" #include "nsILoadGroup.h" #include "nsNetUtil.h" @@ -393,9 +394,7 @@ nsXMLHttpRequest::ConvertBodyToText(PRUnichar **aOutBuffer) } if (dataCharset.Equals(NS_LITERAL_STRING("ASCII"))) { - // XXX There is no ASCII->Unicode decoder? - // XXX How to do this without double allocation/copy? - *aOutBuffer = NS_ConvertASCIItoUCS2(mResponseBody.get(),dataLen).ToNewUnicode(); + *aOutBuffer = ToNewUnicode(nsDependentCString(mResponseBody.get(),dataLen)); if (!*aOutBuffer) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; diff --git a/mozilla/extensions/xmlextras/soap/src/nsSOAPCall.cpp b/mozilla/extensions/xmlextras/soap/src/nsSOAPCall.cpp index 70b09402ee3..c451873344e 100644 --- a/mozilla/extensions/xmlextras/soap/src/nsSOAPCall.cpp +++ b/mozilla/extensions/xmlextras/soap/src/nsSOAPCall.cpp @@ -48,6 +48,7 @@ #include "nsIServiceManager.h" #include "nsIComponentManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIXPConnect.h" #include "nsIJSContextStack.h" #include "nsIURI.h" @@ -269,7 +270,7 @@ NS_IMETHODIMP nsSOAPCall::GetEncodingStyleURI(char * *aEncodingStyleURI) value); if (value.Length() > 0) { - *aEncodingStyleURI = value.ToNewCString(); + *aEncodingStyleURI = ToNewCString(value); if (nsnull == *aEncodingStyleURI) { return NS_ERROR_OUT_OF_MEMORY; } @@ -374,7 +375,7 @@ NS_IMETHODIMP nsSOAPCall::GetTargetObjectURI(char * *aTargetObjectURI) NS_ENSURE_ARG_POINTER(aTargetObjectURI); if (mTargetObjectURI.Length() > 0) { - *aTargetObjectURI = mTargetObjectURI.ToNewCString(); + *aTargetObjectURI = ToNewCString(mTargetObjectURI); } else { *aTargetObjectURI = nsnull; @@ -400,7 +401,7 @@ NS_IMETHODIMP nsSOAPCall::GetMethodName(PRUnichar * *aMethodName) NS_ENSURE_ARG_POINTER(aMethodName); if (mMethodName.Length() > 0) { - *aMethodName = mMethodName.ToNewUnicode(); + *aMethodName = ToNewUnicode(mMethodName); } else { *aMethodName = nsnull; @@ -426,7 +427,7 @@ NS_IMETHODIMP nsSOAPCall::GetDestinationURI(char * *aDestinationURI) NS_ENSURE_ARG_POINTER(aDestinationURI); if (mDestinationURI.Length() > 0) { - *aDestinationURI = mDestinationURI.ToNewCString(); + *aDestinationURI = ToNewCString(mDestinationURI); } else { *aDestinationURI = nsnull; @@ -452,7 +453,7 @@ NS_IMETHODIMP nsSOAPCall::GetActionURI(char * *aActionURI) NS_ENSURE_ARG_POINTER(aActionURI); if (mActionURI.Length() > 0) { - *aActionURI = mActionURI.ToNewCString(); + *aActionURI = ToNewCString(mActionURI); } else { *aActionURI = nsnull; diff --git a/mozilla/extensions/xmlextras/soap/src/nsSOAPFault.cpp b/mozilla/extensions/xmlextras/soap/src/nsSOAPFault.cpp index 45f6141e185..90ccbf6787c 100644 --- a/mozilla/extensions/xmlextras/soap/src/nsSOAPFault.cpp +++ b/mozilla/extensions/xmlextras/soap/src/nsSOAPFault.cpp @@ -39,6 +39,7 @@ #include "nsSOAPFault.h" #include "nsSOAPUtils.h" #include "nsIDOMNodeList.h" +#include "nsReadableUtils.h" nsSOAPFault::nsSOAPFault(nsIDOMElement* aElement) { @@ -85,7 +86,7 @@ NS_IMETHODIMP nsSOAPFault::GetFaultCode(PRUnichar * *aFaultCode) nsAutoString text; nsSOAPUtils::GetElementTextContent(element, text); if (text.Length() > 0) { - *aFaultCode = text.ToNewUnicode(); + *aFaultCode = ToNewUnicode(text); if (!*aFaultCode) return NS_ERROR_OUT_OF_MEMORY; } } @@ -118,7 +119,7 @@ NS_IMETHODIMP nsSOAPFault::GetFaultString(PRUnichar * *aFaultString) nsAutoString text; nsSOAPUtils::GetElementTextContent(element, text); if (text.Length() > 0) { - *aFaultString = text.ToNewUnicode(); + *aFaultString = ToNewUnicode(text); if (!*aFaultString) return NS_ERROR_OUT_OF_MEMORY; } } @@ -151,7 +152,7 @@ NS_IMETHODIMP nsSOAPFault::GetFaultActor(PRUnichar * *aFaultActor) nsAutoString text; nsSOAPUtils::GetElementTextContent(element, text); if (text.Length() > 0) { - *aFaultActor = text.ToNewUnicode(); + *aFaultActor = ToNewUnicode(text); if (!*aFaultActor) return NS_ERROR_OUT_OF_MEMORY; } } diff --git a/mozilla/extensions/xmlextras/soap/src/nsSOAPParameter.cpp b/mozilla/extensions/xmlextras/soap/src/nsSOAPParameter.cpp index 09ba60ed4de..fa343b65983 100644 --- a/mozilla/extensions/xmlextras/soap/src/nsSOAPParameter.cpp +++ b/mozilla/extensions/xmlextras/soap/src/nsSOAPParameter.cpp @@ -40,6 +40,7 @@ #include "nsSOAPUtils.h" #include "nsIXPConnect.h" #include "nsIServiceManager.h" +#include "nsReadableUtils.h" nsSOAPParameter::nsSOAPParameter() { @@ -73,7 +74,7 @@ NS_IMETHODIMP nsSOAPParameter::GetEncodingStyleURI(char * *aEncodingStyleURI) { NS_ENSURE_ARG_POINTER(aEncodingStyleURI); if (mEncodingStyleURI.Length() > 0) { - *aEncodingStyleURI = mEncodingStyleURI.ToNewCString(); + *aEncodingStyleURI = ToNewCString(mEncodingStyleURI); } else { *aEncodingStyleURI = nsnull; @@ -97,7 +98,7 @@ NS_IMETHODIMP nsSOAPParameter::GetName(PRUnichar * *aName) { NS_ENSURE_ARG_POINTER(aName); if (mName.Length() > 0) { - *aName = mName.ToNewUnicode(); + *aName = ToNewUnicode(mName); } else { *aName = nsnull; diff --git a/mozilla/extensions/xmlextras/soap/src/nsSOAPResponse.cpp b/mozilla/extensions/xmlextras/soap/src/nsSOAPResponse.cpp index da2df2c0813..0b5f4475e35 100644 --- a/mozilla/extensions/xmlextras/soap/src/nsSOAPResponse.cpp +++ b/mozilla/extensions/xmlextras/soap/src/nsSOAPResponse.cpp @@ -44,6 +44,7 @@ #include "nsISOAPParameter.h" #include "nsIComponentManager.h" #include "nsMemory.h" +#include "nsReadableUtils.h" nsSOAPResponse::nsSOAPResponse(nsIDOMDocument* aEnvelopeDocument) { @@ -165,7 +166,7 @@ NS_IMETHODIMP nsSOAPResponse::GetTargetObjectURI(char * *aTargetObjectURI) nsAutoString ns; mResultElement->GetNamespaceURI(ns); if (ns.Length() > 0) { - *aTargetObjectURI = ns.ToNewCString(); + *aTargetObjectURI = ToNewCString(ns); } } return NS_OK; @@ -180,7 +181,7 @@ NS_IMETHODIMP nsSOAPResponse::GetMethodName(char * *aMethodName) nsAutoString localName; mResultElement->GetLocalName(localName); if (localName.Length() > 0) { - *aMethodName = localName.ToNewCString(); + *aMethodName = ToNewCString(localName); } } return NS_OK; diff --git a/mozilla/extensions/xmlextras/soap/src/nsSOAPUtils.cpp b/mozilla/extensions/xmlextras/soap/src/nsSOAPUtils.cpp index 9994357a4db..c052544a588 100644 --- a/mozilla/extensions/xmlextras/soap/src/nsSOAPUtils.cpp +++ b/mozilla/extensions/xmlextras/soap/src/nsSOAPUtils.cpp @@ -45,6 +45,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsISupportsArray.h" const char* nsSOAPUtils::kSOAPEnvURI = "http://schemas.xmlsoap.org/soap/envelope/"; @@ -160,7 +161,7 @@ nsSOAPUtils::GetInheritedEncodingStyle(nsIDOMElement* aEntry, NS_ConvertASCIItoUCS2(nsSOAPUtils::kEncodingStyleAttribute), value); if (value.Length() > 0) { - *aEncodingStyle = value.ToNewCString(); + *aEncodingStyle = ToNewCString(value); return; } } diff --git a/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp b/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp index 837e6a30c98..959eb46fcd8 100644 --- a/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp +++ b/mozilla/extensions/xmlextras/tests/TestXMLExtras.cpp @@ -39,6 +39,7 @@ #include #include #include "nsContentCID.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID( kXMLDocumentCID, NS_XMLDOCUMENT_CID ); #if 0 @@ -265,7 +266,7 @@ int main (int argc, char* argv[]) pDOMDocument->GetDocumentElement(getter_AddRefs(element)); nsAutoString tagName; if (element) element->GetTagName(tagName); - char *s = tagName.ToNewCString(); + char *s = ToNewCString(tagName); printf("Document element=\"%s\"\n",s); nsCRT::free(s); nsCOMPtr doc = do_QueryInterface(pDOMDocument); diff --git a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp index c698719f1d0..1a9243f882a 100644 --- a/mozilla/extensions/xmlterm/base/mozLineTerm.cpp +++ b/mozilla/extensions/xmlterm/base/mozLineTerm.cpp @@ -28,6 +28,7 @@ #include "nscore.h" #include "nsCOMPtr.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prlog.h" #include "nsMemory.h" @@ -173,7 +174,7 @@ NS_IMETHODIMP mozLineTerm::ArePrefsSecure(PRBool *_retval) secString.Append(".htmldocument.cookie"); - char* prefStr = secString.ToNewCString(); + char* prefStr = ToNewCString(secString); XMLT_LOG(mozLineTerm::ArePrefsSecure,32, ("prefStr=%s\n", prefStr)); char *secLevelString; @@ -350,7 +351,7 @@ NS_IMETHODIMP mozLineTerm::OpenAux(const PRUnichar *command, mObserver = anObserver; // non-owning reference // Convert cookie to CString - char* cookieCStr = mCookie.ToNewCString(); + char* cookieCStr = ToNewCString(mCookie); XMLT_LOG(mozLineTerm::Open,22, ("mCookie=%s\n", cookieCStr)); // Convert initInput to CString @@ -384,9 +385,9 @@ NS_IMETHODIMP mozLineTerm::OpenAux(const PRUnichar *command, nsAutoString timeStamp; result = mozXMLTermUtils::TimeStamp(0, mLastTime, timeStamp); if (NS_SUCCEEDED(result)) { - char* temStr = timeStamp.ToNewCString(); + char* temStr = ToNewCString(timeStamp); PR_LogPrint(" LineTerm %d opened by principal %s\n", - temStr, mLTerm, securePrincipal); + temStr, mLTerm, securePrincipal); nsMemory::Free(temStr); } } @@ -548,7 +549,7 @@ NS_IMETHODIMP mozLineTerm::Write(const PRUnichar *buf, result = mozXMLTermUtils::TimeStamp(60, mLastTime, timeStamp); if (NS_SUCCEEDED(result) && (timeStamp.Length() > 0)) { - char* temStr = timeStamp.ToNewCString(); + char* temStr = ToNewCString(timeStamp); PR_LogPrint("\n", temStr); nsMemory::Free(temStr); diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp index 2f156a2ddc4..84ac8b0d408 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermSession.cpp @@ -477,7 +477,7 @@ NS_IMETHODIMP mozXMLTermSession::ReadAll(mozILineTermAux* lineTermAux, nsMemory::Free(buf_str); nsMemory::Free(buf_style); - char* temCString = bufString.ToNewCString(); + char* temCString = ToNewCString(bufString); XMLT_LOG(mozXMLTermSession::ReadAll,68,("bufString=%s\n", temCString)); nsCRT::free(temCString); @@ -1186,7 +1186,7 @@ NS_IMETHODIMP mozXMLTermSession::DisplayInput(const nsString& aString, if (NS_FAILED(result)) return NS_ERROR_FAILURE; - char* temCString = aString.ToNewCString(); + char* temCString = ToNewCString(aString); XMLT_LOG(mozXMLTermSession::DisplayInput,72, ("aString=%s\n", temCString)); nsCRT::free(temCString); @@ -1840,7 +1840,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendOutput(const nsString& aString, ("mOutputDisplayType=%d, uniformStyle=0x%x, newline=%d\n", mOutputDisplayType, uniformStyle, newline)); - char* temCString = aString.ToNewCString(); + char* temCString = ToNewCString(aString); XMLT_LOG(mozXMLTermSession::AppendOutput,72, ("aString=%s\n", temCString)); nsCRT::free(temCString); @@ -2107,7 +2107,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString, return AppendOutput(aString, aStyle, PR_TRUE); } - char* temCString = aString.ToNewCString(); + char* temCString = ToNewCString(aString); XMLT_LOG(mozXMLTermSession::AppendLineLS,62,("aString=%s\n", temCString)); nsCRT::free(temCString); @@ -2270,7 +2270,7 @@ NS_IMETHODIMP mozXMLTermSession::AppendLineLS(const nsString& aString, { nsresult result; - char* temCString = aString.ToNewCString(); + char* temCString = ToNewCString(aString); XMLT_LOG(mozXMLTermSession::InsertFragment,70,("aString=%s\n", temCString)); nsCRT::free(temCString); @@ -2471,7 +2471,7 @@ void mozXMLTermSession::SanitizeAttribute(nsString& aAttrValue, // Character '{' and string "function" both found in attribute value; // set to null string - char* temCString = aAttrValue.ToNewCString(); + char* temCString = ToNewCString(aAttrValue); XMLT_WARNING("mozXMLTermSession::SanitizeAttribute: Warning - deleted attribute on%s='%s'\n", aEventName, temCString); nsCRT::free(temCString); @@ -3001,7 +3001,7 @@ NS_IMETHODIMP mozXMLTermSession::SetHistory(PRInt32 aHistory) NS_IMETHODIMP mozXMLTermSession::GetPrompt(PRUnichar **_aPrompt) { // NOTE: Need to be sure that this may be freed by nsMemory::Free - *_aPrompt = mPromptHTML.ToNewUnicode(); + *_aPrompt = ToNewUnicode(mPromptHTML); return NS_OK; } @@ -4359,7 +4359,7 @@ void mozXMLTermSession::TraverseDOMTree(FILE* fileStream, fprintf(fileStream, "%s:\n", treeActionNames[treeActionCode-1]); - char* htmlCString = htmlString.ToNewCString(); + char* htmlCString = ToNewCString(htmlString); fprintf(fileStream, "%s", htmlCString); nsCRT::free(htmlCString); @@ -4386,7 +4386,7 @@ void mozXMLTermSession::TraverseDOMTree(FILE* fileStream, result = domElement->GetTagName(tagName); if (NS_SUCCEEDED(result)) { - char* tagCString = tagName.ToNewCString(); + char* tagCString = ToNewCString(tagName); fprintf(fileStream, "%s", tagCString); nsCRT::free(tagCString); @@ -4400,7 +4400,7 @@ void mozXMLTermSession::TraverseDOMTree(FILE* fileStream, result = domElement->GetAttribute(attName, attValue); if (NS_SUCCEEDED(result) && (attValue.Length() > 0)) { // Print attribute value - char* tagCString2 = attValue.ToNewCString(); + char* tagCString2 = ToNewCString(attValue); fprintf(fileStream, " %s=%s", printAttributeNames[j], tagCString2); nsCRT::free(tagCString2); } diff --git a/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp b/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp index f5cc2bbc816..ef2f249203e 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTermStream.cpp @@ -26,6 +26,7 @@ #include "nsCOMPtr.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsMemory.h" @@ -519,7 +520,7 @@ NS_IMETHODIMP mozXMLTermStream::Write(const PRUnichar* buf) nsAutoString strBuf ( buf ); // Convert Unicode string to UTF8 and store in buffer - char* utf8Str = strBuf.ToNewUTF8String(); + char* utf8Str = ToNewUTF8String(strBuf); mUTF8Buffer = utf8Str; nsMemory::Free(utf8Str); diff --git a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp index 867f1ebd627..b975f8e9947 100644 --- a/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp +++ b/mozilla/extensions/xmlterm/base/mozXMLTerminal.cpp @@ -30,6 +30,7 @@ #include "nsCOMPtr.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIDocument.h" #include "nsIDOMHTMLDocument.h" @@ -787,7 +788,7 @@ NS_IMETHODIMP mozXMLTerminal::Paste() nsAutoString flavor; flavor.AssignWithConversion(bestFlavor); - char* temCStr = flavor.ToNewCString(); + char* temCStr = ToNewCString(flavor); XMLT_LOG(mozXMLTerminal::Paste,20,("flavour=%s\n", temCStr)); nsMemory::Free(temCStr); diff --git a/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp b/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp index eb4200deb85..3f13c6358a1 100644 --- a/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp +++ b/mozilla/gfx/src/beos/nsDeviceContextBeOS.cpp @@ -43,6 +43,7 @@ #include "nsIPref.h" #include "nsIServiceManager.h" #include "nsCRT.h" +#include "nsReadableUtils.h" #include "nsDeviceContextBeOS.h" #include "nsFontMetricsBeOS.h" @@ -349,7 +350,7 @@ NS_IMETHODIMP nsDeviceContextBeOS::CheckFontExistence(const nsString& aFontName) { PRBool isthere = PR_FALSE; - char* cStr = aFontName.ToNewCString(); + char* cStr = ToNewCString(aFontName); int32 numFamilies = count_font_families(); for(int32 i = 0; i < numFamilies; i++) diff --git a/mozilla/gfx/src/beos/nsFontMetricsBeOS.cpp b/mozilla/gfx/src/beos/nsFontMetricsBeOS.cpp index 3023e6b21e2..8a0dfe7c05b 100644 --- a/mozilla/gfx/src/beos/nsFontMetricsBeOS.cpp +++ b/mozilla/gfx/src/beos/nsFontMetricsBeOS.cpp @@ -47,6 +47,7 @@ #include "nsCOMPtr.h" #include "nspr.h" #include "nsHashtable.h" +#include "nsReadableUtils.h" #undef USER_DEFINED #define USER_DEFINED "x-user-def" @@ -351,7 +352,7 @@ nsFontMetricsBeOS::FamilyExists(const nsString& aName) name.ToLowerCase(); PRBool isthere = PR_FALSE; - char* cStr = name.ToNewCString(); + char* cStr = ToNewCString(name); int32 numFamilies = count_font_families(); for(int32 i = 0; i < numFamilies; i++) @@ -426,7 +427,7 @@ EnumFonts(nsIAtom* aLangGroup, const char* aGeneric, PRUint32* aCount, if(get_font_family(i, &family, &flags) == B_OK) { font_name.AssignWithConversion(family); - array[i] = font_name.ToNewUnicode(); + array[i] = ToNewUnicode(font_name); } } diff --git a/mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp b/mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp index de7003c5dcb..6d7fdeca752 100644 --- a/mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp +++ b/mozilla/gfx/src/gtk/nsFontMetricsGTK.cpp @@ -4135,7 +4135,7 @@ EnumerateNode(void* aElement, void* aData) } PRUnichar** array = info->mArray; int j = info->mIndex; - PRUnichar* str = node->mName.ToNewUnicode(); + PRUnichar* str = ToNewUnicode(node->mName); if (!str) { for (j = j - 1; j >= 0; j--) { nsMemory::Free(array[j]); diff --git a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp index 2ccb7d00a40..98b9bb333f3 100644 --- a/mozilla/gfx/src/mac/nsDeviceContextMac.cpp +++ b/mozilla/gfx/src/mac/nsDeviceContextMac.cpp @@ -65,6 +65,7 @@ #include "nsRegionMac.h" #include "nsIScreenManager.h" #include "nsIServiceManager.h" +#include "nsReadableUtils.h" PRUint32 nsDeviceContextMac::mPixelsPerInch = 96; @@ -1095,7 +1096,7 @@ EnumerateFamily(nsHashKey *aKey, void *aData, void* closure) int j = info->mIndex; - PRUnichar* str = (((FontNameKey*)aKey)->mString).ToNewUnicode(); + PRUnichar* str = ToNewUnicode(((FontNameKey*)aKey)->mString); if (!str) { for (j = j - 1; j >= 0; j--) { nsMemory::Free(array[j]); @@ -1164,7 +1165,7 @@ EnumerateFont(nsHashKey *aKey, void *aData, void* closure) short fondID = (short) aData; ScriptCode script = ::FontToScript(fondID); if(script == info->mScript) { - PRUnichar* str = (((FontNameKey*)aKey)->mString).ToNewUnicode(); + PRUnichar* str = ToNewUnicode(((FontNameKey*)aKey)->mString); if (!str) { for (j = j - 1; j >= 0; j--) { nsMemory::Free(array[j]); diff --git a/mozilla/gfx/src/mac/nsUnicodeMappingUtil.cpp b/mozilla/gfx/src/mac/nsUnicodeMappingUtil.cpp index 9b7beb2f5ea..5a2409aa9fa 100644 --- a/mozilla/gfx/src/mac/nsUnicodeMappingUtil.cpp +++ b/mozilla/gfx/src/mac/nsUnicodeMappingUtil.cpp @@ -42,6 +42,7 @@ #include "nsUnicodeMappingUtil.h" #include "nsUnicodeFontMappingCache.h" #include "nsDeviceContextMac.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kPrefCID, NS_PREF_CID); #define BAD_FONT_NUM -1 @@ -349,7 +350,7 @@ nsUnicodeMappingUtil::PrefEnumCallback(const char* aName, void* aClosure) delete Self->mGenericFontMapping[script][type]; Self->mGenericFontMapping[script][type] = fontname; #ifdef DEBUG_ftang_font - char* utf8 = fontname->ToNewUTF8String(); + char* utf8 = ToNewUTF8String(*fontname); printf("font %d %d %s= %s\n",script , type, aName,utf8); Recycle(utf8); #endif diff --git a/mozilla/gfx/src/motif/nsDeviceContextMotif.cpp b/mozilla/gfx/src/motif/nsDeviceContextMotif.cpp index 4f969b9c877..6eac795022f 100644 --- a/mozilla/gfx/src/motif/nsDeviceContextMotif.cpp +++ b/mozilla/gfx/src/motif/nsDeviceContextMotif.cpp @@ -43,6 +43,7 @@ #include "math.h" #include "nspr.h" #include "il_util.h" +#include "nsReadableUtils.h" #define NS_TO_X_COMPONENT(a) ((a << 8) | (a)) @@ -442,7 +443,7 @@ NS_IMETHODIMP nsDeviceContextMotif :: CheckFontExistence(const nsString& aFontNa else dpi = 100; - char* fontName = aFontName.ToNewCString(); + char* fontName = ToNewCString(aFontName); PR_snprintf(wildstring, namelen + 200, "*-%s-*-*-normal--*-*-%d-%d-*-*-*", fontName, dpi, dpi); diff --git a/mozilla/gfx/src/motif/nsFontMetricsMotif.cpp b/mozilla/gfx/src/motif/nsFontMetricsMotif.cpp index eb20e8b8d71..dcbab19b11b 100644 --- a/mozilla/gfx/src/motif/nsFontMetricsMotif.cpp +++ b/mozilla/gfx/src/motif/nsFontMetricsMotif.cpp @@ -42,6 +42,7 @@ #include "nspr.h" #include "nsCRT.h" +#include "nsReadableUtils.h" //#define NOISY_FONTS @@ -145,7 +146,7 @@ NS_IMETHODIMP nsFontMetricsMotif :: Init(const nsFont& aFont, nsIAtom* aLangGrou { //we were not able to match the font name at all... - char *newname = firstFace.ToNewCString(); + char *newname = ToNewCString(firstFace); PR_snprintf(&wildstring[namelen + 1], namelen + 200, "*-%s-%s-%c-normal--*-*-%d-%d-*-*-*", diff --git a/mozilla/gfx/src/nsPrintOptionsImpl.cpp b/mozilla/gfx/src/nsPrintOptionsImpl.cpp index 3dcf939d4fd..9163ca4766f 100644 --- a/mozilla/gfx/src/nsPrintOptionsImpl.cpp +++ b/mozilla/gfx/src/nsPrintOptionsImpl.cpp @@ -39,6 +39,7 @@ #include "nsPrintOptionsImpl.h" #include "nsCoord.h" #include "nsUnitConversion.h" +#include "nsReadableUtils.h" // For Prefs #include "nsIPref.h" @@ -435,7 +436,7 @@ NS_IMETHODIMP nsPrintOptions::SetOrientation(PRInt32 aOrientation) NS_IMETHODIMP nsPrintOptions::GetPrintCommand(PRUnichar * *aPrintCommand) { //NS_ENSURE_ARG_POINTER(aPrintCommand); - *aPrintCommand = mPrintCommand.ToNewUnicode(); + *aPrintCommand = ToNewUnicode(mPrintCommand); return NS_OK; } NS_IMETHODIMP nsPrintOptions::SetPrintCommand(const PRUnichar * aPrintCommand) @@ -461,7 +462,7 @@ NS_IMETHODIMP nsPrintOptions::SetPrintToFile(PRBool aPrintToFile) NS_IMETHODIMP nsPrintOptions::GetToFileName(PRUnichar * *aToFileName) { //NS_ENSURE_ARG_POINTER(aToFileName); - *aToFileName = mToFileName.ToNewUnicode(); + *aToFileName = ToNewUnicode(mToFileName); return NS_OK; } NS_IMETHODIMP nsPrintOptions::SetToFileName(const PRUnichar * aToFileName) @@ -551,7 +552,7 @@ NS_IMETHODIMP nsPrintOptions::SetPrintRange(PRInt16 aPrintRange) NS_IMETHODIMP nsPrintOptions::GetTitle(PRUnichar * *aTitle) { NS_ENSURE_ARG_POINTER(aTitle); - *aTitle = mTitle.ToNewUnicode(); + *aTitle = ToNewUnicode(mTitle); return NS_OK; } NS_IMETHODIMP nsPrintOptions::SetTitle(const PRUnichar * aTitle) @@ -565,7 +566,7 @@ NS_IMETHODIMP nsPrintOptions::SetTitle(const PRUnichar * aTitle) NS_IMETHODIMP nsPrintOptions::GetDocURL(PRUnichar * *aDocURL) { NS_ENSURE_ARG_POINTER(aDocURL); - *aDocURL = mURL.ToNewUnicode(); + *aDocURL = ToNewUnicode(mURL); return NS_OK; } NS_IMETHODIMP nsPrintOptions::SetDocURL(const PRUnichar * aDocURL) @@ -585,15 +586,15 @@ nsPrintOptions::GetMarginStrs(PRUnichar * *aTitle, *aTitle = nsnull; if (aType == eHeader) { switch (aJust) { - case kJustLeft: *aTitle = mHeaderStrs[0].ToNewUnicode();break; - case kJustCenter: *aTitle = mHeaderStrs[1].ToNewUnicode();break; - case kJustRight: *aTitle = mHeaderStrs[2].ToNewUnicode();break; + case kJustLeft: *aTitle = ToNewUnicode(mHeaderStrs[0]);break; + case kJustCenter: *aTitle = ToNewUnicode(mHeaderStrs[1]);break; + case kJustRight: *aTitle = ToNewUnicode(mHeaderStrs[2]);break; } //switch } else { switch (aJust) { - case kJustLeft: *aTitle = mFooterStrs[0].ToNewUnicode();break; - case kJustCenter: *aTitle = mFooterStrs[1].ToNewUnicode();break; - case kJustRight: *aTitle = mFooterStrs[2].ToNewUnicode();break; + case kJustLeft: *aTitle = ToNewUnicode(mFooterStrs[0]);break; + case kJustCenter: *aTitle = ToNewUnicode(mFooterStrs[1]);break; + case kJustRight: *aTitle = ToNewUnicode(mFooterStrs[2]);break; } //switch } return NS_OK; @@ -761,7 +762,7 @@ nsresult nsPrintOptions::WritePrefString(nsIPref * aPref, NS_ENSURE_ARG_POINTER(aPref); NS_ENSURE_ARG_POINTER(aPrefId); - PRUnichar * str = aString.ToNewUnicode(); + PRUnichar * str = ToNewUnicode(aString); nsresult rv = aPref->SetUnicharPref(aPrefId, str); nsMemory::Free(str); @@ -817,7 +818,7 @@ void nsPrintOptions::WriteInchesFromTwipsPref(nsIPref * aPref, double inches = NS_TWIPS_TO_INCHES(aTwips); nsAutoString inchesStr; inchesStr.AppendFloat(inches); - char * str = inchesStr.ToNewCString(); + char * str = ToNewCString(inchesStr); if (str) { aPref->SetCharPref(aPrefId, str); } else { diff --git a/mozilla/gfx/src/os2/nsFontMetricsOS2.cpp b/mozilla/gfx/src/os2/nsFontMetricsOS2.cpp index caed7524637..43f18434552 100644 --- a/mozilla/gfx/src/os2/nsFontMetricsOS2.cpp +++ b/mozilla/gfx/src/os2/nsFontMetricsOS2.cpp @@ -34,6 +34,7 @@ #include "prmem.h" #include "plhash.h" #include "prprf.h" +#include "nsReadableUtils.h" #ifdef MOZ_MATHML #include @@ -1518,7 +1519,7 @@ nsFontMetricsOS2::SetUnicodeFont( HPS aPS, LONG lcid ) { char fontPref[32]; char* value = nsnull; - char* generic = mGeneric->ToNewCString(); + char* generic = ToNewCString(*mGeneric); sprintf( fontPref, "font.name.%s.x-unicode", generic ); nsMemory::Free( generic ); @@ -1673,7 +1674,7 @@ nsFontEnumeratorOS2::EnumerateFonts(const char* aLangGroup, { nsGlobalFont* font = &(nsFontMetricsOS2::gGlobalFonts[i]); FONTMETRICS* fm = &(font->fontMetrics); - PRUnichar* str = font->name->ToNewUnicode(); + PRUnichar* str = ToNewUnicode(*(font->name)); if (!str) { for (i = count - 1; i >= 0; i--) { @@ -1796,7 +1797,7 @@ nsFontEnumeratorOS2::EnumerateAllFonts(PRUint32* aCount, PRUnichar*** aResult) int i = 0; while( i < nsFontMetricsOS2::gGlobalFontsCount ) { - PRUnichar* str = nsFontMetricsOS2::gGlobalFonts[i].name->ToNewUnicode(); + PRUnichar* str = ToNewUnicode(*nsFontMetricsOS2::gGlobalFonts[i].name); if (!str) { for (i = i - 1; i >= 0; i--) { nsMemory::Free(array[i]); diff --git a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp index a150a0fd65c..954816c5af6 100644 --- a/mozilla/gfx/src/photon/nsDeviceContextPh.cpp +++ b/mozilla/gfx/src/photon/nsDeviceContextPh.cpp @@ -42,6 +42,7 @@ #include "nsIPref.h" #include "nsIServiceManager.h" #include "nsCRT.h" +#include "nsReadableUtils.h" #include "nsDeviceContextPh.h" #include "nsRenderingContextPh.h" @@ -394,7 +395,7 @@ NS_IMETHODIMP nsDeviceContextPh :: GetClientRect( nsRect &aRect ) { /* I need to know the requested font size to finish this function */ NS_IMETHODIMP nsDeviceContextPh :: CheckFontExistence( const nsString& aFontName ) { nsresult ret_code = NS_ERROR_FAILURE; - char *fontName = aFontName.ToNewCString(); + char *fontName = ToNewCString(aFontName); if( fontName ) { FontID *id = NULL; diff --git a/mozilla/gfx/src/photon/nsFontMetricsPh.cpp b/mozilla/gfx/src/photon/nsFontMetricsPh.cpp index f02f8e933dd..583d0d74dbd 100644 --- a/mozilla/gfx/src/photon/nsFontMetricsPh.cpp +++ b/mozilla/gfx/src/photon/nsFontMetricsPh.cpp @@ -43,6 +43,7 @@ #include "nsPhGfxLog.h" #include "nsHashtable.h" #include "nsIPref.h" +#include "nsReadableUtils.h" #include #include @@ -159,7 +160,7 @@ NS_IMPL_ISUPPORTS1( nsFontMetricsPh, nsIFontMetrics ) result = aContext->FirstExistingFont(aFont, firstFace); - str = firstFace.ToNewCString(); + str = ToNewCString(firstFace); if( !str || !str[0] ) { @@ -171,7 +172,7 @@ NS_IMPL_ISUPPORTS1( nsFontMetricsPh, nsIFontMetrics ) const PRUnichar *uc; aLangGroup->GetUnicode( &uc ); nsString language( uc ); - char *cstring = language.ToNewCString(); + char *cstring = ToNewCString(language); char prop[256]; sprintf( prop, "font.name.%s.%s", str, cstring ); @@ -289,7 +290,7 @@ NS_IMETHODIMP nsFontMetricsPh :: Destroy( ) static void apGenericFamilyToFont( const nsString& aGenericFamily, nsIDeviceContext* aDC, nsString& aFontFace ) { - char *str = aGenericFamily.ToNewCString(); + char *str = ToNewCString(aGenericFamily); //delete [] str; free (str); } @@ -469,7 +470,7 @@ static PRIntn EnumerateFamily( PLHashEntry* he, PRIntn i, void* arg ) EnumerateFamilyInfo* info = (EnumerateFamilyInfo*) arg; PRUnichar** array = info->mArray; int j = info->mIndex; - PRUnichar* str = ((nsString*) he->key)->ToNewUnicode(); + PRUnichar* str = ToNewUnicode(*NS_STATIC_CAST(const nsString*, he->key)); if (!str) { @@ -573,12 +574,12 @@ NS_IMETHODIMP nsFontEnumeratorPh::EnumerateFonts( const char* aLangGroup, const if(stricmp(aGeneric, "monospace") == 0) { if(gFontDetails[i].flags & PHFONT_INFO_FIXED) - array[nCount++] = gFontNames[i]->ToNewUnicode(); + array[nCount++] = ToNewUnicode(*gFontNames[i]); } else { if (gFontDetails[i].flags & PHFONT_INFO_PROP) - array[nCount++] = gFontNames[i]->ToNewUnicode(); + array[nCount++] = ToNewUnicode(*gFontNames[i]); } } *aCount = nCount; diff --git a/mozilla/gfx/src/photon/nsRenderingContextPh.cpp b/mozilla/gfx/src/photon/nsRenderingContextPh.cpp index 73cc907cd58..1d461fc6033 100644 --- a/mozilla/gfx/src/photon/nsRenderingContextPh.cpp +++ b/mozilla/gfx/src/photon/nsRenderingContextPh.cpp @@ -52,6 +52,7 @@ #include "nsDrawingSurfacePh.h" #include #include +#include "nsReadableUtils.h" static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID); static NS_DEFINE_IID(kIDrawingSurfaceIID, NS_IDRAWING_SURFACE_IID); @@ -957,8 +958,14 @@ NS_IMETHODIMP nsRenderingContextPh :: GetWidth(const char* aString, PRUint32 aLe //using "M" to get rid of the right bearing of the right most char of the string. + /* XXXjag this code looks very bogus to me, but I've no idea what they're + * trying to accomplish here. At my best guess they're trying to do this: + * char* text = ToNewCString(nsDependentCString(aString, aLength) + + * NS_LITERAL_CSTRING("M.")); + * text[aLength + 1] = '\0'; // overwrites the '.' above + */ nsCString strTail("M"); - char* tail=(char*)strTail.ToNewUnicode(); + char* tail=(char*)ToNewUnicode(strTail); PRUint32 tailLength=strlen(tail); char* text = (char*) nsMemory::Alloc(aLength + tailLength + 2); diff --git a/mozilla/gfx/src/ps/nsAFMObject.cpp b/mozilla/gfx/src/ps/nsAFMObject.cpp index 67022b75e6f..33664c3b9f5 100644 --- a/mozilla/gfx/src/ps/nsAFMObject.cpp +++ b/mozilla/gfx/src/ps/nsAFMObject.cpp @@ -51,6 +51,7 @@ #include "Courier-BoldOblique.h" #include "Courier-Oblique.h" #include "Symbol.h" +#include "nsReadableUtils.h" @@ -302,7 +303,7 @@ PRBool bvalue; AFMKey key; double value; PRInt32 ivalue; -char* AFMFileName= aFontName.name.ToNewUTF8String(); // file we will open +char* AFMFileName= ToNewUTF8String(aFontName.name); // file we will open if(nsnull == AFMFileName) return (success); diff --git a/mozilla/gfx/src/ps/nsPostScriptObj.cpp b/mozilla/gfx/src/ps/nsPostScriptObj.cpp index 94cc2ae3c2b..9bc90842fbb 100644 --- a/mozilla/gfx/src/ps/nsPostScriptObj.cpp +++ b/mozilla/gfx/src/ps/nsPostScriptObj.cpp @@ -1629,7 +1629,7 @@ nsPostScriptObj::GetUnixPrinterSetting(const nsCAutoString& aKey, char** aVal) if (!NS_SUCCEEDED(res)) { return PR_FALSE; } - *aVal = oValue.ToNewCString(); + *aVal = ToNewCString(oValue); return PR_TRUE; } diff --git a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp index 99c4ea269e5..c32673f39df 100644 --- a/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp +++ b/mozilla/gfx/src/qt/nsDeviceContextSpecQT.cpp @@ -41,6 +41,7 @@ #include "nsRenderingContextQT.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIPrintOptions.h" #include "nsGfxCIID.h" @@ -220,8 +221,8 @@ NS_IMETHODIMP nsDeviceContextSpecQT::Init(PRBool aQuiet) cmdStr = command; printFileStr = printfile; - char *pCmdStr = cmdStr.ToNewCString(); - char *pPrintFileStr = printFileStr.ToNewCString(); + char *pCmdStr = ToNewCString(cmdStr); + char *pPrintFileStr = ToNewCString(printFileStr); sprintf(mPrData.command,pCmdStr); sprintf(mPrData.path,pPrintFileStr); nsMemory::Free(pCmdStr); diff --git a/mozilla/gfx/src/qt/nsFontMetricsQT.cpp b/mozilla/gfx/src/qt/nsFontMetricsQT.cpp index aedc8694d72..e855eae1526 100644 --- a/mozilla/gfx/src/qt/nsFontMetricsQT.cpp +++ b/mozilla/gfx/src/qt/nsFontMetricsQT.cpp @@ -43,6 +43,7 @@ #include "nsFontMetricsQT.h" #include "nsFont.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsISaveAsCharset.h" #include "nsIPref.h" @@ -2104,7 +2105,7 @@ static nsresult EnumFonts(nsIAtom *aLangGroup,const char *aGeneric, } return NS_ERROR_OUT_OF_MEMORY; } - node->name = name.ToNewUnicode(); + node->name = ToNewUnicode(name); if (!node->name) { FontEnumNode *ptr = head,*tmp; while (ptr) { diff --git a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp index 7c7e1c4f84f..7ab5d7d8419 100644 --- a/mozilla/gfx/src/windows/nsFontMetricsWin.cpp +++ b/mozilla/gfx/src/windows/nsFontMetricsWin.cpp @@ -56,6 +56,7 @@ #include "prmem.h" #include "plhash.h" #include "prprf.h" +#include "nsReadableUtils.h" #define NOT_SETUP 0x33 static PRBool gIsWIN95 = NOT_SETUP; @@ -4862,7 +4863,7 @@ nsFontEnumeratorWin::EnumerateAllFonts(PRUint32* aCount, PRUnichar*** aResult) } for (int i = 0; i < count; ++i) { nsGlobalFont* font = (nsGlobalFont*)nsFontMetricsWin::gGlobalFonts->ElementAt(i); - PRUnichar* str = font->name.ToNewUnicode(); + PRUnichar* str = ToNewUnicode(font->name); if (!str) { for (i = i - 1; i >= 0; --i) { nsMemory::Free(array[i]); @@ -4960,7 +4961,7 @@ nsFontEnumeratorWin::EnumerateFonts(const char* aLangGroup, nsGlobalFont* font = (nsGlobalFont*)nsFontMetricsWin::gGlobalFonts->ElementAt(i); if (SignatureMatchesLangGroup(&font->signature, aLangGroup) && FontMatchesGenericType(font, aGeneric, aLangGroup)) { - PRUnichar* str = font->name.ToNewUnicode(); + PRUnichar* str = ToNewUnicode(font->name); if (!str) { for (j = j - 1; j >= 0; --j) { nsMemory::Free(array[j]); diff --git a/mozilla/gfx/src/xlib/nsFontMetricsXlib.cpp b/mozilla/gfx/src/xlib/nsFontMetricsXlib.cpp index a21b8bf0a97..45721c5226a 100644 --- a/mozilla/gfx/src/xlib/nsFontMetricsXlib.cpp +++ b/mozilla/gfx/src/xlib/nsFontMetricsXlib.cpp @@ -4146,7 +4146,7 @@ EnumerateNode(void* aElement, void* aData) } PRUnichar** array = info->mArray; int j = info->mIndex; - PRUnichar* str = node->mName.ToNewUnicode(); + PRUnichar* str = ToNewUnicode(node->mName); if (!str) { for (j = j - 1; j >= 0; j--) { nsMemory::Free(array[j]); diff --git a/mozilla/htmlparser/robot/nsDebugRobot.cpp b/mozilla/htmlparser/robot/nsDebugRobot.cpp index efdbe56af79..43b3ab9ef42 100644 --- a/mozilla/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/htmlparser/robot/nsDebugRobot.cpp @@ -46,6 +46,7 @@ #include "nsWeakReference.h" #include "nsVoidArray.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIURL.h" #include "nsIServiceManager.h" #include "nsIURL.h" @@ -262,7 +263,7 @@ extern "C" NS_EXPORT int DebugRobot( if (NS_FAILED(rv)) return rv; nsIURI *uri = nsnull; - char *uriStr = urlName->ToNewCString(); + char *uriStr = ToNewCString(*urlName); if (!uriStr) return NS_ERROR_OUT_OF_MEMORY; rv = service->NewURI(uriStr, nsnull, &uri); nsCRT::free(uriStr); diff --git a/mozilla/htmlparser/robot/nsRobotSink.cpp b/mozilla/htmlparser/robot/nsRobotSink.cpp index a193b8dfa24..8aa2e81b755 100644 --- a/mozilla/htmlparser/robot/nsRobotSink.cpp +++ b/mozilla/htmlparser/robot/nsRobotSink.cpp @@ -41,6 +41,7 @@ #include "nsIParserNode.h" #include "nsIParser.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIURL.h" #include "nsIURL.h" #include "nsIServiceManager.h" @@ -372,7 +373,7 @@ void RobotSink::ProcessLink(const nsString& aLink) rv = mDocumentURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri); if (NS_FAILED(rv)) return; - char *uriStr = aLink.ToNewCString(); + char *uriStr = ToNewCString(aLink); if (!uriStr) return; rv = service->NewURI(uriStr, baseUri, &uri); nsCRT::free(uriStr); diff --git a/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp b/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp index 93d0f5175fe..235338995f1 100644 --- a/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp +++ b/mozilla/htmlparser/src/nsHTMLContentSinkStream.cpp @@ -50,6 +50,7 @@ #include "nsIParserNode.h" #include #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIParser.h" #include "nsICharsetAlias.h" #include "nsIServiceManager.h" @@ -667,7 +668,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode) #ifdef DEBUG_prettyprint if (isDirty) printf("AddStartTag(%s): BBO=%d, BAO=%d, BBC=%d, BAC=%d\n", - name.ToNewCString(), + NS_LossyConvertUCS2toASCII(name).get(), BreakBeforeOpen(tag), BreakAfterOpen(tag), BreakBeforeClose(tag), diff --git a/mozilla/htmlparser/src/nsHTMLTokens.cpp b/mozilla/htmlparser/src/nsHTMLTokens.cpp index 56bada1d3d7..2ef8f943443 100644 --- a/mozilla/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokens.cpp @@ -2126,7 +2126,7 @@ PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) { * @return */ void CEntityToken::DebugDumpSource(nsOutputStream& out) { - char* cp=mTextValue.ToNewCString(); + char* cp = ToNewCString(mTextValue); out << "&" << *cp; delete[] cp; } diff --git a/mozilla/htmlparser/src/nsLoggingSink.cpp b/mozilla/htmlparser/src/nsLoggingSink.cpp index 4eb85dff6b5..0c85be21a1d 100644 --- a/mozilla/htmlparser/src/nsLoggingSink.cpp +++ b/mozilla/htmlparser/src/nsLoggingSink.cpp @@ -38,6 +38,7 @@ #include "nsLoggingSink.h" #include "nsHTMLTags.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prprf.h" static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID); @@ -754,7 +755,7 @@ nsLoggingSink::GetNewCString(const nsAReadableString& aValue, char** aResult) result=QuoteText(aValue,temp); if(NS_SUCCEEDED(result)) { if(temp.Length()>0) { - *aResult=temp.ToNewCString(); + *aResult = ToNewCString(temp); } } return result; diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp index 3627c9a5076..2ed2290bb7e 100644 --- a/mozilla/htmlparser/src/nsScanner.cpp +++ b/mozilla/htmlparser/src/nsScanner.cpp @@ -109,7 +109,7 @@ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharset { MOZ_COUNT_CTOR(nsScanner); - PRUnichar* buffer = anHTMLString.ToNewUnicode(); + PRUnichar* buffer = ToNewUnicode(anHTMLString); mTotalRead = anHTMLString.Length(); mSlidingBuffer = nsnull; mCountRemaining = 0; diff --git a/mozilla/htmlparser/tests/grabpage/grabpage.cpp b/mozilla/htmlparser/tests/grabpage/grabpage.cpp index b0de07cd7e9..1c412e4d3b8 100644 --- a/mozilla/htmlparser/tests/grabpage/grabpage.cpp +++ b/mozilla/htmlparser/tests/grabpage/grabpage.cpp @@ -44,6 +44,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "nsString.h" +#include "nsReadableUtils.h" #include "nsCRT.h" #include "prprf.h" @@ -204,7 +205,7 @@ PageGrabber::NextFile(const char* aExtension) // See if file already exists; if it does advance mFileNum by 100 and // try again. - cname = name.ToNewCString(); + cname = ToNewCString(name); struct stat sb; int s = stat(cname, &sb); if (s < 0) { diff --git a/mozilla/htmlparser/tests/outsinks/Convert.cpp b/mozilla/htmlparser/tests/outsinks/Convert.cpp index f0db039bbcf..7e8ba64b758 100644 --- a/mozilla/htmlparser/tests/outsinks/Convert.cpp +++ b/mozilla/htmlparser/tests/outsinks/Convert.cpp @@ -29,6 +29,7 @@ #include "nsLayoutCID.h" #include "nsIHTMLToTextSink.h" #include "nsIComponentManager.h" +#include "nsReadableUtils.h" extern "C" void NS_SetupRegistry(); @@ -49,7 +50,7 @@ Compare(nsString& str, nsString& aFileName) { // Open the file in a Unix-centric way, // until I find out how to use nsFileSpec: - char* filename = aFileName.ToNewCString(); + char* filename = ToNewCString(aFileName); FILE* file = fopen(filename, "r"); if (!file) { @@ -89,7 +90,7 @@ Compare(nsString& str, nsString& aFileName) { nsAutoString left; str.Left(left, different); - char* cstr = left.ToNewUTF8String(); + char* cstr = ToNewUTF8String(left); printf("Comparison failed at char %d:\n-----\n%s\n-----\n", different, cstr); Recycle(cstr); @@ -141,8 +142,8 @@ HTML2text(nsString& inString, nsString& inType, nsString& outType, if (inType != NS_LITERAL_STRING("text/html") || outType != NS_LITERAL_STRING("text/plain")) { - char* in = inType.ToNewCString(); - char* out = outType.ToNewCString(); + char* in = ToNewCString(inType); + char* out = ToNewCString(outType); printf("Don't know how to convert from %s to %s\n", in, out); Recycle(in); Recycle(out); @@ -177,7 +178,7 @@ HTML2text(nsString& inString, nsString& inType, nsString& outType, parser->RegisterDTD(dtd); - char* inTypeStr = inType.ToNewCString(); + char* inTypeStr = ToNewCString(inType); rv = parser->Parse(inString, 0, NS_ConvertASCIItoUCS2(inTypeStr), PR_FALSE, PR_TRUE); delete[] inTypeStr; if (NS_FAILED(rv)) @@ -190,7 +191,7 @@ HTML2text(nsString& inString, nsString& inType, nsString& outType, if (compareAgainst.Length() > 0) return Compare(outString, compareAgainst); - char* charstar = outString.ToNewUTF8String(); + char* charstar = ToNewUTF8String(outString); printf("Output string is:\n--------------------\n%s--------------------\n", charstar); delete[] charstar; diff --git a/mozilla/intl/chardet/src/nsXMLEncodingObserver.cpp b/mozilla/intl/chardet/src/nsXMLEncodingObserver.cpp index 387e91babfa..b818804e6fc 100644 --- a/mozilla/intl/chardet/src/nsXMLEncodingObserver.cpp +++ b/mozilla/intl/chardet/src/nsXMLEncodingObserver.cpp @@ -50,6 +50,7 @@ #include "nsIServiceManager.h" #include "nsObserverBase.h" #include "nsWeakReference.h" +#include "nsReadableUtils.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); @@ -177,7 +178,7 @@ NS_IMETHODIMP nsXMLEncodingObserver::Notify( res = calias->GetPreferred(encoding, preferred); if(NS_SUCCEEDED(res)) { - const char* charsetInCStr = preferred.ToNewCString(); + const char* charsetInCStr = ToNewCString(preferred); if(nsnull != charsetInCStr) { res = NotifyWebShell(0,0, charsetInCStr, kCharsetFromMetaTag ); delete [] (char*)charsetInCStr; diff --git a/mozilla/intl/chardet/src/windows/nsNativeDetectors.cpp b/mozilla/intl/chardet/src/windows/nsNativeDetectors.cpp index 0c88bc67979..93b92b6fc11 100644 --- a/mozilla/intl/chardet/src/windows/nsNativeDetectors.cpp +++ b/mozilla/intl/chardet/src/windows/nsNativeDetectors.cpp @@ -45,6 +45,7 @@ #include "nsISupports.h" #include "nsNativeCharDetDll.h" #include "pratom.h" +#include "nsReadableUtils.h" #include "nsICharsetDetector.h" #include "nsICharsetDetectionObserver.h" @@ -84,7 +85,7 @@ static HRESULT DetectCharsetUsingMLang(IMultiLanguage *aMultiLanguage, IMLangCon if (SUCCEEDED(hr)) { // convert WCHAR* to char* nsString aCharset(aCodePageInfo.wszWebCharset); - char *cstr = aCharset.ToNewCString(); + char *cstr = ToNewCString(aCharset); PL_strcpy(charset, cstr); delete [] cstr; aConfidence = eSureAnswer; diff --git a/mozilla/intl/compatibility/src/nsI18nCompatibility.cpp b/mozilla/intl/compatibility/src/nsI18nCompatibility.cpp index 2864afdfe59..476f1e48179 100644 --- a/mozilla/intl/compatibility/src/nsI18nCompatibility.cpp +++ b/mozilla/intl/compatibility/src/nsI18nCompatibility.cpp @@ -41,6 +41,7 @@ #include "nsISupports.h" #include "nsIComponentManager.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIFactory.h" #include "nsIGenericFactory.h" #include "nsIModule.h" @@ -73,7 +74,7 @@ NS_IMETHODIMP nsI18nCompatibility::CSIDtoCharsetName(PRUint16 csid, PRUnichar ** { nsString charsetname; charsetname.AssignWithConversion(I18N_CSIDtoCharsetName(csid)); - *_retval = charsetname.ToNewUnicode(); + *_retval = ToNewUnicode(charsetname); return NS_OK; } diff --git a/mozilla/intl/compatibility/tests/TestI18nCompatibility.cpp b/mozilla/intl/compatibility/tests/TestI18nCompatibility.cpp index 261b5a48039..41a17f1fcf6 100644 --- a/mozilla/intl/compatibility/tests/TestI18nCompatibility.cpp +++ b/mozilla/intl/compatibility/tests/TestI18nCompatibility.cpp @@ -41,6 +41,7 @@ #include "nsISupports.h" #include "nsIServiceManager.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsII18nCompatibility.h" @@ -79,7 +80,7 @@ int main(int argc, char** argv) { rv = I18nCompatibility->CSIDtoCharsetName(csid, &charsetUni); if (NS_SUCCEEDED(rv) && NULL != charsetUni) { nsString tempStr(charsetUni); - char *tempCstr = tempStr.ToNewCString(); + char *tempCstr = ToNewCString(tempStr); nsMemory::Free(charsetUni); diff --git a/mozilla/intl/locale/src/mac/nsMacLocale.cpp b/mozilla/intl/locale/src/mac/nsMacLocale.cpp index 2617cd751b4..b41838ff90a 100644 --- a/mozilla/intl/locale/src/mac/nsMacLocale.cpp +++ b/mozilla/intl/locale/src/mac/nsMacLocale.cpp @@ -39,6 +39,7 @@ #include "nsISupports.h" #include "nscore.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsILocale.h" #include "nsMacLocale.h" #include "nsLocaleCID.h" @@ -235,7 +236,7 @@ nsMacLocale::GetPlatformLocale(const nsString* locale,short* scriptCode, short* char country_code[3]; char lang_code[3]; char region_code[3]; - char* xp_locale = locale->ToNewCString(); + char* xp_locale = ToNewCString(*locale); bool validCountryFound; int i; diff --git a/mozilla/intl/locale/src/nsLocale.cpp b/mozilla/intl/locale/src/nsLocale.cpp index 383fca53064..b76ad55899a 100644 --- a/mozilla/intl/locale/src/nsLocale.cpp +++ b/mozilla/intl/locale/src/nsLocale.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsString.h" +#include "nsReadableUtils.h" #include "pratom.h" #include "prtypes.h" #include "nsISupports.h" @@ -144,7 +145,7 @@ nsLocale::GetCategory(const PRUnichar *category,PRUnichar **result) value = (const nsString*)PL_HashTableLookup(fHashtable,&aCategory); if (value!=NULL) { - (*result)=value->ToNewUnicode(); + (*result) = ToNewUnicode(*value); return NS_OK; } diff --git a/mozilla/intl/locale/src/nsLocaleService.cpp b/mozilla/intl/locale/src/nsLocaleService.cpp index ff2425b8b3c..834d4330d25 100644 --- a/mozilla/intl/locale/src/nsLocaleService.cpp +++ b/mozilla/intl/locale/src/nsLocaleService.cpp @@ -217,7 +217,7 @@ nsLocaleService::nsLocaleService(void) if ( lang == nsnull ) { nsCAutoString langcstr("en-US"); platformLocale.AssignWithConversion("en_US"); - lang = langcstr.ToNewCString(); + lang = ToNewCString(langcstr); result = posixConverter->GetXPLocale(lang,&xpLocale); nsCRT::free(lang); } @@ -272,7 +272,7 @@ nsLocaleService::nsLocaleService(void) char* lang = getenv("LANG"); if ( lang == nsnull ) { nsCAutoString langcstr("en-US"); - lang = langcstr.ToNewCString(); + lang = ToNewCString(langcstr); result = os2Converter->GetXPLocale(lang,&xpLocale); nsCRT::free(lang); } diff --git a/mozilla/intl/locale/src/nsScriptableDateFormat.cpp b/mozilla/intl/locale/src/nsScriptableDateFormat.cpp index 3c8d597fec0..3e40d61a39f 100644 --- a/mozilla/intl/locale/src/nsScriptableDateFormat.cpp +++ b/mozilla/intl/locale/src/nsScriptableDateFormat.cpp @@ -45,6 +45,7 @@ #include "nsIDateTimeFormat.h" #include "nsIScriptableDateFormat.h" #include "nsCRT.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kLocaleServiceCID, NS_LOCALESERVICE_CID); static NS_DEFINE_CID(kDateTimeFormatCID, NS_DATETIMEFORMAT_CID); @@ -138,7 +139,7 @@ NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime( rv = aDateTimeFormat->FormatTime(aLocale, dateFormatSelector, timeFormatSelector, timetTime, mStringOut); if (NS_SUCCEEDED(rv)) { - *dateTimeString = mStringOut.ToNewUnicode(); + *dateTimeString = ToNewUnicode(mStringOut); } } else { @@ -153,7 +154,7 @@ NS_IMETHODIMP nsScriptableDateFormat::FormatDateTime( rv = aDateTimeFormat->FormatPRTime(aLocale, dateFormatSelector, timeFormatSelector, prtime, mStringOut); if (NS_SUCCEEDED(rv)) { - *dateTimeString = mStringOut.ToNewUnicode(); + *dateTimeString = ToNewUnicode(mStringOut); } } } diff --git a/mozilla/intl/locale/src/windows/nsIWin32LocaleImpl.cpp b/mozilla/intl/locale/src/windows/nsIWin32LocaleImpl.cpp index 6297bc79474..22d9bb46338 100644 --- a/mozilla/intl/locale/src/windows/nsIWin32LocaleImpl.cpp +++ b/mozilla/intl/locale/src/windows/nsIWin32LocaleImpl.cpp @@ -39,6 +39,7 @@ #include "nsISupports.h" #include "nscore.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsILocale.h" #include "nsIWin32LocaleImpl.h" #include "nsLocaleCID.h" @@ -431,7 +432,7 @@ nsIWin32LocaleImpl::GetPlatformLocale(const nsString* locale,LCID* winLCID) char region_code[3]; int i,j; - locale_string = locale->ToNewCString(); + locale_string = ToNewCString(*locale); if (locale_string!=NULL) { if (!ParseLocaleString(locale_string,language_code,country_code,region_code)) { diff --git a/mozilla/intl/locale/tests/LocaleSelfTest.cpp b/mozilla/intl/locale/tests/LocaleSelfTest.cpp index 62618977523..89b21d92a6d 100644 --- a/mozilla/intl/locale/tests/LocaleSelfTest.cpp +++ b/mozilla/intl/locale/tests/LocaleSelfTest.cpp @@ -56,6 +56,7 @@ #include "nsICollation.h" #include "nsDateTimeFormatCID.h" #include "nsIDateTimeFormat.h" +#include "nsReadableUtils.h" #ifdef XP_MAC #define LOCALE_DLL_NAME "NSLOCALE_DLL" @@ -419,7 +420,7 @@ static void DebugPrintCompResult(nsString string1, nsString string2, int result) printf(" %s\n", s); #else // Warning: casting to char* - char *cstr = string1.ToNewCString(); + char *cstr = ToNewCString(string1); if (cstr) { cout << cstr << ' '; @@ -436,7 +437,7 @@ static void DebugPrintCompResult(nsString string1, nsString string2, int result) cout << '<'; break; } - cstr = string2.ToNewCString(); + cstr = ToNewCString(string2); if (cstr) { cout << ' ' << cstr << '\n'; delete [] cstr; diff --git a/mozilla/intl/lwbrk/tests/TestLineBreak.cpp b/mozilla/intl/lwbrk/tests/TestLineBreak.cpp index 455d66ab42d..79bae789f72 100644 --- a/mozilla/intl/lwbrk/tests/TestLineBreak.cpp +++ b/mozilla/intl/lwbrk/tests/TestLineBreak.cpp @@ -45,6 +45,7 @@ #include "nsIWordBreaker.h" #include "nsIBreakState.h" #include "nsLWBrkCIID.h" +#include "nsReadableUtils.h" #define WORK_AROUND_SERVICE_MANAGER_ASSERT @@ -486,7 +487,7 @@ void SamplePrintWordWithBreak() } } cout << "Output From SamplePrintWordWithBreak() \n\n"; - cout << "[" << result.ToNewCString() << "]\n"; + cout << "[" << NS_LossyConvertUCS2toASCII(result).get() << "]\n"; } void SampleFindWordBreakFromPosition(PRUint32 fragN, PRUint32 offset) @@ -574,7 +575,7 @@ void SampleFindWordBreakFromPosition(PRUint32 fragN, PRUint32 offset) } cout << "Output From SamplePrintWordWithBreak() \n\n"; - cout << "[" << result.ToNewCString() << "]\n"; + cout << "[" << NS_LossyConvertUCS2toASCII(result).get() << "]\n"; } // Main diff --git a/mozilla/intl/strres/src/nsStringBundle.cpp b/mozilla/intl/strres/src/nsStringBundle.cpp index db61df9b1a8..c8675612015 100644 --- a/mozilla/intl/strres/src/nsStringBundle.cpp +++ b/mozilla/intl/strres/src/nsStringBundle.cpp @@ -40,6 +40,7 @@ #include "nsID.h" #include "nsFileSpec.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIPersistentProperties2.h" #include "nsIStringBundle.h" #include "nscore.h" @@ -300,7 +301,7 @@ nsStringBundle::GetStringFromID(PRInt32 aID, nsString& aResult) nsresult rv = mProps->GetStringProperty(name, aResult); #ifdef DEBUG_tao_ - char *s = aResult.ToNewCString(); + char *s = ToNewCString(aResult); printf("\n** GetStringFromID: aResult=%s, len=%d\n", s?s:"null", aResult.Length()); delete s; @@ -317,8 +318,8 @@ nsStringBundle::GetStringFromName(const nsAReadableString& aName, rv = mProps->GetStringProperty(nsAutoString(aName), aResult); #ifdef DEBUG_tao_ - char *s = aResult.ToNewCString(), - *ss = aName.ToNewCString(); + char *s = ToNewCString(aResult), + *ss = ToNewCString(aName); printf("\n** GetStringFromName: aName=%s, aResult=%s, len=%d\n", ss?ss:"null", s?s:"null", aResult.Length()); delete s; @@ -946,7 +947,7 @@ nsStringBundleService::CreateBundle(const char* aURLSpec, printf("\n++ nsStringBundleService::CreateBundle ++\n"); { nsAutoString aURLStr(aURLSpec); - char *s = aURLStr.ToNewCString(); + char *s = ToNewCString(aURLStr); printf("\n** nsStringBundleService::CreateBundle: %s\n", s?s:"null"); delete s; } @@ -1062,7 +1063,7 @@ nsStringBundleService::FormatStatusMessage(nsresult aStatus, pos = args.Length(); nsAutoString arg; args.Mid(arg, offset, pos); - argArray[i] = arg.ToNewUnicode(); + argArray[i] = ToNewUnicode(arg); if (argArray[i] == nsnull) { rv = NS_ERROR_OUT_OF_MEMORY; argCount = i - 1; // don't try to free uninitialized memory diff --git a/mozilla/intl/strres/tests/StringBundleTest.cpp b/mozilla/intl/strres/tests/StringBundleTest.cpp index a6897a529b9..a037c6a8515 100644 --- a/mozilla/intl/strres/tests/StringBundleTest.cpp +++ b/mozilla/intl/strres/tests/StringBundleTest.cpp @@ -39,6 +39,7 @@ #define NS_IMPL_IDS #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIPersistentProperties2.h" #include "nsIStringBundle.h" #include "nsIAcceptLang.h" @@ -178,7 +179,7 @@ main(int argc, char *argv[]) return 1; } v = ptrv; - value = v.ToNewCString(); + value = ToNewCString(v); cout << "123=\"" << value << "\"" << endl; // file @@ -191,7 +192,7 @@ main(int argc, char *argv[]) return 1; } v = ptrv; - value = v.ToNewCString(); + value = ToNewCString(v); cout << "file=\"" << value << "\"" << endl; nsIBidirectionalEnumerator* propEnum = nsnull; @@ -235,8 +236,8 @@ main(int argc, char *argv[]) nsAutoString keyAdjustedLengthBuff(pKey); nsAutoString valAdjustedLengthBuff(pVal); - char* keyCStr = keyAdjustedLengthBuff.ToNewCString(); - char* valCStr = valAdjustedLengthBuff.ToNewCString(); + char* keyCStr = ToNewCString(keyAdjustedLengthBuff); + char* valCStr = ToNewCString(valAdjustedLengthBuff); if (keyCStr && valCStr) cout << keyCStr << "\t" << valCStr << endl; delete[] keyCStr; diff --git a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp index 7546366a533..3180139f66a 100644 --- a/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp +++ b/mozilla/intl/uconv/src/nsCharsetConverterManager.cpp @@ -41,6 +41,7 @@ #include "nsCOMPtr.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsICharsetAlias.h" #include "nsIRegistry.h" #include "nsIServiceManager.h" @@ -246,7 +247,7 @@ nsresult nsCharsetConverterManager::RegisterConverterTitles( nsAutoString str; str.AssignWithConversion(aRegistryPath); str.AppendWithConversion("defaultFile"); - char * p = str.ToNewCString(); + char * p = ToNewCString(str); res = aRegistry->AddSubtree(nsIRegistry::Common, p, &key); nsMemory::Free(p); if (NS_FAILED(res)) return res; @@ -266,7 +267,7 @@ nsresult nsCharsetConverterManager::RegisterConverterData( nsAutoString str; str.AssignWithConversion(aRegistryPath); str.AppendWithConversion("defaultFile"); - char * p = str.ToNewCString(); + char * p = ToNewCString(str); res = aRegistry->AddSubtree(nsIRegistry::Common, p, &key); nsMemory::Free(p); if (NS_FAILED(res)) return res; diff --git a/mozilla/intl/uconv/src/nsMacCharset.cpp b/mozilla/intl/uconv/src/nsMacCharset.cpp index 9dbf26b48ca..21c2c858df4 100644 --- a/mozilla/intl/uconv/src/nsMacCharset.cpp +++ b/mozilla/intl/uconv/src/nsMacCharset.cpp @@ -45,6 +45,7 @@ #include "nsIComponentManager.h" #include "nsIMacLocale.h" #include "nsLocaleCID.h" +#include "nsReadableUtils.h" static nsURLProperties *gInfo = nsnull; static PRInt32 gCnt; @@ -129,12 +130,12 @@ nsMacCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar* nsresult rv; pMacLocale = do_CreateInstance(NS_MACLOCALE_CONTRACTID, &rv); - if (NS_FAILED(rv)) { *_retValue = charset.ToNewUnicode(); return rv; } + if (NS_FAILED(rv)) { *_retValue = ToNewUnicode(charset); return rv; } rv = pMacLocale->GetPlatformLocale(&localeAsString,&script,&language,®ion); - if (NS_FAILED(rv)) { *_retValue = charset.ToNewUnicode(); return rv; } + if (NS_FAILED(rv)) { *_retValue = ToNewUnicode(charset); return rv; } - if (!gInfo) { *_retValue = charset.ToNewUnicode(); return NS_ERROR_OUT_OF_MEMORY; } + if (!gInfo) { *_retValue = ToNewUnicode(charset); return NS_ERROR_OUT_OF_MEMORY; } nsAutoString locale_key; locale_key.AssignWithConversion("region."); locale_key.AppendInt(region,10); @@ -146,7 +147,7 @@ nsMacCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar* rv = gInfo->Get(locale_key,charset); if (NS_FAILED(rv)) { charset.AssignWithConversion("x-mac-roman");} } - *_retValue = charset.ToNewUnicode(); + *_retValue = ToNewUnicode(charset); return rv; } diff --git a/mozilla/intl/uconv/src/nsScriptableUConv.cpp b/mozilla/intl/uconv/src/nsScriptableUConv.cpp index 091b0948952..b3387b2ff8a 100644 --- a/mozilla/intl/uconv/src/nsScriptableUConv.cpp +++ b/mozilla/intl/uconv/src/nsScriptableUConv.cpp @@ -40,6 +40,7 @@ #include "pratom.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsICharsetConverterManager.h" #include "nsICharsetConverterManager2.h" @@ -130,7 +131,7 @@ nsScriptableUnicodeConverter::ConvertToUnicode(const char *aSrc, PRUnichar **_re NS_IMETHODIMP nsScriptableUnicodeConverter::GetCharset(PRUnichar * *aCharset) { - *aCharset = mCharset.ToNewUnicode() ; + *aCharset = ToNewUnicode(mCharset); if (!*aCharset) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/intl/uconv/src/nsUNIXCharset.cpp b/mozilla/intl/uconv/src/nsUNIXCharset.cpp index f1bb751e47d..c59c447bf1f 100644 --- a/mozilla/intl/uconv/src/nsUNIXCharset.cpp +++ b/mozilla/intl/uconv/src/nsUNIXCharset.cpp @@ -41,6 +41,7 @@ #include "pratom.h" #include "nsURLProperties.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsLocaleCID.h" #include "nsUConvDll.h" #include "nsIComponentManager.h" @@ -167,7 +168,7 @@ nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar if (mLocale.Equals(localeNameAsString) || // support the 4.x behavior (mLocale.EqualsIgnoreCase("en_US") && localeNameAsString.EqualsIgnoreCase("C"))) { - *_retValue = mCharset.ToNewUnicode(); + *_retValue = ToNewUnicode(mCharset); return NS_OK; } @@ -181,7 +182,7 @@ nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar // NS_ASSERTION(0, "GetDefaultCharsetForLocale: need to add multi locale support"); // until we add multi locale support: use the the charset of the user's locale - *_retValue = mCharset.ToNewUnicode(); + *_retValue = ToNewUnicode(mCharset); return NS_ERROR_USING_FALLBACK_LOCALE; #endif @@ -193,13 +194,13 @@ nsUNIXCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar nsString charset; nsresult res = ConvertLocaleToCharsetUsingDeprecatedConfig(localeStr, charset); if (NS_SUCCEEDED(res)) { - *_retValue = charset.ToNewUnicode(); + *_retValue = ToNewUnicode(charset); return res; // succeeded } NS_ASSERTION(0, "unable to convert locale to charset using deprecated config"); charset.Assign(NS_LITERAL_STRING("ISO-8859-1")); - *_retValue=charset.ToNewUnicode(); + *_retValue = ToNewUnicode(charset); return NS_ERROR_USING_FALLBACK_LOCALE; } diff --git a/mozilla/intl/uconv/src/nsWinCharset.cpp b/mozilla/intl/uconv/src/nsWinCharset.cpp index 12bdaa99a44..d9d3ae02df5 100644 --- a/mozilla/intl/uconv/src/nsWinCharset.cpp +++ b/mozilla/intl/uconv/src/nsWinCharset.cpp @@ -43,6 +43,7 @@ #include "nsUConvDll.h" #include "nsIWin32Locale.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsLocaleCID.h" #include "nsIComponentManager.h" @@ -128,20 +129,20 @@ nsWinCharset::GetDefaultCharsetForLocale(const PRUnichar* localeName, PRUnichar* nsresult result; winLocale = do_CreateInstance(NS_WIN32LOCALE_CONTRACTID, &result); result = winLocale->GetPlatformLocale(&localeAsNSString,&localeAsLCID); - if (NS_FAILED(result)) { *_retValue = charset.ToNewUnicode(); return result; } + if (NS_FAILED(result)) { *_retValue = ToNewUnicode(charset); return result; } - if (GetLocaleInfo(localeAsLCID,LOCALE_IDEFAULTANSICODEPAGE,acp_name,sizeof(acp_name))==0) { *_retValue = charset.ToNewUnicode(); return NS_ERROR_FAILURE; } + if (GetLocaleInfo(localeAsLCID,LOCALE_IDEFAULTANSICODEPAGE,acp_name,sizeof(acp_name))==0) { *_retValue = ToNewUnicode(charset); return NS_ERROR_FAILURE; } // // load property file and convert from LCID->charset // - if (!gInfo) { *_retValue = charset.ToNewUnicode(); return NS_ERROR_OUT_OF_MEMORY; } + if (!gInfo) { *_retValue = ToNewUnicode(charset); return NS_ERROR_OUT_OF_MEMORY; } nsAutoString acp_key; acp_key.AssignWithConversion("acp."); acp_key.AppendWithConversion(acp_name); result = gInfo->Get(acp_key,charset); - *_retValue = charset.ToNewUnicode(); + *_retValue = ToNewUnicode(charset); return result; } diff --git a/mozilla/intl/uconv/tests/nsTestUConv.cpp b/mozilla/intl/uconv/tests/nsTestUConv.cpp index 1b4c2485886..a3cb285617c 100644 --- a/mozilla/intl/uconv/tests/nsTestUConv.cpp +++ b/mozilla/intl/uconv/tests/nsTestUConv.cpp @@ -48,6 +48,7 @@ #include "nsIPlatformCharset.h" #include "nsICharRepresentable.h" #include "prmem.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); @@ -1102,13 +1103,13 @@ nsresult testPlatformCharset() nsString value; res = cinfo->GetCharset(kPlatformCharsetSel_PlainTextInClipboard , value); - printf("Clipboard plain text encoding = %s\n",value.ToNewCString()); + printf("Clipboard plain text encoding = %s\n", NS_LossyConvertUCS2toASCII(value).get()); res = cinfo->GetCharset(kPlatformCharsetSel_FileName , value); - printf("File Name encoding = %s\n",value.ToNewCString()); + printf("File Name encoding = %s\n", NS_LossyConvertUCS2toASCII(value).get()); res = cinfo->GetCharset(kPlatformCharsetSel_Menu , value); - printf("Menu encoding = %s\n",value.ToNewCString()); + printf("Menu encoding = %s\n", NS_LossyConvertUCS2toASCII(value).get()); cinfo->Release(); return res; diff --git a/mozilla/intl/uconv/tests/plattest.cpp b/mozilla/intl/uconv/tests/plattest.cpp index d0eca521122..3bef6cc612e 100644 --- a/mozilla/intl/uconv/tests/plattest.cpp +++ b/mozilla/intl/uconv/tests/plattest.cpp @@ -38,6 +38,7 @@ #include "nsIPlatformCharset.h" #include "nsILocaleService.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsLocaleCID.h" #include "nsIComponentManager.h" #include @@ -71,14 +72,14 @@ main(int argc, const char** argv) charsetAsNSString = charset; categoryAsNSString = category_value; - printf("DefaultCharset for %s is %s\n",categoryAsNSString.ToNewCString(),charsetAsNSString.ToNewCString()); + printf("DefaultCharset for %s is %s\n", NS_LossyConvertUCS2toASCII(categoryAsNSString).get(), NS_LossyConvertUCS2toASCII(charsetAsNSString).get()); categoryAsNSString.AssignWithConversion("en-US"); rv = platform_charset->GetDefaultCharsetForLocale(categoryAsNSString.get(),&charset); if (NS_FAILED(rv)) return -1; charsetAsNSString = charset; - printf("DefaultCharset for %s is %s\n",categoryAsNSString.ToNewCString(),charsetAsNSString.ToNewCString()); + printf("DefaultCharset for %s is %s\n", NS_LossyConvertUCS2toASCII(categoryAsNSString).get(), NS_LossyConvertUCS2toASCII(charsetAsNSString).get()); return 0; } diff --git a/mozilla/intl/unicharutil/src/nsEntityConverter.cpp b/mozilla/intl/unicharutil/src/nsEntityConverter.cpp index da9a36b57a5..2e18c5f19cf 100644 --- a/mozilla/intl/unicharutil/src/nsEntityConverter.cpp +++ b/mozilla/intl/unicharutil/src/nsEntityConverter.cpp @@ -40,6 +40,7 @@ #include "nsIProperties.h" #include "nsIServiceManager.h" #include "nsIComponentManager.h" +#include "nsReadableUtils.h" #include "nsIURL.h" #include "nsNetUtil.h" @@ -224,7 +225,7 @@ nsEntityConverter::ConvertToEntity(PRUnichar character, PRUint32 entityVersion, key.AppendInt(character,10); nsresult rv = entityProperties->GetStringProperty(key, value); if (NS_SUCCEEDED(rv)) { - *_retval = value.ToNewCString(); + *_retval = ToNewCString(value); if(nsnull == *_retval) return NS_ERROR_OUT_OF_MEMORY; else @@ -275,7 +276,7 @@ nsEntityConverter::ConvertToEntities(const PRUnichar *inString, PRUint32 entityV } } - *_retval = outString.ToNewUnicode(); + *_retval = ToNewUnicode(outString); if (NULL == *_retval) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp b/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp index c0f706acf9b..2e179ab9aa4 100644 --- a/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp +++ b/mozilla/intl/unicharutil/tests/UnicharSelfTest.cpp @@ -49,6 +49,7 @@ #include "nsIURL.h" #include "nsNetUtil.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" NS_DEFINE_CID(kUnicharUtilCID, NS_UNICHARUTIL_CID); NS_DEFINE_IID(kCaseConversionIID, NS_ICASECONVERSION_IID); @@ -467,7 +468,7 @@ static void TestSaveAsCharset() if (NULL == outString) {cout << "\tFailed!! output null\n";} else {cout << outString << "\n"; nsMemory::Free(outString);} if (NS_ERROR_UENC_NOMAPPING == res) { - outString = inString.ToNewUTF8String(); + outString = ToNewUTF8String(inString); if (NULL == outString) {cout << "\tFailed!! output null\n";} else {cout << "Fall back to UTF-8: " << outString << "\n"; nsMemory::Free(outString);} } diff --git a/mozilla/js/jsd/jsd_xpc.cpp b/mozilla/js/jsd/jsd_xpc.cpp index a97e509b94c..139aa863a42 100644 --- a/mozilla/js/jsd/jsd_xpc.cpp +++ b/mozilla/js/jsd/jsd_xpc.cpp @@ -47,6 +47,7 @@ #include "nsIEventQueueService.h" #include "nsMemory.h" #include "jsdebug.h" +#include "nsReadableUtils.h" /* XXX this stuff is used by NestEventLoop, a temporary hack to be refactored * later */ @@ -451,7 +452,7 @@ jsdObject::GetJSDObject(JSDObject **_rval) NS_IMETHODIMP jsdObject::GetCreatorURL(char **_rval) { - *_rval = nsCString(JSD_GetObjectNewURL(mCx, mObject)).ToNewCString(); + *_rval = ToNewCString(nsDependentCString(JSD_GetObjectNewURL(mCx, mObject))); return NS_OK; } @@ -465,7 +466,7 @@ jsdObject::GetCreatorLine(PRUint32 *_rval) NS_IMETHODIMP jsdObject::GetConstructorURL(char **_rval) { - *_rval = nsCString(JSD_GetObjectConstructorURL(mCx, mObject)).ToNewCString(); + *_rval = ToNewCString(nsDependentCString(JSD_GetObjectConstructorURL(mCx, mObject))); return NS_OK; } @@ -680,14 +681,14 @@ jsdScript::GetIsValid(PRBool *_rval) NS_IMETHODIMP jsdScript::GetFileName(char **_rval) { - *_rval = mFileName->ToNewCString(); + *_rval = ToNewCString(*mFileName); return NS_OK; } NS_IMETHODIMP jsdScript::GetFunctionName(char **_rval) { - *_rval = mFunctionName->ToNewCString(); + *_rval = ToNewCString(*mFunctionName); return NS_OK; } @@ -1035,7 +1036,7 @@ NS_IMETHODIMP jsdValue::GetJsClassName(char **_rval) { ASSERT_VALID_VALUE; - *_rval = nsCString(JSD_GetValueClassName(mCx, mValue)).ToNewCString(); + *_rval = ToNewCString(nsDependentCString(JSD_GetValueClassName(mCx, mValue))); return NS_OK; } @@ -1052,7 +1053,7 @@ NS_IMETHODIMP jsdValue::GetJsFunctionName(char **_rval) { ASSERT_VALID_VALUE; - *_rval = nsCString(JSD_GetValueFunctionName(mCx, mValue)).ToNewCString(); + *_rval = ToNewCString(nsDependentCString(JSD_GetValueFunctionName(mCx, mValue))); return NS_OK; } @@ -1099,7 +1100,7 @@ jsdValue::GetStringValue(char **_rval) { ASSERT_VALID_VALUE; JSString *jstr_val = JSD_GetValueString(mCx, mValue); - *_rval = nsCString(JS_GetStringBytes(jstr_val)).ToNewCString(); + *_rval = ToNewCString(nsDependentCString(JS_GetStringBytes(jstr_val))); return NS_OK; } diff --git a/mozilla/js/src/xpconnect/src/nsScriptError.cpp b/mozilla/js/src/xpconnect/src/nsScriptError.cpp index 661ba45e487..f8b91c1f58f 100644 --- a/mozilla/js/src/xpconnect/src/nsScriptError.cpp +++ b/mozilla/js/src/xpconnect/src/nsScriptError.cpp @@ -43,6 +43,7 @@ */ #include "xpcprivate.h" +#include "nsReadableUtils.h" NS_IMPL_THREADSAFE_ISUPPORTS2(nsScriptError, nsIConsoleMessage, nsIScriptError); @@ -63,20 +64,20 @@ nsScriptError::~nsScriptError() {}; // nsIConsoleMessage methods NS_IMETHODIMP nsScriptError::GetMessage(PRUnichar **result) { - *result = mMessage.ToNewUnicode(); + *result = ToNewUnicode(mMessage); return NS_OK; } // nsIScriptError methods NS_IMETHODIMP nsScriptError::GetSourceName(PRUnichar **result) { - *result = mSourceName.ToNewUnicode(); + *result = ToNewUnicode(mSourceName); return NS_OK; } NS_IMETHODIMP nsScriptError::GetSourceLine(PRUnichar **result) { - *result = mSourceLine.ToNewUnicode(); + *result = ToNewUnicode(mSourceLine); return NS_OK; } @@ -100,7 +101,7 @@ nsScriptError::GetFlags(PRUint32 *result) { NS_IMETHODIMP nsScriptError::GetCategory(char **result) { - *result = mCategory.ToNewCString(); + *result = ToNewCString(mCategory); return NS_OK; } @@ -145,11 +146,11 @@ nsScriptError::ToString(char **_retval) char* tempSourceLine = nsnull; if(!mMessage.IsEmpty()) - tempMessage = mMessage.ToNewCString(); + tempMessage = ToNewCString(mMessage); if(!mSourceName.IsEmpty()) - tempSourceName = mSourceName.ToNewCString(); + tempSourceName = ToNewCString(mSourceName); if(!mSourceLine.IsEmpty()) - tempSourceLine = mSourceLine.ToNewCString(); + tempSourceLine = ToNewCString(mSourceLine); if(nsnull != tempSourceName && nsnull != tempSourceLine) temp = JS_smprintf(format0, diff --git a/mozilla/js/src/xpconnect/src/xpcconvert.cpp b/mozilla/js/src/xpconnect/src/xpcconvert.cpp index d3917e44e75..4d789dc296d 100644 --- a/mozilla/js/src/xpconnect/src/xpcconvert.cpp +++ b/mozilla/js/src/xpconnect/src/xpcconvert.cpp @@ -38,6 +38,7 @@ /* Data conversion between native and JavaScript types. */ #include "xpcprivate.h" +#include "nsReadableUtils.h" //#define STRICT_CHECK_OF_UNICODE #ifdef STRICT_CHECK_OF_UNICODE @@ -1119,24 +1120,13 @@ XPCConvert::JSErrorToXPCException(XPCCallContext& ccx, bestMessage = NS_LITERAL_STRING("JavaScript Error"); } - const PRUnichar *newMessage = bestMessage.ToNewUnicode(); - const PRUnichar *newSourceName = nsnull; - if(report->filename) - { - nsAutoString newSourceNameStr; - newSourceNameStr.AssignWithConversion(report->filename); - newSourceName = newSourceNameStr.ToNewUnicode(); - } - data = new nsScriptError(); NS_ADDREF(data); - data->Init(newMessage, newSourceName, + data->Init(bestMessage.get(), + NS_ConvertASCIItoUCS2(report->filename).get(), (const PRUnichar *)report->uclinebuf, report->lineno, report->uctokenptr - report->uclinebuf, report->flags, "XPConnect JavaScript"); - nsMemory::Free((void *)newMessage); - if(nsnull != newSourceName) - nsMemory::Free((void *) newSourceName); } else data = nsnull; diff --git a/mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp b/mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp index f44bc9abec7..01bf75922f2 100644 --- a/mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp +++ b/mozilla/js/src/xpconnect/src/xpcwrappedjsclass.cpp @@ -1133,13 +1133,12 @@ pre_call_clean_up: nsAutoString newMessage; newMessage.AssignWithConversion(exn_string); nsMemory::Free((void *) exn_string); - PRUnichar* newMessageUni; - newMessageUni = newMessage.ToNewUnicode(); // try to get filename, lineno from the first // stack frame location. PRUnichar* sourceNameUni = nsnull; PRInt32 lineNumber = 0; + nsXPIDLCString sourceName; nsCOMPtr location; xpc_exception-> @@ -1150,24 +1149,16 @@ pre_call_clean_up: location->GetLineNumber(&lineNumber); // get a filename. - char *csourceName; - rv = location->GetFilename(&csourceName); - nsAutoString newSourceName; - newSourceName. - AssignWithConversion(csourceName); - nsMemory::Free((void *)csourceName); - sourceNameUni = newSourceName.ToNewUnicode(); + rv = location->GetFilename(getter_Copies(sourceName)); } - rv = scriptError->Init(newMessageUni, - sourceNameUni, nsnull, + rv = scriptError->Init(newMessage.get(), + NS_ConvertASCIItoUCS2(sourceName).get(), + nsnull, lineNumber, 0, 0, "XPConnect JavaScript"); if(NS_FAILED(rv)) scriptError = nsnull; - nsMemory::Free((void *)newMessageUni); - if(nsnull != sourceNameUni) - nsMemory::Free((void *)sourceNameUni); } } } diff --git a/mozilla/layout/base/nsDocumentViewer.cpp b/mozilla/layout/base/nsDocumentViewer.cpp index bf0028d47cf..3aebe4a4702 100644 --- a/mozilla/layout/base/nsDocumentViewer.cpp +++ b/mozilla/layout/base/nsDocumentViewer.cpp @@ -43,6 +43,7 @@ #include "nsCOMPtr.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsISupports.h" #include "nsIContent.h" #include "nsIContentViewerContainer.h" @@ -2110,23 +2111,17 @@ DocumentViewerImpl::GetWebShellTitleAndURL(nsIWebShell * aWebShell, presShell->GetDocument(getter_AddRefs(doc)); if (doc) { const nsString* docTitle = doc->GetDocumentTitle(); - if (docTitle != nsnull) { - nsAutoString title(docTitle->get()); - if (title.Length() > 0) { - *aTitle = title.ToNewUnicode(); - } + if (docTitle && !docTitle->IsEmpty()) { + *aTitle = ToNewUnicode(*docTitle); } nsCOMPtr url; doc->GetDocumentURL(getter_AddRefs(url)); if (url) { - char * urlCStr; - url->GetSpec(&urlCStr); - if (urlCStr) { - nsAutoString urlStr; - urlStr.AssignWithConversion(urlCStr); - *aURLStr = urlStr.ToNewUnicode(); - nsMemory::Free(urlCStr); + nsXPIDLCString urlCStr; + url->GetSpec(getter_Copies(urlCStr)); + if (urlCStr.get()) { + *aURLStr = ToNewUnicode(urlCStr); } } @@ -3297,8 +3292,7 @@ DocumentViewerImpl::SetupToPrintContent(nsIWebShell* aParent, docTitleStr = docURLStr; docURLStr = nsnull; } else { - nsAutoString docStr(NS_LITERAL_STRING("Document")); - docTitleStr = docStr.ToNewUnicode(); + docTitleStr = ToNewUnicode(NS_LITERAL_STRING("Document")); } } // BeginDocument may pass back a FAILURE code @@ -3483,8 +3477,7 @@ DocumentViewerImpl::DoPrint(PrintObject * aPO, PRBool aDoSyncPrinting, PRBool& a GetWebShellTitleAndURL(webShell, &docTitleStr, &docURLStr); if (!docTitleStr) { - nsAutoString emptyTitle(NS_LITERAL_STRING("")); - docTitleStr = emptyTitle.ToNewUnicode(); + docTitleStr = ToNewUnicode(NS_LITERAL_STRING("")); } if (docTitleStr) { @@ -4823,7 +4816,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetDefaultCharacterSet(PRUnichar** aDefaultCha else mDefaultCharacterSet.Assign(gDefCharset); } - *aDefaultCharacterSet = mDefaultCharacterSet.ToNewUnicode(); + *aDefaultCharacterSet = ToNewUnicode(mDefaultCharacterSet); return NS_OK; } @@ -4853,7 +4846,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetForceCharacterSet(PRUnichar** aForceCharact *aForceCharacterSet = nsnull; } else { - *aForceCharacterSet = mForceCharacterSet.ToNewUnicode(); + *aForceCharacterSet = ToNewUnicode(mForceCharacterSet); } return NS_OK; } @@ -4881,7 +4874,7 @@ NS_IMETHODIMP DocumentViewerImpl::GetHintCharacterSet(PRUnichar * *aHintCharacte if(kCharsetUninitialized == mHintCharsetSource) { *aHintCharacterSet = nsnull; } else { - *aHintCharacterSet = mHintCharset.ToNewUnicode(); + *aHintCharacterSet = ToNewUnicode(mHintCharset); // this can't possibly be right. we can't set a value just because somebody got a related value! //mHintCharsetSource = kCharsetUninitialized; } diff --git a/mozilla/layout/base/nsPresShell.cpp b/mozilla/layout/base/nsPresShell.cpp index 82de6eab00e..1202dbf2aa3 100644 --- a/mozilla/layout/base/nsPresShell.cpp +++ b/mozilla/layout/base/nsPresShell.cpp @@ -79,6 +79,7 @@ #include "nsIDOMElement.h" #include "nsHTMLAtoms.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsWeakReference.h" #include "nsIPageSequenceFrame.h" #include "nsICaret.h" @@ -7328,7 +7329,7 @@ static void RecurseIndiTotals(nsIPresContext* aPresContext, IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(aHT, key); if (counter) { counter->mHasBeenOutput = PR_TRUE; - char * name = counter->mName.ToNewCString(); + char * name = ToNewCString(counter->mName); for (PRInt32 i=0;imCount); for (PRInt32 inx=0;inx<5;inx++) { @@ -7354,7 +7355,7 @@ PRIntn ReflowCountMgr::DoSingleIndi(PLHashEntry *he, PRIntn i, void *arg) char *str = (char *)he->key; IndiReflowCounter * counter = (IndiReflowCounter *)he->value; if (counter && !counter->mHasBeenOutput) { - char * name = counter->mName.ToNewCString(); + char * name = ToNewCString(counter->mName); printf("%s - %p [%d][", name, counter->mFrame, counter->mCount); for (PRInt32 inx=0;inx<5;inx++) { if (inx != 0) printf(","); diff --git a/mozilla/layout/forms/nsComboboxControlFrame.cpp b/mozilla/layout/forms/nsComboboxControlFrame.cpp index 60999c868bd..c115edbc19a 100644 --- a/mozilla/layout/forms/nsComboboxControlFrame.cpp +++ b/mozilla/layout/forms/nsComboboxControlFrame.cpp @@ -36,6 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsComboboxControlFrame.h" #include "nsIDOMEventReceiver.h" #include "nsIFrameManager.h" @@ -921,7 +922,7 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext, maxWidth = width; } //maxWidth = PR_MAX(width, maxWidth); - //printf("[%d] - %d %s \n", i, width, text.ToNewCString()); + //printf("[%d] - %d %s \n", i, width, NS_LossyConvertUCS2toASCII(text).get()); } } } @@ -930,7 +931,7 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext, if (maxWidth == 0) { maxWidth = 11 * 15; } - char * str = maxStr.ToNewCString(); + char * str = ToNewCString(maxStr); printf("id: %d maxWidth %d [%s]\n", mReflowId, maxWidth, str); delete [] str; @@ -1995,7 +1996,7 @@ nsComboboxControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUp // Fix for Bug 42661 (remove comment later) #ifdef DO_REFLOW_DEBUG - char * str = mTextStr.ToNewCString(); + char * str = ToNewCString(mTextStr); REFLOW_DEBUG_MSG2("UpdateSelection %s\n", str); delete [] str; #endif @@ -2053,7 +2054,7 @@ nsComboboxControlFrame::SelectionChanged() shouldSetValue = PR_TRUE; } else { shouldSetValue = value != mTextStr; - REFLOW_DEBUG_MSG3("**** CBX::SelectionChanged Old[%s] New[%s]\n", value.ToNewCString(), mTextStr.ToNewCString()); + REFLOW_DEBUG_MSG3("**** CBX::SelectionChanged Old[%s] New[%s]\n", NS_LossyConvertUCS2toASCII(value).get(), NS_LossyConvertUCS2toASCII(mTextStr).get()); } if (shouldSetValue) { if (mTextStr.Length() == 0) { diff --git a/mozilla/layout/forms/nsIsIndexFrame.cpp b/mozilla/layout/forms/nsIsIndexFrame.cpp index eaa7b01953c..0142521eb83 100644 --- a/mozilla/layout/forms/nsIsIndexFrame.cpp +++ b/mozilla/layout/forms/nsIsIndexFrame.cpp @@ -67,6 +67,7 @@ #include "nsILinkHandler.h" #include "nsIHTMLDocument.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsICharsetConverterManager.h" #include "nsEscape.h" @@ -569,7 +570,7 @@ nsIsIndexFrame::URLEncode(const nsString& aString, nsIUnicodeEncoder* encoder, n inBuf = UnicodeToNewBytes(aString.get(), aString.Length(), encoder); if(nsnull == inBuf) - inBuf = aString.ToNewCString(); + inBuf = ToNewCString(aString); // convert to CRLF breaks char* convertedBuf = nsLinebreakConverter::ConvertLineBreaks(inBuf, diff --git a/mozilla/layout/forms/nsListControlFrame.cpp b/mozilla/layout/forms/nsListControlFrame.cpp index a0dd34a8402..440292d4138 100644 --- a/mozilla/layout/forms/nsListControlFrame.cpp +++ b/mozilla/layout/forms/nsListControlFrame.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nscore.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsListControlFrame.h" #include "nsFormControlFrame.h" // for COMPARE macro #include "nsFormControlHelper.h" @@ -708,7 +709,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, } else { text = "No Value"; } - printf("[%d] - %s\n", i, text.ToNewCString()); + printf("[%d] - %s\n", i, NS_LossyConvertUCS2toASCII(text).get()); } } } diff --git a/mozilla/layout/generic/nsImageMap.cpp b/mozilla/layout/generic/nsImageMap.cpp index 077dec997e0..e48e4644603 100644 --- a/mozilla/layout/generic/nsImageMap.cpp +++ b/mozilla/layout/generic/nsImageMap.cpp @@ -36,6 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsImageMap.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsVoidArray.h" #include "nsIRenderingContext.h" #include "nsIPresContext.h" @@ -331,7 +332,7 @@ static nscoord* lo_parse_coord_list(char *str, PRInt32* value_cnt) void Area::ParseCoords(const nsString& aSpec) { - char* cp = aSpec.ToNewCString(); + char* cp = ToNewCString(aSpec); if (cp) { mCoords = lo_parse_coord_list(cp, &mNumCoords); nsCRT::free(cp); diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 0212f7fb832..ef43d59712c 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -2099,8 +2099,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetAttributes(PRUint16& n, } } */ - mAttrNames[mNumAttrs] = name.ToNewUTF8String(); - mAttrVals[mNumAttrs] = value.ToNewUTF8String(); + mAttrNames[mNumAttrs] = ToNewUTF8String(name); + mAttrVals[mNumAttrs] = ToNewUTF8String(value); mNumAttrs++; } } @@ -2473,7 +2473,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagText(const char* *result) if (NS_FAILED(rv)) return rv; - mTagText = elementHTML.ToNewUTF8String(); + mTagText = ToNewUTF8String(elementHTML); if (!mTagText) return NS_ERROR_OUT_OF_MEMORY; } @@ -2601,8 +2601,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetParameters(PRUint16& n, const char*const */ name.CompressWhitespace(); val.CompressWhitespace(); - mParamNames[mNumParams] = name.ToNewUTF8String(); - mParamVals[mNumParams] = val.ToNewUTF8String(); + mParamNames[mNumParams] = ToNewUTF8String(name); + mParamVals[mNumParams] = ToNewUTF8String(val); mNumParams++; } } diff --git a/mozilla/layout/generic/nsPageFrame.cpp b/mozilla/layout/generic/nsPageFrame.cpp index b72f958c033..e57a7a8ef9f 100644 --- a/mozilla/layout/generic/nsPageFrame.cpp +++ b/mozilla/layout/generic/nsPageFrame.cpp @@ -47,6 +47,7 @@ #include "nsIStyleSet.h" #include "nsIPresShell.h" #include "nsIDeviceContext.h" +#include "nsReadableUtils.h" // for page number localization formatting #include "nsTextFormatter.h" @@ -273,9 +274,7 @@ nsPageFrame::IsPercentageBase(PRBool& aBase) const static PRUnichar * GetUStr(const char * aCStr) { - nsAutoString str; - str.AssignWithConversion(aCStr); - return str.ToNewUnicode(); + return ToNewUnicode(nsDependentCString(aCStr)); } // replace the & with the value, but if the value is empty @@ -309,10 +308,7 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr) if (mDateTimeStr != nsnull) { aNewStr.ReplaceSubstring(kDate, mDateTimeStr); } else { - nsAutoString empty; - PRUnichar * uEmpty = empty.ToNewUnicode(); - aNewStr.ReplaceSubstring(kDate, uEmpty); - nsMemory::Free(uEmpty); + aNewStr.ReplaceSubstring(kDate, NS_LITERAL_STRING("").get()); } nsMemory::Free(kDate); return; @@ -514,7 +510,7 @@ nsPageFrame::DrawHeaderFooter(nsIRenderingContext& aRenderingContext, aRenderingContext.PopState(clipEmpty); #ifdef DEBUG_PRINTING PRINT_DEBUG_MSG2("Page: %p", this); - char * s = str.ToNewCString(); + char * s = ToNewCString(str); if (s) { PRINT_DEBUG_MSG2(" [%s]", s); nsMemory::Free(s); diff --git a/mozilla/layout/generic/nsSelection.cpp b/mozilla/layout/generic/nsSelection.cpp index 18c7c9b06d8..b16e5b49cdd 100644 --- a/mozilla/layout/generic/nsSelection.cpp +++ b/mozilla/layout/generic/nsSelection.cpp @@ -44,6 +44,8 @@ #include "nsWeakReference.h" #include "nsIFactory.h" #include "nsIEnumerator.h" +#include "nsString.h" +#include "nsReadableUtils.h" #include "nsIDOMRange.h" #include "nsIFrameSelection.h" #include "nsISelection.h" @@ -1762,7 +1764,7 @@ nsTypedSelection::ToStringWithFormat(const char * aFormatType, PRUint32 aFlags, nsAutoString tmp; rv = encoder->EncodeToString(tmp); - *aReturn = tmp.ToNewUnicode();//get the unicode pointer from it. this is temporary + *aReturn = ToNewUnicode(tmp);//get the unicode pointer from it. this is temporary return rv; } @@ -5814,7 +5816,7 @@ nsTypedSelection::Collapse(nsIDOMNode* aParentNode, PRInt32 aOffset) { nsAutoString tagString; tag->ToString(tagString); - char * tagCString = tagString.ToNewCString(); + char * tagCString = ToNewCString(tagString); printf ("Sel. Collapse to %p %s %d\n", content, tagCString, aOffset); delete [] tagCString; } @@ -6638,7 +6640,7 @@ nsTypedSelection::Extend(nsIDOMNode* aParentNode, PRInt32 aOffset) { nsAutoString tagString; tag->ToString(tagString); - char * tagCString = tagString.ToNewCString(); + char * tagCString = ToNewCString(tagString); printf ("Sel. Extend to %p %s %d\n", content, tagCString, aOffset); delete [] tagCString; } @@ -6736,7 +6738,8 @@ nsTypedSelection::ContainsNode(nsIDOMNode* aNode, PRBool aRecursive, PRBool* aYe nsAutoString name, value; aNode->GetNodeName(name); aNode->GetNodeValue(value); - printf("%s [%s]: %d, %d\n", name.ToNewCString(), value.ToNewCString(), + printf("%s [%s]: %d, %d\n", NS_LossyConvertUCS2toASCII(name).get(), + NS_LossyConvertUCS2toASCII(value).get(), nodeStartsBeforeRange, nodeEndsAfterRange); #endif PRUint16 nodeType; diff --git a/mozilla/layout/generic/nsSimplePageSequence.cpp b/mozilla/layout/generic/nsSimplePageSequence.cpp index c955aae7d5a..2c18a3ec57a 100644 --- a/mozilla/layout/generic/nsSimplePageSequence.cpp +++ b/mozilla/layout/generic/nsSimplePageSequence.cpp @@ -35,6 +35,7 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsSimplePageSequence.h" #include "nsIPresContext.h" #include "nsIReflowCommand.h" @@ -465,7 +466,7 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, time_t ltime; time( <ime ); if (NS_SUCCEEDED(dateTime->FormatTime(locale, kDateFormatShort, kTimeFormatNoSeconds, ltime, dateString))) { - PRUnichar * uStr = dateString.ToNewUnicode(); + PRUnichar * uStr = ToNewUnicode(dateString); nsPageFrame::SetDateTimeStr(uStr); // nsPageFrame will own memory } } @@ -579,7 +580,7 @@ nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName, const char // Now go get the Localized Page Formating String nsAutoString propName; propName.AssignWithConversion(aPropName); - PRUnichar* uPropName = propName.ToNewUnicode(); + PRUnichar* uPropName = ToNewUnicode(propName); if (uPropName != nsnull) { nsresult rv = nsFormControlHelper::GetLocalizedString(PRINTING_PROPERTIES, uPropName, pageNumberFormat); if (NS_FAILED(rv)) { // back stop formatting @@ -588,7 +589,7 @@ nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName, const char nsMemory::Free(uPropName); } // Sets the format into a static data memeber which will own the memory and free it - PRUnichar* uStr = pageNumberFormat.ToNewUnicode(); + PRUnichar* uStr = ToNewUnicode(pageNumberFormat); if (uStr != nsnull) { nsPageFrame::SetPageNumberFormat(uStr, aPageNumOnly); // nsPageFrame will own the memory } diff --git a/mozilla/layout/html/base/src/nsImageMap.cpp b/mozilla/layout/html/base/src/nsImageMap.cpp index 077dec997e0..e48e4644603 100644 --- a/mozilla/layout/html/base/src/nsImageMap.cpp +++ b/mozilla/layout/html/base/src/nsImageMap.cpp @@ -36,6 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsImageMap.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsVoidArray.h" #include "nsIRenderingContext.h" #include "nsIPresContext.h" @@ -331,7 +332,7 @@ static nscoord* lo_parse_coord_list(char *str, PRInt32* value_cnt) void Area::ParseCoords(const nsString& aSpec) { - char* cp = aSpec.ToNewCString(); + char* cp = ToNewCString(aSpec); if (cp) { mCoords = lo_parse_coord_list(cp, &mNumCoords); nsCRT::free(cp); diff --git a/mozilla/layout/html/base/src/nsObjectFrame.cpp b/mozilla/layout/html/base/src/nsObjectFrame.cpp index 0212f7fb832..ef43d59712c 100644 --- a/mozilla/layout/html/base/src/nsObjectFrame.cpp +++ b/mozilla/layout/html/base/src/nsObjectFrame.cpp @@ -2099,8 +2099,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetAttributes(PRUint16& n, } } */ - mAttrNames[mNumAttrs] = name.ToNewUTF8String(); - mAttrVals[mNumAttrs] = value.ToNewUTF8String(); + mAttrNames[mNumAttrs] = ToNewUTF8String(name); + mAttrVals[mNumAttrs] = ToNewUTF8String(value); mNumAttrs++; } } @@ -2473,7 +2473,7 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetTagText(const char* *result) if (NS_FAILED(rv)) return rv; - mTagText = elementHTML.ToNewUTF8String(); + mTagText = ToNewUTF8String(elementHTML); if (!mTagText) return NS_ERROR_OUT_OF_MEMORY; } @@ -2601,8 +2601,8 @@ NS_IMETHODIMP nsPluginInstanceOwner::GetParameters(PRUint16& n, const char*const */ name.CompressWhitespace(); val.CompressWhitespace(); - mParamNames[mNumParams] = name.ToNewUTF8String(); - mParamVals[mNumParams] = val.ToNewUTF8String(); + mParamNames[mNumParams] = ToNewUTF8String(name); + mParamVals[mNumParams] = ToNewUTF8String(val); mNumParams++; } } diff --git a/mozilla/layout/html/base/src/nsPageFrame.cpp b/mozilla/layout/html/base/src/nsPageFrame.cpp index b72f958c033..e57a7a8ef9f 100644 --- a/mozilla/layout/html/base/src/nsPageFrame.cpp +++ b/mozilla/layout/html/base/src/nsPageFrame.cpp @@ -47,6 +47,7 @@ #include "nsIStyleSet.h" #include "nsIPresShell.h" #include "nsIDeviceContext.h" +#include "nsReadableUtils.h" // for page number localization formatting #include "nsTextFormatter.h" @@ -273,9 +274,7 @@ nsPageFrame::IsPercentageBase(PRBool& aBase) const static PRUnichar * GetUStr(const char * aCStr) { - nsAutoString str; - str.AssignWithConversion(aCStr); - return str.ToNewUnicode(); + return ToNewUnicode(nsDependentCString(aCStr)); } // replace the & with the value, but if the value is empty @@ -309,10 +308,7 @@ nsPageFrame::ProcessSpecialCodes(const nsString& aStr, nsString& aNewStr) if (mDateTimeStr != nsnull) { aNewStr.ReplaceSubstring(kDate, mDateTimeStr); } else { - nsAutoString empty; - PRUnichar * uEmpty = empty.ToNewUnicode(); - aNewStr.ReplaceSubstring(kDate, uEmpty); - nsMemory::Free(uEmpty); + aNewStr.ReplaceSubstring(kDate, NS_LITERAL_STRING("").get()); } nsMemory::Free(kDate); return; @@ -514,7 +510,7 @@ nsPageFrame::DrawHeaderFooter(nsIRenderingContext& aRenderingContext, aRenderingContext.PopState(clipEmpty); #ifdef DEBUG_PRINTING PRINT_DEBUG_MSG2("Page: %p", this); - char * s = str.ToNewCString(); + char * s = ToNewCString(str); if (s) { PRINT_DEBUG_MSG2(" [%s]", s); nsMemory::Free(s); diff --git a/mozilla/layout/html/base/src/nsPresShell.cpp b/mozilla/layout/html/base/src/nsPresShell.cpp index 82de6eab00e..1202dbf2aa3 100644 --- a/mozilla/layout/html/base/src/nsPresShell.cpp +++ b/mozilla/layout/html/base/src/nsPresShell.cpp @@ -79,6 +79,7 @@ #include "nsIDOMElement.h" #include "nsHTMLAtoms.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsWeakReference.h" #include "nsIPageSequenceFrame.h" #include "nsICaret.h" @@ -7328,7 +7329,7 @@ static void RecurseIndiTotals(nsIPresContext* aPresContext, IndiReflowCounter * counter = (IndiReflowCounter *)PL_HashTableLookup(aHT, key); if (counter) { counter->mHasBeenOutput = PR_TRUE; - char * name = counter->mName.ToNewCString(); + char * name = ToNewCString(counter->mName); for (PRInt32 i=0;imCount); for (PRInt32 inx=0;inx<5;inx++) { @@ -7354,7 +7355,7 @@ PRIntn ReflowCountMgr::DoSingleIndi(PLHashEntry *he, PRIntn i, void *arg) char *str = (char *)he->key; IndiReflowCounter * counter = (IndiReflowCounter *)he->value; if (counter && !counter->mHasBeenOutput) { - char * name = counter->mName.ToNewCString(); + char * name = ToNewCString(counter->mName); printf("%s - %p [%d][", name, counter->mFrame, counter->mCount); for (PRInt32 inx=0;inx<5;inx++) { if (inx != 0) printf(","); diff --git a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp index c955aae7d5a..2c18a3ec57a 100644 --- a/mozilla/layout/html/base/src/nsSimplePageSequence.cpp +++ b/mozilla/layout/html/base/src/nsSimplePageSequence.cpp @@ -35,6 +35,7 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsSimplePageSequence.h" #include "nsIPresContext.h" #include "nsIReflowCommand.h" @@ -465,7 +466,7 @@ nsSimplePageSequenceFrame::Reflow(nsIPresContext* aPresContext, time_t ltime; time( <ime ); if (NS_SUCCEEDED(dateTime->FormatTime(locale, kDateFormatShort, kTimeFormatNoSeconds, ltime, dateString))) { - PRUnichar * uStr = dateString.ToNewUnicode(); + PRUnichar * uStr = ToNewUnicode(dateString); nsPageFrame::SetDateTimeStr(uStr); // nsPageFrame will own memory } } @@ -579,7 +580,7 @@ nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName, const char // Now go get the Localized Page Formating String nsAutoString propName; propName.AssignWithConversion(aPropName); - PRUnichar* uPropName = propName.ToNewUnicode(); + PRUnichar* uPropName = ToNewUnicode(propName); if (uPropName != nsnull) { nsresult rv = nsFormControlHelper::GetLocalizedString(PRINTING_PROPERTIES, uPropName, pageNumberFormat); if (NS_FAILED(rv)) { // back stop formatting @@ -588,7 +589,7 @@ nsSimplePageSequenceFrame::SetPageNumberFormat(const char* aPropName, const char nsMemory::Free(uPropName); } // Sets the format into a static data memeber which will own the memory and free it - PRUnichar* uStr = pageNumberFormat.ToNewUnicode(); + PRUnichar* uStr = ToNewUnicode(pageNumberFormat); if (uStr != nsnull) { nsPageFrame::SetPageNumberFormat(uStr, aPageNumOnly); // nsPageFrame will own the memory } diff --git a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp index 60999c868bd..c115edbc19a 100644 --- a/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsComboboxControlFrame.cpp @@ -36,6 +36,7 @@ * * ***** END LICENSE BLOCK ***** */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsComboboxControlFrame.h" #include "nsIDOMEventReceiver.h" #include "nsIFrameManager.h" @@ -921,7 +922,7 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext, maxWidth = width; } //maxWidth = PR_MAX(width, maxWidth); - //printf("[%d] - %d %s \n", i, width, text.ToNewCString()); + //printf("[%d] - %d %s \n", i, width, NS_LossyConvertUCS2toASCII(text).get()); } } } @@ -930,7 +931,7 @@ nsComboboxControlFrame::ReflowItems(nsIPresContext* aPresContext, if (maxWidth == 0) { maxWidth = 11 * 15; } - char * str = maxStr.ToNewCString(); + char * str = ToNewCString(maxStr); printf("id: %d maxWidth %d [%s]\n", mReflowId, maxWidth, str); delete [] str; @@ -1995,7 +1996,7 @@ nsComboboxControlFrame::UpdateSelection(PRBool aDoDispatchEvent, PRBool aForceUp // Fix for Bug 42661 (remove comment later) #ifdef DO_REFLOW_DEBUG - char * str = mTextStr.ToNewCString(); + char * str = ToNewCString(mTextStr); REFLOW_DEBUG_MSG2("UpdateSelection %s\n", str); delete [] str; #endif @@ -2053,7 +2054,7 @@ nsComboboxControlFrame::SelectionChanged() shouldSetValue = PR_TRUE; } else { shouldSetValue = value != mTextStr; - REFLOW_DEBUG_MSG3("**** CBX::SelectionChanged Old[%s] New[%s]\n", value.ToNewCString(), mTextStr.ToNewCString()); + REFLOW_DEBUG_MSG3("**** CBX::SelectionChanged Old[%s] New[%s]\n", NS_LossyConvertUCS2toASCII(value).get(), NS_LossyConvertUCS2toASCII(mTextStr).get()); } if (shouldSetValue) { if (mTextStr.Length() == 0) { diff --git a/mozilla/layout/html/forms/src/nsFormFrame.cpp b/mozilla/layout/html/forms/src/nsFormFrame.cpp index 5cd22665e0a..650ccf3403a 100644 --- a/mozilla/layout/html/forms/src/nsFormFrame.cpp +++ b/mozilla/layout/html/forms/src/nsFormFrame.cpp @@ -47,6 +47,7 @@ #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsID.h" @@ -665,7 +666,7 @@ NS_NewFormFrame(nsIPresShell* aPresShell, nsIFrame** aNewFrame, PRUint32 aFlags) PRIVATE void DebugPrint(char* aLabel, nsString aString) { - char* out = aString.ToNewCString(); + char* out = ToNewCString(aString); printf("\n %s=%s\n", aLabel, out); delete [] out; } @@ -943,15 +944,15 @@ nsFormFrame::OnSubmit(nsIPresContext* aPresContext, nsIFrame* aFrame) #if defined(DEBUG_rods) || defined(DEBUG_pollmann) { printf("******\n"); - char * str = data.ToNewCString(); + char * str = ToNewCString(data); printf("postBuffer[%s]\n", str); Recycle(str); - str = absURLSpec.ToNewCString(); + str = ToNewCString(absURLSpec); printf("absURLSpec[%s]\n", str); Recycle(str); - str = target.ToNewCString(); + str = ToNewCString(target); printf("target [%s]\n", str); Recycle(str); printf("******\n"); @@ -1053,7 +1054,7 @@ nsFormFrame::URLEncode(const nsString& aString, nsIUnicodeEncoder* encoder) inBuf = UnicodeToNewBytes(aString.get(), aString.Length(), encoder); if(nsnull == inBuf) - inBuf = aString.ToNewCString(); + inBuf = ToNewCString(aString); // convert to CRLF breaks char* convertedBuf = nsLinebreakConverter::ConvertLineBreaks(inBuf, @@ -1092,7 +1093,7 @@ void nsFormFrame::GetSubmitCharset(nsString& oCharset) } } #ifdef DEBUG_ftang - printf("accept-charset = %s\n", acceptCharsetValue.ToNewUTF8String()); + printf("accept-charset = %s\n", NS_LossyConvertUCS2toASCII(acceptCharsetValue).get()); #endif PRInt32 l = acceptCharsetValue.Length(); if(l > 0 ) { @@ -1108,7 +1109,7 @@ void nsFormFrame::GetSubmitCharset(nsString& oCharset) nsAutoString charset; acceptCharsetValue.Mid(charset, offset, cnt); #ifdef DEBUG_ftang - printf("charset[i] = %s\n",charset.ToNewUTF8String()); + printf("charset[i] = %s\n", NS_LossyConvertUCS2toASCII(charset).get()); #endif if(NS_SUCCEEDED(calias->GetPreferred(charset,oCharset))) return; @@ -1154,7 +1155,7 @@ NS_IMETHODIMP nsFormFrame::GetEncoder(nsIUnicodeEncoder** encoder) nsresult rv = NS_OK; GetSubmitCharset(charset); #ifdef DEBUG_ftang - printf("charset=%s\n", charset.ToNewCString()); + printf("charset=%s\n", NS_LossyConvertUCS2toASCII(charset).get()); #endif // Get Charset, get the encoder. @@ -1496,9 +1497,9 @@ nsresult nsFormFrame::ProcessAsMultipart(nsIFormProcessor* aFormProcessor, } if(nsnull == name) - name = names[valueX].ToNewCString(); + name = ToNewCString(names[valueX]); if(nsnull == value) - value = valueStr.ToNewCString(); + value = ToNewCString(valueStr); if (0 == names[valueX].Length()) { continue; @@ -1651,9 +1652,9 @@ nsresult nsFormFrame::ProcessAsMultipart(nsIFormProcessor* aFormProcessor, } if(nsnull == name) - name = names[valueX].ToNewCString(); + name = ToNewCString(names[valueX]); if(nsnull == value) - value = valueStr.ToNewCString(); + value = ToNewCString(valueStr); if (0 == names[valueX].Length()) { continue; diff --git a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp index eaa7b01953c..0142521eb83 100644 --- a/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp +++ b/mozilla/layout/html/forms/src/nsIsIndexFrame.cpp @@ -67,6 +67,7 @@ #include "nsILinkHandler.h" #include "nsIHTMLDocument.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsICharsetConverterManager.h" #include "nsEscape.h" @@ -569,7 +570,7 @@ nsIsIndexFrame::URLEncode(const nsString& aString, nsIUnicodeEncoder* encoder, n inBuf = UnicodeToNewBytes(aString.get(), aString.Length(), encoder); if(nsnull == inBuf) - inBuf = aString.ToNewCString(); + inBuf = ToNewCString(aString); // convert to CRLF breaks char* convertedBuf = nsLinebreakConverter::ConvertLineBreaks(inBuf, diff --git a/mozilla/layout/html/forms/src/nsListControlFrame.cpp b/mozilla/layout/html/forms/src/nsListControlFrame.cpp index a0dd34a8402..440292d4138 100644 --- a/mozilla/layout/html/forms/src/nsListControlFrame.cpp +++ b/mozilla/layout/html/forms/src/nsListControlFrame.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nscore.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsListControlFrame.h" #include "nsFormControlFrame.h" // for COMPARE macro #include "nsFormControlHelper.h" @@ -708,7 +709,7 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext, } else { text = "No Value"; } - printf("[%d] - %s\n", i, text.ToNewCString()); + printf("[%d] - %s\n", i, NS_LossyConvertUCS2toASCII(text).get()); } } } diff --git a/mozilla/layout/style/nsCSSStyleSheet.cpp b/mozilla/layout/style/nsCSSStyleSheet.cpp index 691874da8f3..b38ebad5b11 100644 --- a/mozilla/layout/style/nsCSSStyleSheet.cpp +++ b/mozilla/layout/style/nsCSSStyleSheet.cpp @@ -62,6 +62,7 @@ #include "nsLayoutAtoms.h" #include "nsIFrame.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsVoidArray.h" #include "nsIUnicharInputStream.h" #include "nsHTMLIIDs.h" @@ -2284,7 +2285,7 @@ CSSStyleSheetImpl::CheckRuleForAttributes(nsICSSRule *aRule) #ifdef DEBUG_shaver_off nsAutoString str; sel->mAttr->ToString(str); - char * chars = str.ToNewCString(); + char * chars = ToNewCString(str); fprintf(stderr, "[%s@%p]", chars, this); nsMemory::Free(chars); #endif diff --git a/mozilla/layout/style/nsStyleUtil.cpp b/mozilla/layout/style/nsStyleUtil.cpp index 16d04383cd1..a67d12e5ec3 100644 --- a/mozilla/layout/style/nsStyleUtil.cpp +++ b/mozilla/layout/style/nsStyleUtil.cpp @@ -55,6 +55,7 @@ #include "nsIServiceManager.h" #include "nsIPref.h" +#include "nsReadableUtils.h" // XXX This is here because nsCachedStyleData is accessed outside of // the content module; e.g., by nsCSSFrameConstructor. @@ -717,7 +718,7 @@ PRBool nsStyleUtil::IsSimpleXlink(nsIContent *aContent, nsIPresContext *aPresCon // convert here, rather than twice in NS_MakeAbsoluteURI and // back again - char * href = val.ToNewCString(); + char * href = ToNewCString(val); char * absHREF = nsnull; (void) NS_MakeAbsoluteURI(&absHREF, href, baseURI); nsCRT::free(href); diff --git a/mozilla/layout/svg/base/src/nsPolygonFrame.cpp b/mozilla/layout/svg/base/src/nsPolygonFrame.cpp index b52383da5f4..0c2fe151459 100644 --- a/mozilla/layout/svg/base/src/nsPolygonFrame.cpp +++ b/mozilla/layout/svg/base/src/nsPolygonFrame.cpp @@ -53,6 +53,7 @@ #include "nsSVGAtoms.h" #include "nsIDeviceContext.h" #include "nsGUIEvent.h" +#include "nsReadableUtils.h" #include "nsIReflowCommand.h" extern nsresult @@ -172,14 +173,14 @@ nsPolygonFrame::Reflow(nsIPresContext* aPresContext, nsAutoString coordStr; nsresult res = mContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::x, coordStr); if (NS_SUCCEEDED(res)) { - char * s = coordStr.ToNewCString(); + char * s = ToNewCString(coordStr); mX = NSIntPixelsToTwips(atoi(s), p2t*scale); delete [] s; } res = mContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::y, coordStr); if (NS_SUCCEEDED(res)) { - char * s = coordStr.ToNewCString(); + char * s = ToNewCString(coordStr); mY = NSIntPixelsToTwips(atoi(s), p2t*scale); delete [] s; } @@ -252,7 +253,7 @@ nsPolygonFrame::GetPoints() nsAutoString pointsStr; nsresult res = mContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::points, pointsStr); - char * ps = pointsStr.ToNewCString(); + char * ps = ToNewCString(pointsStr); char seps[] = " "; char *token = strtok(ps, seps); PRInt32 cnt = 0; diff --git a/mozilla/layout/svg/base/src/nsSVGPathFrame.cpp b/mozilla/layout/svg/base/src/nsSVGPathFrame.cpp index b1289c08504..a9cc86d97f2 100644 --- a/mozilla/layout/svg/base/src/nsSVGPathFrame.cpp +++ b/mozilla/layout/svg/base/src/nsSVGPathFrame.cpp @@ -54,6 +54,7 @@ #include "nsIDeviceContext.h" #include "nsGUIEvent.h" //#include "nsSVGPathCID.h" +#include "nsReadableUtils.h" // // NS_NewSVGPathFrame @@ -160,14 +161,14 @@ nsSVGPathFrame::Reflow(nsIPresContext* aPresContext, nsAutoString coordStr; nsresult res = mContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::x, coordStr); if (NS_SUCCEEDED(res)) { - char * s = coordStr.ToNewCString(); + char * s = ToNewCString(coordStr); mX = NSIntPixelsToTwips(atoi(s), p2t*scale); delete [] s; } res = mContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::y, coordStr); if (NS_SUCCEEDED(res)) { - char * s = coordStr.ToNewCString(); + char * s = ToNewCString(coordStr); mY = NSIntPixelsToTwips(atoi(s), p2t*scale); delete [] s; } @@ -175,7 +176,7 @@ nsSVGPathFrame::Reflow(nsIPresContext* aPresContext, nsAutoString pathStr; res = mContent->GetAttr(kNameSpaceID_None, nsSVGAtoms::d, pathStr); if (NS_SUCCEEDED(res)) { - char * s = pathStr.ToNewCString(); + char * s = ToNewCString(pathStr); // parse path commands here delete [] s; } diff --git a/mozilla/layout/xul/base/src/nsMenuFrame.cpp b/mozilla/layout/xul/base/src/nsMenuFrame.cpp index 2153c27ce8a..579abbfcfd3 100644 --- a/mozilla/layout/xul/base/src/nsMenuFrame.cpp +++ b/mozilla/layout/xul/base/src/nsMenuFrame.cpp @@ -80,6 +80,7 @@ #include "nsIPref.h" #include "nsIScrollableView.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsGUIEvent.h" @@ -1451,7 +1452,7 @@ nsMenuFrame::BuildAcceleratorText(nsString& aAccelString) nsAutoString modifiers; keyElement->GetAttr(kNameSpaceID_None, nsXULAtoms::modifiers, modifiers); - char* str = modifiers.ToNewCString(); + char* str = ToNewCString(modifiers); char* newStr; char* token = nsCRT::strtok(str, ", ", &newStr); while (token) { diff --git a/mozilla/layout/xul/base/src/nsToolbarItemFrame.cpp b/mozilla/layout/xul/base/src/nsToolbarItemFrame.cpp index b912e4c3d9a..af21807156a 100644 --- a/mozilla/layout/xul/base/src/nsToolbarItemFrame.cpp +++ b/mozilla/layout/xul/base/src/nsToolbarItemFrame.cpp @@ -38,6 +38,7 @@ #include "nsToolbarItemFrame.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsWidgetsCID.h" @@ -150,12 +151,12 @@ nsToolbarItemFrame::HandleEvent(nsIPresContext* aPresContext, trans->AddDataFlavor(&textPlainFlavor); nsString dragText = "Drag Text"; PRUint32 len = 9; - trans->SetTransferData(&textPlainFlavor, dragText.ToNewCString(), len); // transferable consumes the data + trans->SetTransferData(&textPlainFlavor, ToNewCString(dragText), len); // transferable consumes the data trans2->AddDataFlavor(&textPlainFlavor); nsString dragText2 = "More Drag Text"; len = 14; - trans2->SetTransferData(&textPlainFlavor, dragText2.ToNewCString(), len); // transferable consumes the data + trans2->SetTransferData(&textPlainFlavor, ToNewCString(dragText2), len); // transferable consumes the data nsCOMPtr items; NS_NewISupportsArray(getter_AddRefs(items)); diff --git a/mozilla/mailnews/absync/src/nsAbSync.cpp b/mozilla/mailnews/absync/src/nsAbSync.cpp index 111aca9f9e3..346233e107a 100644 --- a/mozilla/mailnews/absync/src/nsAbSync.cpp +++ b/mozilla/mailnews/absync/src/nsAbSync.cpp @@ -53,6 +53,7 @@ #include "nsSyncDecoderRing.h" #include "plstr.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsTextFormatter.h" #include "nsIStringBundle.h" #include "nsMsgI18N.h" @@ -695,7 +696,7 @@ NS_IMETHODIMP nsAbSync::PerformAbSync(nsIDOMWindowInternal *aDOMWindow, PRInt32 mPostString.Insert(NS_ConvertASCIItoUCS2(prefixStr), 0); nsCRT::free(prefixStr); - protocolRequest = mPostString.ToNewCString(); + protocolRequest = ToNewCString(mPostString); if (!protocolRequest) goto EarlyExit; @@ -897,9 +898,9 @@ nsAbSync::GenerateProtocolForCard(nsIAbCard *aCard, PRBool aAddId, nsString &pro if (NS_SUCCEEDED(aCard->GetPreferMailFormat(&format))) { if (format != nsIAbPreferMailFormat::html) - aName = nsString(NS_ConvertASCIItoUCS2("0")).ToNewUnicode(); + aName = ToNewUnicode(NS_LITERAL_STRING("0")); else - aName = nsString(NS_ConvertASCIItoUCS2("1")).ToNewUnicode(); + aName = ToNewUnicode(NS_LITERAL_STRING("1")); // Just some sanity... if (aName) @@ -929,7 +930,7 @@ nsAbSync::GenerateProtocolForCard(nsIAbCard *aCard, PRBool aAddId, nsString &pro } } - char *tLine = tProtLine.ToNewCString(); + char *tLine = ToNewCString(tProtLine); if (!tLine) return NS_ERROR_OUT_OF_MEMORY; @@ -1015,7 +1016,7 @@ nsAbSync::ThisCardHasChanged(nsIAbCard *aCard, syncMappingRecord *newSyncRecord, return PR_FALSE; // Get the CRC for this temp entry line... - char *tLine = tempProtocolLine.ToNewCString(); + char *tLine = ToNewCString(tempProtocolLine); if (!tLine) return PR_FALSE; newSyncRecord->CRC = GetCRC(tLine); @@ -1293,7 +1294,7 @@ nsAbSync::AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *director mCrashTable[workCounter].localID = aKey; if (NS_SUCCEEDED(GenerateProtocolForCard(card, PR_FALSE, tProtLine))) { - char *tCRCLine = tProtLine.ToNewCString(); + char *tCRCLine = ToNewCString(tProtLine); if (tCRCLine) { mCrashTable[workCounter].CRC = GetCRC(tCRCLine); @@ -1438,7 +1439,7 @@ nsAbSync::AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *director if (mNewSyncMapingTable[workCounter].flags & SYNC_ADD) { #ifdef DEBUG_rhp - char *t = singleProtocolLine.ToNewCString(); + char *t = ToNewCString(singleProtocolLine); printf("ABSYNC: ADDING Card: %s\n", t); PR_FREEIF(t); #endif @@ -1458,7 +1459,7 @@ nsAbSync::AnalyzeAllRecords(nsIAddrDatabase *aDatabase, nsIAbDirectory *director else if (mNewSyncMapingTable[workCounter].flags & SYNC_MODIFIED) { #ifdef DEBUG_rhp - char *t = singleProtocolLine.ToNewCString(); + char *t = ToNewCString(singleProtocolLine); printf("ABSYNC: MODIFYING Card: %s\n", t); PR_FREEIF(t); #endif @@ -2079,7 +2080,7 @@ nsAbSync::ExtractCurrentLine() if (*mProtocolOffset == nsCRT::LF) mProtocolOffset++; - char *tString = extractString.ToNewCString(); + char *tString = ToNewCString(extractString); if (tString) { char *ret = nsUnescape(tString); @@ -2475,7 +2476,7 @@ nsAbSync::CardAlreadyInAddressBook(nsIAbCard *newCard, if (NS_FAILED(GenerateProtocolForCard(newCard, PR_FALSE, tProtLine))) return PR_FALSE; - char *tCRCLine = tProtLine.ToNewCString(); + char *tCRCLine = ToNewCString(tProtLine); if (!tCRCLine) return PR_FALSE; @@ -2665,7 +2666,7 @@ nsAbSync::AddNewUsers() // Ok, "val" could still be URL Encoded, so we need to decode // first and then pass into the call... // - char *myTStr = val->ToNewCString(); + char *myTStr = ToNewCString(*val); if (myTStr) { char *ret = nsUnescape(myTStr); @@ -2750,7 +2751,7 @@ nsAbSync::AddNewUsers() continue; // Get the CRC for this temp entry line... - char *tLine = tempProtocolLine.ToNewCString(); + char *tLine = ToNewCString(tempProtocolLine); if (!tLine) continue; @@ -2900,7 +2901,7 @@ nsAbSync::AddValueToNewCard(nsIAbCard *aCard, nsString *aTagName, nsString *aTag nsString outValue; char *tValue = nsnull; - tValue = aTagValue->ToNewCString(); + tValue = ToNewCString(*aTagValue); if (tValue) { rv = nsMsgI18NConvertToUnicode(nsCAutoString("UTF-8"), nsCAutoString(tValue), outValue); @@ -2938,7 +2939,7 @@ nsAbSync::AddValueToNewCard(nsIAbCard *aCard, nsString *aTagName, nsString *aTag else if (!aTagName->CompareWithConversion(kServerPriEmailColumn)) { #ifdef DEBUG_rhp - char *t = aTagValue->ToNewCString(); + char *t = ToNewCString(*aTagValue); printf("Email: %s\n", t); PR_FREEIF(t); #endif diff --git a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp index 98c0e2c6f72..8f1b68ccd08 100644 --- a/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp +++ b/mozilla/mailnews/absync/src/nsAbSyncPostEngine.cpp @@ -51,6 +51,7 @@ #include "nsIComponentManager.h" #include "nsIURI.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsAbSyncPostEngine.h" #include "nsIIOService.h" #include "nsIChannel.h" @@ -534,7 +535,7 @@ nsAbSyncPostEngine::OnStopRequest(nsIRequest *request, nsISupports * /* ctxt */, } else { - tProtResponse = mProtocolResponse.ToNewCString(); + tProtResponse = ToNewCString(mProtocolResponse); NotifyListenersOnStopSending(mTransactionID, aStatus, tProtResponse); } diff --git a/mozilla/mailnews/addrbook/src/nsAbAddressCollecter.cpp b/mozilla/mailnews/addrbook/src/nsAbAddressCollecter.cpp index 83a1d1a3bf7..6e0a2767c6d 100644 --- a/mozilla/mailnews/addrbook/src/nsAbAddressCollecter.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbAddressCollecter.cpp @@ -49,6 +49,7 @@ #include "nsIRDFService.h" #include "nsRDFCID.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "prmem.h" // For the new pref API's @@ -91,7 +92,7 @@ NS_IMETHODIMP nsAbAddressCollecter::CollectUnicodeAddress(const PRUnichar * aAdd // convert the unicode string to UTF-8... nsAutoString unicodeString (aAddress); - char * utf8Version = unicodeString.ToNewUTF8String(); + char * utf8Version = ToNewUTF8String(unicodeString); if (utf8Version) { rv = CollectAddress(utf8Version); diff --git a/mozilla/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp b/mozilla/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp index 7eecabb3756..c878574d387 100644 --- a/mozilla/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbAutoCompleteSession.cpp @@ -44,6 +44,7 @@ #include "nsIAbDirectory.h" #include "nsIAbCard.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMsgBaseCID.h" #include "nsMsgI18N.h" #include "nsIMsgIdentity.h" @@ -140,34 +141,31 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr, nsAutoString aStr(pDisplayNameStr); aStr.AppendWithConversion('@'); aStr += mDefaultDomain; - fullAddrStr = aStr.ToNewUnicode(); + fullAddrStr = ToNewUnicode(aStr); } else { if (mParser) { - char * fullAddress = nsnull; - char * utf8Name = nsAutoString(pDisplayNameStr).ToNewUTF8String(); - char * utf8Email; + nsXPIDLCString fullAddress; + nsXPIDLCString utf8Email; if (bIsMailList) { if (pNotesStr && pNotesStr[0] != 0) - utf8Email = nsAutoString(pNotesStr).ToNewUTF8String(); + utf8Email.Adopt(ToNewUTF8String(nsDependentString(pNotesStr))); else - utf8Email = nsAutoString(pDisplayNameStr).ToNewUTF8String(); + utf8Email.Adopt(ToNewUTF8String(nsDependentString(pDisplayNameStr))); } else - utf8Email = nsAutoString(pEmailStr).ToNewUTF8String(); + utf8Email.Adopt(ToNewUTF8String(nsDependentString(pEmailStr))); - mParser->MakeFullAddress(nsnull, utf8Name, utf8Email, &fullAddress); - if (fullAddress && *fullAddress) + mParser->MakeFullAddress(nsnull, NS_ConvertUCS2toUTF8(pDisplayNameStr).get(), + utf8Email, getter_Copies(fullAddress)); + if (!fullAddress.IsEmpty()) { /* We need to convert back the result from UTF-8 to Unicode */ - INTL_ConvertToUnicode(fullAddress, nsCRT::strlen(fullAddress), (void**)&fullAddrStr); - PR_Free(fullAddress); + INTL_ConvertToUnicode(fullAddress.get(), fullAddress.Length(), (void**)&fullAddrStr); } - Recycle(utf8Name); - Recycle(utf8Email); } if (!fullAddrStr) @@ -189,7 +187,7 @@ nsAbAutoCompleteSession::AddToResult(const PRUnichar* pNickNameStr, aStr.AppendWithConversion(" <"); aStr += pStr; aStr.AppendWithConversion(">"); - fullAddrStr = aStr.ToNewUnicode(); + fullAddrStr = ToNewUnicode(aStr); } else fullAddrStr = nsnull; @@ -458,7 +456,7 @@ nsresult nsAbAutoCompleteSession::SearchDirectory(nsString& fileName, nsAbAutoCo NS_ENSURE_SUCCESS(rv, rv); nsCOMPtr resource; - char * strFileName = fileName.ToNewCString(); + char * strFileName = ToNewCString(fileName); rv = rdfService->GetResource(strFileName, getter_AddRefs(resource)); Recycle(strFileName); NS_ENSURE_SUCCESS(rv, rv); @@ -675,7 +673,7 @@ NS_IMETHODIMP nsAbAutoCompleteSession::GetDefaultDomain(PRUnichar * *aDefaultDom if (!aDefaultDomain) return NS_ERROR_NULL_POINTER; - *aDefaultDomain = mDefaultDomain.ToNewUnicode(); + *aDefaultDomain = ToNewUnicode(mDefaultDomain); return NS_OK; } diff --git a/mozilla/mailnews/addrbook/src/nsAbBooleanExpression.cpp b/mozilla/mailnews/addrbook/src/nsAbBooleanExpression.cpp index 52f25469e0d..2ac6edc6e3b 100644 --- a/mozilla/mailnews/addrbook/src/nsAbBooleanExpression.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbBooleanExpression.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsAbBooleanExpression.h" +#include "nsReadableUtils.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsAbBooleanConditionString, nsIAbBooleanConditionString) @@ -78,7 +79,7 @@ NS_IMETHODIMP nsAbBooleanConditionString::GetName(char** aName) if (!value) *aName = 0; else - *aName = mName.ToNewCString (); + *aName = ToNewCString(mName); return NS_OK; @@ -99,7 +100,7 @@ NS_IMETHODIMP nsAbBooleanConditionString::GetValue(PRUnichar** aValue) if (!aValue) return NS_ERROR_NULL_POINTER; - *aValue = mValue.ToNewUnicode(); + *aValue = ToNewUnicode(mValue); return NS_OK; } diff --git a/mozilla/mailnews/addrbook/src/nsAbCard.cpp b/mozilla/mailnews/addrbook/src/nsAbCard.cpp index fa9c179bf3e..2df398b550b 100644 --- a/mozilla/mailnews/addrbook/src/nsAbCard.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbCard.cpp @@ -41,6 +41,7 @@ #include "nsIServiceManager.h" #include "nsRDFCID.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsAbBaseCID.h" #include "prmem.h" @@ -202,7 +203,7 @@ nsresult nsAbCard::AddSubNode(nsAutoString name, nsIAbCard **childCard) uri.Append(mURI); uri.Append('/'); - char *utf8Name = name.ToNewUTF8String(); + char *utf8Name = ToNewUTF8String(name); if (!utf8Name) return NS_ERROR_OUT_OF_MEMORY; uri.Append(utf8Name); diff --git a/mozilla/mailnews/addrbook/src/nsAbCardProperty.cpp b/mozilla/mailnews/addrbook/src/nsAbCardProperty.cpp index 0061d982bd5..28b477dc793 100644 --- a/mozilla/mailnews/addrbook/src/nsAbCardProperty.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbCardProperty.cpp @@ -47,6 +47,7 @@ #include "prprf.h" #include "rdf.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIPref.h" #include "nsIAbDirectory.h" @@ -94,7 +95,7 @@ nsresult nsAbCardProperty::GetAttributeName(PRUnichar **aName, nsString& value) { if (aName) { - *aName = value.ToNewUnicode(); + *aName = ToNewUnicode(value); if (!(*aName)) return NS_ERROR_OUT_OF_MEMORY; else @@ -256,7 +257,7 @@ NS_IMETHODIMP nsAbCardProperty::GetCardValue(const char *attrname, PRUnichar **v formatStr.AssignWithConversion("unknown"); break; } - *value = (PRUnichar *) formatStr.ToNewUnicode (); + *value = ToNewUnicode(formatStr); } /* else handle pass down attribute */ @@ -715,7 +716,7 @@ nsAbCardProperty::GetName(PRUnichar * *aName) } } - *aName = name.ToNewUnicode(); + *aName = ToNewUnicode(name); if (!(*aName)) return NS_ERROR_OUT_OF_MEMORY; else diff --git a/mozilla/mailnews/addrbook/src/nsAbDirProperty.cpp b/mozilla/mailnews/addrbook/src/nsAbDirProperty.cpp index c1deef64de7..598a0217d2e 100644 --- a/mozilla/mailnews/addrbook/src/nsAbDirProperty.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbDirProperty.cpp @@ -42,6 +42,7 @@ #include "nsIServiceManager.h" #include "nsRDFCID.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsAbBaseCID.h" #include "nsIAbCard.h" @@ -106,7 +107,7 @@ NS_IMETHODIMP nsAbDirProperty::GetDirName(PRUnichar **aDirName) { if (aDirName) { - *aDirName = m_DirName.ToNewUnicode(); + *aDirName = ToNewUnicode(m_DirName); if (!(*aDirName)) return NS_ERROR_OUT_OF_MEMORY; else @@ -147,7 +148,7 @@ nsresult nsAbDirProperty::GetAttributeName(PRUnichar **aName, nsString& value) { if (aName) { - *aName = value.ToNewUnicode(); + *aName = ToNewUnicode(value); if (!(*aName)) return NS_ERROR_OUT_OF_MEMORY; else diff --git a/mozilla/mailnews/addrbook/src/nsAbDirectoryQuery.cpp b/mozilla/mailnews/addrbook/src/nsAbDirectoryQuery.cpp index e08acef20c9..069170b85b3 100644 --- a/mozilla/mailnews/addrbook/src/nsAbDirectoryQuery.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbDirectoryQuery.cpp @@ -44,6 +44,7 @@ #include "nsIRDFResource.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "prthread.h" @@ -300,7 +301,7 @@ NS_IMETHODIMP nsAbDirectoryQueryPropertyValue::GetName(char* *aName) if (!value) *aName = 0; else - *aName = mName.ToNewCString (); + *aName = ToNewCString(mName); return NS_OK; @@ -309,7 +310,7 @@ NS_IMETHODIMP nsAbDirectoryQueryPropertyValue::GetName(char* *aName) /* read only attribute wstring value; */ NS_IMETHODIMP nsAbDirectoryQueryPropertyValue::GetValue(PRUnichar* *aValue) { - *aValue = mValue.ToNewUnicode(); + *aValue = ToNewUnicode(mValue); if (!(*aValue)) return NS_ERROR_OUT_OF_MEMORY; else diff --git a/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp b/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp index 2ce5d523204..aee8367cb41 100644 --- a/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbLDAPAutoCompFormatter.cpp @@ -36,6 +36,7 @@ #include "nsILDAPMessage.h" #include "nsLDAP.h" #include "prlog.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsISupportsPrimitives.h" #include "nsIDNSService.h" @@ -410,7 +411,7 @@ nsAbLDAPAutoCompFormatter::GetAttributes(PRUint32 *aCount, char ** *aAttrs) // while (rawSearchAttrsSize < count) { if (!(rawSearchAttrs[rawSearchAttrsSize] = - (mSearchAttrs.CStringAt(rawSearchAttrsSize))->ToNewCString())) { + ToNewCString(*(mSearchAttrs.CStringAt(rawSearchAttrsSize))))) { NS_FREE_XPCOM_ALLOCATED_POINTER_ARRAY(rawSearchAttrsSize, rawSearchAttrs); NS_ERROR("nsAbLDAPAutoCompFormatter::GetAttributes(): out " diff --git a/mozilla/mailnews/addrbook/src/nsAbMDBCard.cpp b/mozilla/mailnews/addrbook/src/nsAbMDBCard.cpp index c654bc31024..a8827fd8e6a 100644 --- a/mozilla/mailnews/addrbook/src/nsAbMDBCard.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbMDBCard.cpp @@ -41,6 +41,7 @@ #include "nsIServiceManager.h" #include "nsRDFCID.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsAbBaseCID.h" #include "prmem.h" @@ -222,7 +223,7 @@ nsresult nsAbMDBCard::AddSubNode(nsAutoString name, nsIAbCard **childCard) uri.Append(mURI); uri.Append('/'); - char *utf8Name = name.ToNewUTF8String(); + char *utf8Name = ToNewUTF8String(name); if (!utf8Name) return NS_ERROR_OUT_OF_MEMORY; uri.Append(utf8Name); diff --git a/mozilla/mailnews/addrbook/src/nsAbMDBCardProperty.cpp b/mozilla/mailnews/addrbook/src/nsAbMDBCardProperty.cpp index a8962c4b0fc..4b92dff25ad 100644 --- a/mozilla/mailnews/addrbook/src/nsAbMDBCardProperty.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbMDBCardProperty.cpp @@ -40,6 +40,7 @@ #include "nsIServiceManager.h" #include "nsRDFCID.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsAbBaseCID.h" #include "prmem.h" #include "prlog.h" @@ -468,8 +469,8 @@ static const char *kAbPrintUrlFormat = "addbook:printone?email=%s&folder=%s"; } dirNameStr.ReplaceSubstring(NS_ConvertASCIItoUCS2(" "), NS_ConvertASCIItoUCS2("%20")); - char *emailCharStr = emailStr.ToNewUTF8String(); - char *dirCharStr = dirNameStr.ToNewUTF8String(); + char *emailCharStr = ToNewUTF8String(emailStr); + char *dirCharStr = ToNewUTF8String(dirNameStr); *aPrintCardUrl = PR_smprintf(kAbPrintUrlFormat, emailCharStr, dirCharStr); diff --git a/mozilla/mailnews/addrbook/src/nsAbUtils.cpp b/mozilla/mailnews/addrbook/src/nsAbUtils.cpp index 3b919361694..16c13689678 100644 --- a/mozilla/mailnews/addrbook/src/nsAbUtils.cpp +++ b/mozilla/mailnews/addrbook/src/nsAbUtils.cpp @@ -40,6 +40,7 @@ #include "nsAbUtils.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" /* * Convert the nsCStringArray to a char* array @@ -66,9 +67,9 @@ nsresult CStringArrayToCharPtrArray::Convert (nsCStringArray& array, if (copyElements == PR_TRUE) (*returnPropertiesArray)[i] = - array[i]->ToNewCString(); + ToNewCString(*array[i]); else - (*returnPropertiesArray)[i] = NS_CONST_CAST(char *, (array[i]->ToNewCString())); + (*returnPropertiesArray)[i] = ToNewCString(*array[i]); } return NS_OK; @@ -120,9 +121,9 @@ nsresult StringArrayToPRUnicharPtrArray::Convert (nsStringArray& array, if (copyElements == PR_TRUE) (*returnPropertiesArray)[i] = - array[i]->ToNewUnicode(); + ToNewUnicode(*array[i]); else - (*returnPropertiesArray)[i] = NS_REINTERPRET_CAST(PRUnichar*,array[i]->ToNewCString()); + (*returnPropertiesArray)[i] = ToNewUnicode(*array[i]); } return NS_OK; diff --git a/mozilla/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp b/mozilla/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp index a040f58e85f..cfd9753e5db 100644 --- a/mozilla/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddbookProtocolHandler.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "msgCore.h" // precompiled header... #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPref.h" #include "nsIIOService.h" @@ -313,7 +314,7 @@ nsAddbookProtocolHandler::FindPossibleAbName(nsIAbCard *aCard, char *val = (char *)valuelist->ElementAt(i); if ( (val) && (*val) ) { - *retName = NS_ConvertASCIItoUCS2(val).ToNewUnicode(); + *retName = ToNewUnicode(nsDependentCString(val)); rv = NS_OK; } } @@ -364,7 +365,7 @@ nsAddbookProtocolHandler::GeneratePrintOutput(nsIAddbookUrl *addbookUrl, goto EarlyExit; // Make it a char * - charEmail = nsString(workEmail).ToNewCString(); + charEmail = ToNewCString(nsDependentString(workEmail)); if (!charEmail) goto EarlyExit; } @@ -378,7 +379,7 @@ nsAddbookProtocolHandler::GeneratePrintOutput(nsIAddbookUrl *addbookUrl, if ( (NS_SUCCEEDED(rv)) && (workAb) && (*workAb)) { // Make it a char * - charAb = nsString(workAb).ToNewCString(); + charAb = ToNewCString(nsDependentString(workAb)); if (!charAb) goto EarlyExit; @@ -417,7 +418,7 @@ nsAddbookProtocolHandler::GeneratePrintOutput(nsIAddbookUrl *addbookUrl, else rv = BuildAllHTML(aDatabase, directory, workBuffer); - *outBuf = workBuffer.ToNewUTF8String(); + *outBuf = ToNewUTF8String(workBuffer); EarlyExit: // Database is open...make sure to close it diff --git a/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp b/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp index df5fa72b9d8..ca3d2e89c3a 100644 --- a/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddrDatabase.cpp @@ -42,6 +42,7 @@ #include "nsIEnumerator.h" #include "nsFileStream.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsAbBaseCID.h" #include "nsIAbCard.h" #include "nsIAbMDBCard.h" @@ -1094,7 +1095,7 @@ nsresult nsAddrDatabase::ConvertAndAddLowercaseColumn err = GetStringColumn(row, fromCol, colUtf8String); if (colUtf8String.Length()) { - char* pUTF8String = colUtf8String.ToNewCString(); + char* pUTF8String = ToNewCString(colUtf8String); err = AddLowercaseColumn(row, toCol, pUTF8String); nsCRT::free(pUTF8String); } @@ -1108,30 +1109,20 @@ nsresult nsAddrDatabase::AddUnicodeToColumn(nsIMdbRow * row, mdb_token colToken, { nsresult err = NS_OK; nsAutoString displayString(pUnicodeStr); - char* pDisplayUTF8Str = displayString.ToNewUTF8String(); - nsAutoString newUnicodeString(pUnicodeStr); - newUnicodeString.ToLowerCase(); - char* pUTF8Str = newUnicodeString.ToNewUTF8String(); - if (pUTF8Str && pDisplayUTF8Str) + NS_ConvertUCS2toUTF8 displayUTF8Str(displayString); + displayString.ToLowerCase(); + NS_ConvertUCS2toUTF8 UTF8Str(displayString); + if (colToken == m_PriEmailColumnToken) { - if (colToken == m_PriEmailColumnToken) - { - err = AddCharStringColumn(row, m_PriEmailColumnToken, pDisplayUTF8Str); - err = AddLowercaseColumn(row, m_LowerPriEmailColumnToken, pUTF8Str); - } - else if (colToken == m_ListNameColumnToken) - { - err = AddCharStringColumn(row, m_ListNameColumnToken, pDisplayUTF8Str); - err = AddLowercaseColumn(row, m_LowerListNameColumnToken, pUTF8Str); - } + err = AddCharStringColumn(row, m_PriEmailColumnToken, displayUTF8Str.get()); + err = AddLowercaseColumn(row, m_LowerPriEmailColumnToken, UTF8Str.get()); + } + else if (colToken == m_ListNameColumnToken) + { + err = AddCharStringColumn(row, m_ListNameColumnToken, displayUTF8Str.get()); + err = AddLowercaseColumn(row, m_LowerListNameColumnToken, UTF8Str.get()); } - else - err = NS_ERROR_OUT_OF_MEMORY; - if (pDisplayUTF8Str) - Recycle(pDisplayUTF8Str); - if (pUTF8Str) - Recycle(pUTF8Str); return err; } @@ -2594,7 +2585,7 @@ NS_IMETHODIMP nsAddrDatabase::AddLdifListMember(nsIMdbRow* listRow, const char* PRInt32 emailPos = valueString.Find("mail="); emailPos += nsCRT::strlen("mail="); valueString.Right(email, valueString.Length() - emailPos); - char* emailAddress = (char*)email.ToNewCString(); + char* emailAddress = ToNewCString(email); nsIMdbRow *cardRow = nsnull; nsresult result = GetRowForEmailAddress(emailAddress, &cardRow); if (cardRow) @@ -2631,7 +2622,7 @@ void nsAddrDatabase::GetCharStringYarn(char* str, struct mdbYarn* strYarn) void nsAddrDatabase::GetStringYarn(nsString* str, struct mdbYarn* strYarn) { - strYarn->mYarn_Buf = str->ToNewCString(); + strYarn->mYarn_Buf = ToNewCString(*str); strYarn->mYarn_Size = PL_strlen((const char *) strYarn->mYarn_Buf) + 1; strYarn->mYarn_Fill = strYarn->mYarn_Size - 1; strYarn->mYarn_Form = 0; @@ -2903,7 +2894,6 @@ NS_IMETHODIMP nsAddrDatabase::GetAnonymousStringAttribute(const char *attrname, nsIMdbTableRowCursor* rowCursor; mdb_pos rowPos; nsAutoString tempString; - char *tempCString = nsnull; mdb_token anonymousColumnToken; GetStore()->StringToToken(GetEnv(), attrname, &anonymousColumnToken); @@ -2917,11 +2907,9 @@ NS_IMETHODIMP nsAddrDatabase::GetAnonymousStringAttribute(const char *attrname, if (NS_SUCCEEDED(err) && cardRow) { err = GetStringColumn(cardRow, anonymousColumnToken, tempString); - if (NS_SUCCEEDED(err) && tempString.Length()) + if (NS_SUCCEEDED(err) && !tempString.IsEmpty()) { - tempCString = tempString.ToNewUTF8String(); - *value = nsCRT::strdup(tempCString); - Recycle(tempCString); + *value = ToNewUTF8String(tempString); return NS_OK; } cardRow->CutStrongRef(GetEnv()); @@ -3047,13 +3035,13 @@ nsresult nsAddrDatabase::AddLowercaseColumn { nsAutoString newUnicodeString(unicodeStr); newUnicodeString.ToLowerCase(); - char * utf8Str = newUnicodeString.ToNewUTF8String(); + char * utf8Str = ToNewUTF8String(newUnicodeString); if (utf8Str) { err = AddCharStringColumn(row, columnToken, utf8Str); Recycle(utf8Str); - } - PR_FREEIF(unicodeStr); + } + PR_Free(unicodeStr); } } return err; @@ -3910,7 +3898,7 @@ nsresult nsAddrDatabase::GetRowForEmailAddress(const char *emailAddress, nsIMdbR { nsAutoString newUnicodeString(unicodeStr); newUnicodeString.ToLowerCase(); - char * pUTF8Str = newUnicodeString.ToNewUTF8String(); + char * pUTF8Str = ToNewUTF8String(newUnicodeString); if (pUTF8Str) { result = GetRowForCharColumn(pUTF8Str, m_LowerPriEmailColumnToken, PR_TRUE, cardRow); @@ -4055,7 +4043,7 @@ NS_IMETHODIMP nsAddrDatabase::FindMailListbyUnicodeName(const PRUnichar *listNam nsresult rv = NS_ERROR_FAILURE; nsAutoString unicodeString(listName); unicodeString.ToLowerCase(); - char* pUTF8Str = unicodeString.ToNewUTF8String(); + char* pUTF8Str = ToNewUTF8String(unicodeString); if (pUTF8Str) { nsIMdbRow *pListRow = nsnull; @@ -4121,7 +4109,7 @@ nsresult nsAddrDatabase::GetRowForCharColumn nsresult rv = NS_ERROR_FAILURE; nsAutoString unicodeString(unicodeStr); unicodeString.ToLowerCase(); - char* pUTF8Str = unicodeString.ToNewUTF8String(); + char* pUTF8Str = ToNewUTF8String(unicodeString); if (pUTF8Str) { rv = GetRowForCharColumn(pUTF8Str, findColumn, bIsCard, findRow); diff --git a/mozilla/mailnews/addrbook/src/nsAddressBook.cpp b/mozilla/mailnews/addrbook/src/nsAddressBook.cpp index 457ee8a3a11..3e9730f2fde 100644 --- a/mozilla/mailnews/addrbook/src/nsAddressBook.cpp +++ b/mozilla/mailnews/addrbook/src/nsAddressBook.cpp @@ -63,6 +63,7 @@ #include "nsIContentViewerFile.h" #include "nsIDocShell.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsICategoryManager.h" #include "nsIAbUpgrader.h" #include "nsSpecialSystemDirectory.h" @@ -1085,7 +1086,7 @@ void AddressBookParser::AddLdifRowToDatabase(PRBool bIsList) else return; - char* cursor = (char*)mLine.ToNewCString(); + char* cursor = ToNewCString(mLine); char* saveCursor = cursor; /* keep for deleting */ char* line = 0; char* typeSlot = 0; diff --git a/mozilla/mailnews/addrbook/src/nsDirPrefs.cpp b/mozilla/mailnews/addrbook/src/nsDirPrefs.cpp index fe5d4c47ce1..12b24ba9f57 100644 --- a/mozilla/mailnews/addrbook/src/nsDirPrefs.cpp +++ b/mozilla/mailnews/addrbook/src/nsDirPrefs.cpp @@ -48,6 +48,7 @@ #include "nsICharsetConverterManager.h" #include "nsIAbUpgrader.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "plstr.h" #include "prmem.h" @@ -319,7 +320,7 @@ PRInt32 INTL_ConvertToUnicode(const char* aBuffer, const PRInt32 aLength, // This can now use ToNewUTF8String (or this function itself can be substitued by that). // e.g. // nsAutoString aStr(uniBuffer); -// *aBuffer = aStr.ToNewUTF8String(); +// *aBuffer = ToNewUTF8String(aStr); // Do not use void* that was inherited from old libmime when it could not include C++, use PRUnichar* instead. PRInt32 INTL_ConvertFromUnicode(const PRUnichar* uniBuffer, const PRInt32 uniLength, char** aBuffer) { @@ -329,7 +330,7 @@ PRInt32 INTL_ConvertFromUnicode(const PRUnichar* uniBuffer, const PRInt32 uniLen } NS_ConvertUCS2toUTF8 temp(uniBuffer, uniLength); - *aBuffer = temp.ToNewCString(); + *aBuffer = ToNewCString(temp); return (*aBuffer) ? 0 : -1; } @@ -420,7 +421,7 @@ static nsresult dir_ConvertToMabFileName() name.Cut(pos, PL_strlen(ABFileName_kPreviousSuffix)); name.Append(ABFileName_kCurrentSuffix); PR_FREEIF (server->fileName); - server->fileName = name.ToNewCString(); + server->fileName = ToNewCString(name); } DIR_SavePrefsForOneServer(server); } diff --git a/mozilla/mailnews/base/search/src/nsMsgFilter.cpp b/mozilla/mailnews/base/search/src/nsMsgFilter.cpp index 7822a7c6c56..fc22ebe860f 100644 --- a/mozilla/mailnews/base/search/src/nsMsgFilter.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgFilter.cpp @@ -109,7 +109,7 @@ NS_IMETHODIMP nsMsgFilter::GetFilterName(PRUnichar **name) { NS_ENSURE_ARG_POINTER(name); - *name = m_filterName.ToNewUnicode(); + *name = ToNewUnicode(m_filterName); return NS_OK; } @@ -123,7 +123,7 @@ NS_IMETHODIMP nsMsgFilter::GetFilterDesc(char **description) { NS_ENSURE_ARG_POINTER(description); - *description = m_description.ToNewCString(); + *description = ToNewCString(m_description); return NS_OK; } @@ -276,7 +276,7 @@ nsMsgFilter::GetActionTargetFolderUri(char** aResult) NS_ENSURE_TRUE(m_action.m_type == nsMsgFilterAction::MoveToFolder, NS_ERROR_ILLEGAL_VALUE); if (m_action.m_folderUri) - *aResult = m_action.m_folderUri.ToNewCString(); + *aResult = ToNewCString(m_action.m_folderUri); return NS_OK; } @@ -303,11 +303,9 @@ NS_IMETHODIMP nsMsgFilter::LogRuleHit(nsOutputStream *stream, nsIMsgDBHdr *msgHd msgHdr->GetSubject(getter_Copies(subject)); if (stream) { - char *utf8name = nsAutoString(filterName).ToNewUTF8String(); *stream << "Applied filter \""; - *stream << utf8name; - ::Recycle(utf8name); + *stream << NS_ConvertUCS2toUTF8(filterName).get(); *stream << "\" to message from "; *stream << (const char*)author; @@ -472,7 +470,7 @@ nsresult nsMsgFilter::ConvertMoveToFolderValue(nsCString &moveValue) moveValue.ReplaceSubstring(".sbd/", "/"); #ifdef XP_MAC - char *unescapedMoveValue = moveValue.ToNewCString(); + char *unescapedMoveValue = ToNewCString(moveValue); nsUnescape(unescapedMoveValue); moveValue.Assign(unescapedMoveValue); nsCRT::free(unescapedMoveValue); diff --git a/mozilla/mailnews/base/search/src/nsMsgFilterDataSource.cpp b/mozilla/mailnews/base/search/src/nsMsgFilterDataSource.cpp index c4af91d2e6c..c988110ad8c 100644 --- a/mozilla/mailnews/base/search/src/nsMsgFilterDataSource.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgFilterDataSource.cpp @@ -44,6 +44,7 @@ #include "nsIMsgFilterList.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #define NC_RDF_ENABLED NC_NAMESPACE_URI "Enabled" @@ -326,7 +327,7 @@ nsMsgFilterDataSource::getFilterListTargets(nsIMsgFilterList *aFilterList, nsAutoString filterString(filterName); - char *utf8Name = filterString.ToNewUTF8String(); + char *utf8Name = ToNewUTF8String(filterString); filterUri.Append(utf8Name); Recycle(utf8Name); diff --git a/mozilla/mailnews/base/search/src/nsMsgFilterList.cpp b/mozilla/mailnews/base/search/src/nsMsgFilterList.cpp index d59c476955c..71e9536a4ab 100644 --- a/mozilla/mailnews/base/search/src/nsMsgFilterList.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgFilterList.cpp @@ -48,6 +48,7 @@ #include "nsMsgUtils.h" #include "nsMsgSearchTerm.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIImportService.h" #include "nsMsgBaseCID.h" #include "nsIMsgFilterService.h" @@ -558,7 +559,7 @@ nsresult nsMsgFilterList::LoadTextFilters(nsIOFileStream *aStream) { nsAutoString unicodeStr; impSvc->SystemStringToUnicode(value.get(), unicodeStr); - char *utf8 = unicodeStr.ToNewUTF8String(); + char *utf8 = ToNewUTF8String(unicodeStr); value.Assign(utf8); nsMemory::Free(utf8); } diff --git a/mozilla/mailnews/base/search/src/nsMsgImapSearch.cpp b/mozilla/mailnews/base/search/src/nsMsgImapSearch.cpp index 788fd4226c0..c35c09d8bf5 100644 --- a/mozilla/mailnews/base/search/src/nsMsgImapSearch.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgImapSearch.cpp @@ -37,6 +37,7 @@ #include "msgCore.h" #include "nsMsgSearchAdapter.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMsgSearchScopeTerm.h" #include "nsMsgResultElement.h" #include "nsMsgSearchTerm.h" @@ -77,7 +78,7 @@ nsresult nsMsgSearchOnlineMail::ValidateTerms () NS_IMETHODIMP nsMsgSearchOnlineMail::GetEncoding (char **result) { - *result = m_encoding.ToNewCString(); + *result = ToNewCString(m_encoding); return NS_OK; } diff --git a/mozilla/mailnews/base/search/src/nsMsgSearchAdapter.cpp b/mozilla/mailnews/base/search/src/nsMsgSearchAdapter.cpp index 768603b32c8..d05152be82a 100644 --- a/mozilla/mailnews/base/search/src/nsMsgSearchAdapter.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgSearchAdapter.cpp @@ -43,6 +43,7 @@ #include "nsMsgI18N.h" #include "nsIPref.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMsgSearchTerm.h" #include "nsMsgSearchBoolExpression.h" #include "nsIIOService.h" @@ -771,7 +772,7 @@ nsresult nsMsgSearchAdapter::EncodeImap (char **ppOutEncoding, nsISupportsArray // Set output parameter if we encoded the query successfully if (NS_SUCCEEDED(err)) - *ppOutEncoding = encodingBuff.ToNewCString(); + *ppOutEncoding = ToNewCString(encodingBuff); } delete [] termEncodings; diff --git a/mozilla/mailnews/base/search/src/nsMsgSearchNews.cpp b/mozilla/mailnews/base/search/src/nsMsgSearchNews.cpp index d6075df6a43..813b44954cf 100644 --- a/mozilla/mailnews/base/search/src/nsMsgSearchNews.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgSearchNews.cpp @@ -37,6 +37,7 @@ #include "msgCore.h" #include "nsMsgSearchAdapter.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMsgSearchScopeTerm.h" #include "nsMsgResultElement.h" #include "nsMsgSearchTerm.h" @@ -247,7 +248,7 @@ char *nsMsgSearchNews::EncodeTerm (nsIMsgSearchTerm *term) nsresult nsMsgSearchNews::GetEncoding(char **result) { NS_ENSURE_ARG(result); - *result = m_encoding.ToNewCString(); + *result = ToNewCString(m_encoding); return (*result) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/mailnews/base/search/src/nsMsgSearchTerm.cpp b/mozilla/mailnews/base/search/src/nsMsgSearchTerm.cpp index 5c653511d9d..f3f8d1d6033 100644 --- a/mozilla/mailnews/base/search/src/nsMsgSearchTerm.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgSearchTerm.cpp @@ -37,6 +37,7 @@ #include "msgCore.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMsgSearchCore.h" #include "nsIMsgSearchSession.h" @@ -820,7 +821,7 @@ nsresult nsMsgSearchTerm::MatchString (const char *stringToMatch, srcCharset.AssignWithConversion(charset); nsString out; ConvertToUnicode(srcCharset, stringToMatch ? stringToMatch : "", out); - utf8 = out.ToNewUTF8String(); + utf8 = ToNewUTF8String(out); } } @@ -1255,7 +1256,7 @@ NS_IMETHODIMP nsMsgSearchTerm::GetArbitraryHeader(char* *aResult) { NS_ENSURE_ARG_POINTER(aResult); - *aResult = m_arbitraryHeader.ToNewCString(); + *aResult = ToNewCString(m_arbitraryHeader); return NS_OK; } @@ -1442,7 +1443,7 @@ nsresult nsMsgResultElement::AssignValues (nsIMsgSearchValue *src, nsMsgSearchVa NS_ASSERTION(IS_STRING_ATTRIBUTE(dst->attribute), "assigning non-string result"); nsXPIDLString unicodeString; err = src->GetStr(getter_Copies(unicodeString)); - dst->string = NS_ConvertUCS2toUTF8(unicodeString).ToNewCString(); + dst->string = ToNewUTF8String(unicodeString); } else err = NS_ERROR_INVALID_ARG; diff --git a/mozilla/mailnews/base/search/src/nsMsgSearchValue.cpp b/mozilla/mailnews/base/search/src/nsMsgSearchValue.cpp index e39e751121d..940655b1dc2 100644 --- a/mozilla/mailnews/base/search/src/nsMsgSearchValue.cpp +++ b/mozilla/mailnews/base/search/src/nsMsgSearchValue.cpp @@ -38,6 +38,7 @@ #include "MailNewsTypes.h" #include "nsMsgSearchValue.h" +#include "nsReadableUtils.h" nsMsgSearchValueImpl::nsMsgSearchValueImpl(nsMsgSearchValue *aInitialValue) { @@ -63,7 +64,7 @@ nsMsgSearchValueImpl::GetStr(PRUnichar** aResult) { NS_ENSURE_ARG_POINTER(aResult); NS_ENSURE_TRUE(IS_STRING_ATTRIBUTE(mValue.attribute), NS_ERROR_ILLEGAL_VALUE); - *aResult = NS_ConvertUTF8toUCS2(mValue.string).ToNewUnicode(); + *aResult = ToNewUnicode(NS_ConvertUTF8toUCS2(mValue.string)); return NS_OK; } @@ -73,7 +74,7 @@ nsMsgSearchValueImpl::SetStr(const PRUnichar* aValue) NS_ENSURE_TRUE(IS_STRING_ATTRIBUTE(mValue.attribute), NS_ERROR_ILLEGAL_VALUE); if (mValue.string) nsCRT::free(mValue.string); - mValue.string = NS_ConvertUCS2toUTF8(aValue).ToNewCString(); + mValue.string = ToNewUTF8String(nsDependentString(aValue)); return NS_OK; } @@ -242,6 +243,6 @@ nsMsgSearchValueImpl::ToString(PRUnichar **aResult) resultStr.AppendWithConversion("]"); - *aResult = resultStr.ToNewUnicode(); + *aResult = ToNewUnicode(resultStr); return NS_OK; } diff --git a/mozilla/mailnews/base/src/nsMessenger.cpp b/mozilla/mailnews/base/src/nsMessenger.cpp index 095b57b274e..98002699c9f 100644 --- a/mozilla/mailnews/base/src/nsMessenger.cpp +++ b/mozilla/mailnews/base/src/nsMessenger.cpp @@ -46,6 +46,7 @@ #include "nsIStringStream.h" #include "nsEscape.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsTextFormatter.h" #include "nsIFileSpec.h" #ifdef XP_MAC @@ -582,7 +583,7 @@ nsMessenger::SaveAttachment(nsIFileSpec * fileSpec, urlString.AssignWithConversion(unescapedUrl); urlString.ReplaceSubstring(NS_ConvertASCIItoUCS2("/;section"), NS_ConvertASCIItoUCS2("?section")); - urlCString = urlString.ToNewCString(); + urlCString = ToNewCString(urlString); rv = CreateStartupUrl(urlCString, getter_AddRefs(aURL)); nsCRT::free(urlCString); @@ -907,7 +908,7 @@ nsMessenger::SaveAs(const char* url, PRBool asFile, nsIMsgIdentity* identity, ns else urlString.AppendWithConversion("?header=print"); - urlCString = urlString.ToNewCString(); + urlCString = ToNewCString(urlString); rv = CreateStartupUrl(urlCString, getter_AddRefs(aURL)); nsCRT::free(urlCString); if (NS_FAILED(rv)) goto done; diff --git a/mozilla/mailnews/base/src/nsMsgAccount.cpp b/mozilla/mailnews/base/src/nsMsgAccount.cpp index fa5bbade0b5..c2950024ab6 100644 --- a/mozilla/mailnews/base/src/nsMsgAccount.cpp +++ b/mozilla/mailnews/base/src/nsMsgAccount.cpp @@ -45,6 +45,7 @@ #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPref.h" #include "nsMsgBaseCID.h" @@ -374,7 +375,7 @@ nsMsgAccount::ToString(PRUnichar **aResult) nsAutoString val; val.AssignWithConversion("[nsIMsgAccount: "); val.AppendWithConversion(m_accountKey); val.AppendWithConversion("]"); - *aResult = val.ToNewUnicode(); + *aResult = ToNewUnicode(val); return NS_OK; } diff --git a/mozilla/mailnews/base/src/nsMsgDBView.cpp b/mozilla/mailnews/base/src/nsMsgDBView.cpp index ee0190a6b28..c0031bf33af 100644 --- a/mozilla/mailnews/base/src/nsMsgDBView.cpp +++ b/mozilla/mailnews/base/src/nsMsgDBView.cpp @@ -38,6 +38,7 @@ * ***** END LICENSE BLOCK ***** */ #include "msgCore.h" +#include "nsReadableUtils.h" #include "nsMsgDBView.h" #include "nsISupports.h" #include "nsIMsgFolder.h" @@ -257,7 +258,7 @@ nsresult nsMsgDBView::FetchSubject(nsIMsgHdr * aMsgHdr, PRUint32 aFlags, PRUnich nsAutoString reSubject; reSubject.Assign(NS_LITERAL_STRING("Re: ")); reSubject.Append(subject); - *aValue = reSubject.ToNewUnicode(); + *aValue = ToNewUnicode(reSubject); } else aMsgHdr->GetMime2DecodedSubject(aValue); @@ -320,7 +321,7 @@ nsresult nsMsgDBView::FetchDate(nsIMsgHdr * aHdr, PRUnichar ** aDateString) formattedDateString); if (NS_SUCCEEDED(rv)) - *aDateString = formattedDateString.ToNewUnicode(); + *aDateString = ToNewUnicode(formattedDateString); return rv; } @@ -369,7 +370,7 @@ nsresult nsMsgDBView::FetchSize(nsIMsgHdr * aHdr, PRUnichar ** aSizeString) formattedSizeString.Append(NS_LITERAL_STRING("KB")); } - *aSizeString = formattedSizeString.ToNewUnicode(); + *aSizeString = ToNewUnicode(formattedSizeString); return NS_OK; } @@ -976,7 +977,7 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, P PRUint32 numChildren; thread->GetNumChildren(&numChildren); formattedCountString.AppendInt(numChildren); - *aValue = formattedCountString.ToNewUnicode(); + *aValue = ToNewUnicode(formattedCountString); } } } @@ -996,7 +997,7 @@ NS_IMETHODIMP nsMsgDBView::GetCellText(PRInt32 aRow, const PRUnichar * aColID, P if (numUnreadChildren > 0) { formattedCountString.AppendInt(numUnreadChildren); - *aValue = formattedCountString.ToNewUnicode(); + *aValue = ToNewUnicode(formattedCountString); } } } diff --git a/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp b/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp index 255f2692d27..a0363206630 100644 --- a/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp +++ b/mozilla/mailnews/base/src/nsMsgPrintEngine.cpp @@ -24,6 +24,7 @@ #include "nsIURI.h" #include "nsEscape.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIWebShell.h" #include "nsIDocShell.h" #include "nsIDOMDocument.h" @@ -301,7 +302,7 @@ nsMsgPrintEngine::FireThatLoadOperation(nsString *uri) { nsresult rv = NS_OK; - char *tString = uri->ToNewCString(); + char *tString = ToNewCString(*uri); if (!tString) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/mailnews/base/src/nsMsgWindow.cpp b/mozilla/mailnews/base/src/nsMsgWindow.cpp index ec203cd98fb..3431335dd15 100644 --- a/mozilla/mailnews/base/src/nsMsgWindow.cpp +++ b/mozilla/mailnews/base/src/nsMsgWindow.cpp @@ -36,6 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsMsgWindow.h" +#include "nsReadableUtils.h" #include "nsIURILoader.h" #include "nsCURILoader.h" #include "nsIDocShell.h" @@ -311,7 +312,7 @@ NS_IMETHODIMP nsMsgWindow::GetMailCharacterSet(PRUnichar * *aMailCharacterSet) if(!aMailCharacterSet) return NS_ERROR_NULL_POINTER; - *aMailCharacterSet = mMailCharacterSet.ToNewUnicode(); + *aMailCharacterSet = ToNewUnicode(mMailCharacterSet); if (!(*aMailCharacterSet)) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/mailnews/base/util/nsLocalFolderSummarySpec.cpp b/mozilla/mailnews/base/util/nsLocalFolderSummarySpec.cpp index 015126ff942..1ffbc869632 100644 --- a/mozilla/mailnews/base/util/nsLocalFolderSummarySpec.cpp +++ b/mozilla/mailnews/base/util/nsLocalFolderSummarySpec.cpp @@ -38,6 +38,7 @@ #include "nsLocalFolderSummarySpec.h" #include "plstr.h" #include "nsString.h" +#include "nsReadableUtils.h" MOZ_DECL_CTOR_COUNTER(nsLocalFolderSummarySpec) @@ -89,7 +90,7 @@ void nsLocalFolderSummarySpec:: CreateSummaryFileName() // Mac and Unix can decide for themselves. fullLeafName.AppendWithConversion(".msf"); // message summary file - char *cLeafName = fullLeafName.ToNewCString(); + char *cLeafName = ToNewCString(fullLeafName); SetLeafName(cLeafName); nsMemory::Free(cLeafName); PL_strfree(leafName); diff --git a/mozilla/mailnews/base/util/nsMsgDBFolder.cpp b/mozilla/mailnews/base/util/nsMsgDBFolder.cpp index aedeb35f69b..692127455f0 100644 --- a/mozilla/mailnews/base/util/nsMsgDBFolder.cpp +++ b/mozilla/mailnews/base/util/nsMsgDBFolder.cpp @@ -38,6 +38,7 @@ #include "msgCore.h" #include "xp_core.h" +#include "nsReadableUtils.h" #include "nsMsgDBFolder.h" #include "nsMsgFolderFlags.h" #include "nsIPref.h" @@ -232,7 +233,7 @@ NS_IMETHODIMP nsMsgDBFolder::GetCharset(PRUnichar * *aCharset) rv = folderInfo->GetCharPtrCharacterSet(getter_Copies(charset)); if(NS_SUCCEEDED(rv)) { - *aCharset = NS_ConvertASCIItoUCS2(charset.get()).ToNewUnicode(); + *aCharset = ToNewUnicode(charset); } } return rv; diff --git a/mozilla/mailnews/base/util/nsMsgFolder.cpp b/mozilla/mailnews/base/util/nsMsgFolder.cpp index 73a57cef2f8..a7bbe02b26e 100644 --- a/mozilla/mailnews/base/util/nsMsgFolder.cpp +++ b/mozilla/mailnews/base/util/nsMsgFolder.cpp @@ -43,6 +43,7 @@ #include "nsISupportsArray.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsAutoLock.h" #include "nsMemory.h" @@ -864,7 +865,7 @@ NS_IMETHODIMP nsMsgFolder::GetName(PRUnichar **name) return server->GetPrettyName(name); } - *name = mName.ToNewUnicode(); + *name = ToNewUnicode(mName); if (!(*name)) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; @@ -2074,7 +2075,7 @@ NS_IMETHODIMP nsMsgFolder::GetNewMessagesNotificationDescription(PRUnichar * *aD description.Append(serverName); } } - *aDescription = description.ToNewUnicode(); + *aDescription = ToNewUnicode(description); return NS_OK; } @@ -2600,7 +2601,7 @@ NS_IMETHODIMP nsMsgFolder::GetUriForMsg(nsIMsgDBHdr *msgHdr, char **aURI) uri.Append('#'); uri.AppendInt(msgKey); - *aURI = uri.ToNewCString(); + *aURI = ToNewCString(uri); return NS_OK; } @@ -2619,7 +2620,7 @@ NS_IMETHODIMP nsMsgFolder::GenerateMessageURI(nsMsgKey msgKey, char **aURI) uri.Append('#'); uri.AppendInt(msgKey); - *aURI = uri.ToNewCString(); + *aURI = ToNewCString(uri); if (! *aURI) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; diff --git a/mozilla/mailnews/base/util/nsMsgI18N.cpp b/mozilla/mailnews/base/util/nsMsgI18N.cpp index 6d5d8002d1d..f4886cc6785 100644 --- a/mozilla/mailnews/base/util/nsMsgI18N.cpp +++ b/mozilla/mailnews/base/util/nsMsgI18N.cpp @@ -59,6 +59,7 @@ #include "nsHankakuToZenkakuCID.h" #include "nsXPIDLString.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prmem.h" #include "nsFileSpec.h" @@ -89,7 +90,7 @@ nsresult nsMsgI18NConvertFromUnicode(const nsCString& aCharset, return NS_OK; } else if (aCharset.EqualsIgnoreCase("UTF-8")) { - char *s = inString.ToNewUTF8String(); + char *s = ToNewUTF8String(inString); if (NULL == s) return NS_ERROR_OUT_OF_MEMORY; outString.Assign(s); @@ -238,11 +239,11 @@ nsresult ConvertFromUnicode(const nsString& aCharset, else if (aCharset.IsEmpty() || aCharset.EqualsIgnoreCase("us-ascii") || aCharset.EqualsIgnoreCase("ISO-8859-1")) { - *outCString = inString.ToNewCString(); + *outCString = ToNewCString(inString); return (NULL == *outCString) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; } else if (aCharset.EqualsIgnoreCase("UTF-8")) { - *outCString = inString.ToNewUTF8String(); + *outCString = ToNewUTF8String(inString); return (NULL == *outCString) ? NS_ERROR_OUT_OF_MEMORY : NS_OK; } @@ -430,17 +431,16 @@ char * nsMsgI18NGetDefaultMailCharset() nsCOMPtr prefs(do_GetService(kPrefCID, &res)); if (nsnull != prefs && NS_SUCCEEDED(res)) { - PRUnichar *prefValue; - res = prefs->GetLocalizedUnicharPref("mailnews.send_default_charset", &prefValue); - - if (NS_SUCCEEDED(res)) - { - //TODO: map to mail charset (e.g. Shift_JIS -> ISO-2022-JP) bug#3941. - retVal = NS_ConvertUCS2toUTF8(prefValue).ToNewCString(); - nsMemory::Free(prefValue); - } - else - retVal = nsCRT::strdup("ISO-8859-1"); + nsXPIDLString prefValue; + res = prefs->GetLocalizedUnicharPref("mailnews.send_default_charset", getter_Copies(prefValue)); + + if (NS_SUCCEEDED(res)) + { + //TODO: map to mail charset (e.g. Shift_JIS -> ISO-2022-JP) bug#3941. + retVal = ToNewUTF8String(prefValue); + } + else + retVal = nsCRT::strdup("ISO-8859-1"); } return (nsnull != retVal) ? retVal : nsCRT::strdup("ISO-8859-1"); diff --git a/mozilla/mailnews/base/util/nsMsgIdentity.cpp b/mozilla/mailnews/base/util/nsMsgIdentity.cpp index 70369f092e0..d59112f1e8e 100644 --- a/mozilla/mailnews/base/util/nsMsgIdentity.cpp +++ b/mozilla/mailnews/base/util/nsMsgIdentity.cpp @@ -40,6 +40,7 @@ #include "nsMsgIdentity.h" #include "nsIPref.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMsgCompCID.h" #include "nsIRDFService.h" @@ -338,7 +339,7 @@ nsMsgIdentity::GetIdentityName(PRUnichar **idName) { str.AppendWithConversion(" <"); str.AppendWithConversion((const char*)email); str.AppendWithConversion(">"); - *idName = str.ToNewUnicode(); + *idName = ToNewUnicode(str); rv = NS_OK; } @@ -356,7 +357,7 @@ nsMsgIdentity::ToString(PRUnichar **aResult) idname.AppendWithConversion(m_identityKey); idname.AppendWithConversion("]"); - *aResult = idname.ToNewUnicode(); + *aResult = ToNewUnicode(idname); return NS_OK; } diff --git a/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp b/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp index c1333c45770..604dd917c50 100644 --- a/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp +++ b/mozilla/mailnews/base/util/nsMsgIncomingServer.cpp @@ -46,6 +46,7 @@ #include "nsIServiceManager.h" #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsEscape.h" #include "nsMsgBaseCID.h" @@ -271,7 +272,7 @@ nsMsgIncomingServer::GetServerURI(char* *aResult) uri.Append(escapedHostname); } - *aResult = uri.ToNewCString(); + *aResult = ToNewCString(uri); return NS_OK; } @@ -632,7 +633,7 @@ nsMsgIncomingServer::GetConstructedPrettyName(PRUnichar **retval) prettyName.AppendWithConversion(hostname); - *retval = prettyName.ToNewUnicode(); + *retval = ToNewUnicode(prettyName); return NS_OK; } @@ -643,7 +644,7 @@ nsMsgIncomingServer::ToString(PRUnichar** aResult) { servername.AppendWithConversion(m_serverKey); servername.AppendWithConversion("]"); - *aResult = servername.ToNewUnicode(); + *aResult = ToNewUnicode(servername); NS_ASSERTION(*aResult, "no server name!"); return NS_OK; } @@ -671,7 +672,7 @@ NS_IMETHODIMP nsMsgIncomingServer::GetPassword(char ** aPassword) { NS_ENSURE_ARG_POINTER(aPassword); - *aPassword = m_password.ToNewCString(); + *aPassword = ToNewCString(m_password); return NS_OK; } diff --git a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp index f7a6686d8bc..7efcbc0cb56 100644 --- a/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp +++ b/mozilla/mailnews/base/util/nsMsgMailNewsUrl.cpp @@ -41,6 +41,7 @@ #include "nsIMsgMailSession.h" #include "nsIMsgAccountManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIDocumentLoader.h" #include "nsILoadGroup.h" #include "nsIWebShell.h" @@ -595,7 +596,7 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetFileName(char * *aFileName) { if (!mAttachmentFileName.IsEmpty()) { - *aFileName = mAttachmentFileName.ToNewCString(); + *aFileName = ToNewCString(mAttachmentFileName); return NS_OK; } else @@ -622,7 +623,7 @@ NS_IMETHODIMP nsMsgMailNewsUrl::GetFileExtension(char * *aFileExtension) mAttachmentFileName.Right(extension, mAttachmentFileName.Length() - (pos + 1) /* skip the '.' */); - *aFileExtension = extension.ToNewCString(); + *aFileExtension = ToNewCString(extension); return NS_OK; } else diff --git a/mozilla/mailnews/base/util/nsMsgProtocol.cpp b/mozilla/mailnews/base/util/nsMsgProtocol.cpp index 4c14bbce4fe..8f480960846 100644 --- a/mozilla/mailnews/base/util/nsMsgProtocol.cpp +++ b/mozilla/mailnews/base/util/nsMsgProtocol.cpp @@ -36,6 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "msgCore.h" +#include "nsReadableUtils.h" #include "nsMsgProtocol.h" #include "nsIMsgMailNewsUrl.h" #include "nsISocketTransportService.h" @@ -337,7 +338,7 @@ NS_IMETHODIMP nsMsgProtocol::OnStopRequest(nsIRequest *request, nsISupports *ctx nsAutoString resultString(NS_LITERAL_STRING("[StringID ")); resultString.AppendInt(errorID, 10); resultString.Append(NS_LITERAL_STRING("?]")); - errorMsg = resultString.ToNewUnicode(); + errorMsg = ToNewUnicode(resultString); } rv = msgPrompt->Alert(nsnull, errorMsg); nsMemory::Free(errorMsg); @@ -489,7 +490,7 @@ NS_IMETHODIMP nsMsgProtocol::GetContentType(char * *aContentType) if (m_ContentType.IsEmpty()) *aContentType = nsCRT::strdup("message/rfc822"); else - *aContentType = m_ContentType.ToNewCString(); + *aContentType = ToNewCString(m_ContentType); return NS_OK; } diff --git a/mozilla/mailnews/base/util/nsMsgUtf7Utils.cpp b/mozilla/mailnews/base/util/nsMsgUtf7Utils.cpp index c90fe0ee216..fff2512911f 100644 --- a/mozilla/mailnews/base/util/nsMsgUtf7Utils.cpp +++ b/mozilla/mailnews/base/util/nsMsgUtf7Utils.cpp @@ -40,6 +40,7 @@ #include "nsCOMPtr.h" #include "nsICharsetConverterManager.h" #include "prmem.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kCharsetConverterManagerCID, NS_ICHARSETCONVERTERMANAGER_CID); @@ -214,7 +215,7 @@ nsresult CreateUnicodeStringFromUtf7(const char *aSourceString, PRUnichar **aUni } NS_IF_RELEASE(decoder); nsString unicodeStr(unichars); - convertedString = unicodeStr.ToNewUnicode(); + convertedString = ToNewUnicode(unicodeStr); delete [] unichars; } } diff --git a/mozilla/mailnews/base/util/nsMsgUtils.cpp b/mozilla/mailnews/base/util/nsMsgUtils.cpp index e8081598031..683390e5815 100644 --- a/mozilla/mailnews/base/util/nsMsgUtils.cpp +++ b/mozilla/mailnews/base/util/nsMsgUtils.cpp @@ -40,6 +40,7 @@ #include "nsIMsgHdr.h" #include "nsMsgUtils.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsFileSpec.h" #include "nsEscape.h" #include "nsIServiceManager.h" @@ -485,7 +486,7 @@ nsresult NS_MsgDecodeUnescapeURLPath(const char *path, PRUnichar **result) nsUnescape(unescapedName); nsAutoString resultStr; resultStr = NS_ConvertUTF8toUCS2(unescapedName); - *result = resultStr.ToNewUnicode(); + *result = ToNewUnicode(resultStr); if (!*result) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } diff --git a/mozilla/mailnews/compose/src/nsMsgAttachmentHandler.cpp b/mozilla/mailnews/compose/src/nsMsgAttachmentHandler.cpp index 2def32a84d4..54077270cde 100644 --- a/mozilla/mailnews/compose/src/nsMsgAttachmentHandler.cpp +++ b/mozilla/mailnews/compose/src/nsMsgAttachmentHandler.cpp @@ -50,6 +50,7 @@ #include "nsMsgComposeStringBundle.h" #include "nsMsgCompCID.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIMsgMessageService.h" #include "nsMsgUtils.h" #include "nsMsgPrompts.h" @@ -1099,7 +1100,7 @@ nsMsgAttachmentHandler::UrlExit(nsresult status, const PRUnichar* aMsg) char *tData = nsnull; nsAutoString charset; charset.AssignWithConversion(m_charset); if (NS_FAILED(ConvertFromUnicode(charset, conData, &tData))) - tData = conData.ToNewCString(); + tData = ToNewCString(conData); if (tData) { (void) tempfile.write(tData, nsCRT::strlen(tData)); diff --git a/mozilla/mailnews/compose/src/nsMsgCompFields.cpp b/mozilla/mailnews/compose/src/nsMsgCompFields.cpp index 5cb7605de26..76b8ec059ef 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompFields.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompFields.cpp @@ -46,6 +46,7 @@ #include "nsMsgCompUtils.h" #include "prmem.h" #include "nsIFileChannel.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kHeaderParserCID, NS_MSGHEADERPARSER_CID); @@ -230,7 +231,7 @@ nsresult nsMsgCompFields::GetUnicodeHeader(MsgHeaderID header, PRUnichar **_retv { nsString unicodeStr; ConvertToUnicode(m_internalCharSet, GetAsciiHeader(header), unicodeStr); - *_retval = unicodeStr.ToNewUnicode(); + *_retval = ToNewUnicode(unicodeStr); return NS_OK; } @@ -545,7 +546,7 @@ NS_IMETHODIMP nsMsgCompFields::GetBody(PRUnichar **_retval) nsString unicodeStr; const char* cString = GetBody(); ConvertToUnicode(m_internalCharSet, cString, unicodeStr); - *_retval = unicodeStr.ToNewUnicode(); + *_retval = ToNewUnicode(unicodeStr); return NS_OK; } diff --git a/mozilla/mailnews/compose/src/nsMsgCompUtils.cpp b/mozilla/mailnews/compose/src/nsMsgCompUtils.cpp index 1d4cbfe793b..30e4bfa7bdb 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompUtils.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompUtils.cpp @@ -51,6 +51,7 @@ #include "nsMimeTypes.h" #include "nsMsgComposeStringBundle.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsSpecialSystemDirectory.h" #include "nsIDocumentEncoder.h" // for editor output flags #include "nsIURI.h" @@ -1557,7 +1558,7 @@ msg_pick_real_name (nsMsgAttachmentHandler *attachment, const char *charset) if (NS_FAILED(rv)) uStr.AssignWithConversion(attachment->m_real_name); - char *utf8Str = uStr.ToNewUTF8String(); + char *utf8Str = ToNewUTF8String(uStr); /* Try to MIME-2 encode the filename... */ char *mime2Name = nsMsgI18NEncodeMimePartIIStr((NULL != utf8Str) ? utf8Str : attachment->m_real_name, @@ -1941,7 +1942,7 @@ nsMsgGetExtensionFromFileURL(nsString aUrl) if (aUrl.IsEmpty()) return nsnull; - url = aUrl.ToNewCString(); + url = ToNewCString(aUrl); if (!url) goto ERROR_OUT; diff --git a/mozilla/mailnews/compose/src/nsMsgCompose.cpp b/mozilla/mailnews/compose/src/nsMsgCompose.cpp index 0826caf4c17..85fb41e3c2d 100644 --- a/mozilla/mailnews/compose/src/nsMsgCompose.cpp +++ b/mozilla/mailnews/compose/src/nsMsgCompose.cpp @@ -1357,7 +1357,7 @@ NS_IMETHODIMP nsMsgCompose::SetSavedFolderURI(const char *folderURI) NS_IMETHODIMP nsMsgCompose::GetSavedFolderURI(char ** folderURI) { NS_ENSURE_ARG_POINTER(folderURI); - *folderURI = m_folderName.ToNewCString(); + *folderURI = ToNewCString(m_folderName); return (*folderURI) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } @@ -1737,7 +1737,7 @@ NS_IMETHODIMP QuotingOutputStreamListener::OnStopRequest(nsIRequest *request, ns if (!composeHTML) { // Downsampling. The charset should only consist of ascii. - char *target_charset = aCharset.ToNewCString(); + char *target_charset = ToNewCString(aCharset); PRBool formatflowed = UseFormatFlowed(target_charset); ConvertToPlainText(formatflowed); Recycle(target_charset); @@ -2928,7 +2928,7 @@ nsresult nsMsgCompose::AttachmentPrettyName(const char* url, PRUnichar** _retval nsAutoString unicodeUrl; unicodeUrl.AssignWithConversion(url); - *_retval = unicodeUrl.ToNewUnicode(); + *_retval = ToNewUnicode(unicodeUrl); return NS_OK; } @@ -2943,7 +2943,7 @@ nsresult nsMsgCompose::AttachmentPrettyName(const char* url, PRUnichar** _retval nsresult rv = ConvertToUnicode(nsMsgI18NFileSystemCharset(), leafName, tempStr); if (NS_FAILED(rv)) tempStr.AssignWithConversion(leafName); - *_retval = tempStr.ToNewUnicode(); + *_retval = ToNewUnicode(tempStr); nsCRT::free(leafName); return NS_OK; } @@ -2952,7 +2952,7 @@ nsresult nsMsgCompose::AttachmentPrettyName(const char* url, PRUnichar** _retval if (PL_strncasestr(unescapeURL, "http:", 5)) unescapeURL.Cut(0, 7); - *_retval = unescapeURL.ToNewUnicode(); + *_retval = ToNewUnicode(unescapeURL); return NS_OK; } @@ -3299,19 +3299,15 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList, if (parser) { - char * fullAddress = nsnull; - char * utf8Name = nsAutoString((const PRUnichar*)pDisplayName).ToNewUTF8String(); - char * utf8Email = nsAutoString((const PRUnichar*)pEmail).ToNewUTF8String(); + nsXPIDLCString fullAddress; - parser->MakeFullAddress(nsnull, utf8Name, utf8Email, &fullAddress); - if (fullAddress && *fullAddress) + parser->MakeFullAddress(nsnull, NS_ConvertUCS2toUTF8(pDisplayName).get(), + NS_ConvertUCS2toUTF8(pEmail).get(), getter_Copies(fullAddress)); + if (!fullAddress.IsEmpty()) { /* We need to convert back the result from UTF-8 to Unicode */ - (void)ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), fullAddress, fullNameStr); - PR_Free(fullAddress); + (void)ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), fullAddress.get(), fullNameStr); } - Recycle(utf8Name); - Recycle(utf8Email); } if (fullNameStr.IsEmpty()) { @@ -3485,7 +3481,7 @@ NS_IMETHODIMP nsMsgCompose::CheckAndPopulateRecipients(PRBool populateMailList, } if (returnNonHTMLRecipients) - *nonHTMLRecipients = nonHtmlRecipientsStr.ToNewUnicode(); + *nonHTMLRecipients = ToNewUnicode(nonHtmlRecipientsStr); return rv; } @@ -4023,23 +4019,19 @@ nsMsgMailList::nsMsgMailList(nsString listName, nsString listDescription, nsIAbD if (parser) { - char * fullAddress = nsnull; - char * utf8Name = listName.ToNewUTF8String(); - char * utf8Email; + nsXPIDLCString fullAddress; + nsXPIDLCString utf8Email; if (listDescription.IsEmpty()) - utf8Email = listName.ToNewUTF8String(); + utf8Email.Adopt(ToNewUTF8String(listName)); else - utf8Email = listDescription.ToNewUTF8String(); + utf8Email.Adopt(ToNewUTF8String(listDescription)); - parser->MakeFullAddress(nsnull, utf8Name, utf8Email, &fullAddress); - if (fullAddress && *fullAddress) + parser->MakeFullAddress(nsnull, NS_ConvertUCS2toUTF8(listName).get(), utf8Email, getter_Copies(fullAddress)); + if (!fullAddress.IsEmpty()) { /* We need to convert back the result from UTF-8 to Unicode */ (void)ConvertToUnicode(NS_ConvertASCIItoUCS2(msgCompHeaderInternalCharset()), fullAddress, mFullName); - PR_Free(fullAddress); } - Recycle(utf8Name); - Recycle(utf8Email); } if (mFullName.IsEmpty()) diff --git a/mozilla/mailnews/compose/src/nsMsgComposeParams.cpp b/mozilla/mailnews/compose/src/nsMsgComposeParams.cpp index e52d5941a80..34d8e53a69c 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeParams.cpp +++ b/mozilla/mailnews/compose/src/nsMsgComposeParams.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsMsgComposeParams.h" +#include "nsReadableUtils.h" nsMsgComposeParams::nsMsgComposeParams() : mType(nsIMsgCompType::New), @@ -86,7 +87,7 @@ NS_IMETHODIMP nsMsgComposeParams::GetOriginalMsgURI(char * *aOriginalMsgURI) { NS_ENSURE_ARG_POINTER(aOriginalMsgURI); - *aOriginalMsgURI = mOriginalMsgUri.ToNewCString(); + *aOriginalMsgURI = ToNewCString(mOriginalMsgUri); return NS_OK; } NS_IMETHODIMP nsMsgComposeParams::SetOriginalMsgURI(const char * aOriginalMsgURI) @@ -174,7 +175,7 @@ NS_IMETHODIMP nsMsgComposeParams::GetSmtpPassword(char * *aSmtpPassword) { NS_ENSURE_ARG_POINTER(aSmtpPassword); - *aSmtpPassword = mSMTPPassword.ToNewCString(); + *aSmtpPassword = ToNewCString(mSMTPPassword); return NS_OK; } NS_IMETHODIMP nsMsgComposeParams::SetSmtpPassword(const char * aSmtpPassword) diff --git a/mozilla/mailnews/compose/src/nsMsgComposeProgressParams.cpp b/mozilla/mailnews/compose/src/nsMsgComposeProgressParams.cpp index cbaa750e582..488e7be5b98 100644 --- a/mozilla/mailnews/compose/src/nsMsgComposeProgressParams.cpp +++ b/mozilla/mailnews/compose/src/nsMsgComposeProgressParams.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsMsgComposeProgressParams.h" +#include "nsReadableUtils.h" NS_IMPL_ISUPPORTS1(nsMsgComposeProgressParams, nsIMsgComposeProgressParams) @@ -56,7 +57,7 @@ NS_IMETHODIMP nsMsgComposeProgressParams::GetSubject(PRUnichar * *aSubject) { NS_ENSURE_ARG(aSubject); - *aSubject = m_subject.ToNewUnicode(); + *aSubject = ToNewUnicode(m_subject); return NS_OK; } NS_IMETHODIMP nsMsgComposeProgressParams::SetSubject(const PRUnichar * aSubject) diff --git a/mozilla/mailnews/compose/src/nsMsgRecipientArray.cpp b/mozilla/mailnews/compose/src/nsMsgRecipientArray.cpp index 698d67f292e..e9c5195ea44 100644 --- a/mozilla/mailnews/compose/src/nsMsgRecipientArray.cpp +++ b/mozilla/mailnews/compose/src/nsMsgRecipientArray.cpp @@ -37,6 +37,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsMsgRecipientArray.h" #include "nsString.h" +#include "nsReadableUtils.h" nsMsgRecipientArray::nsMsgRecipientArray() { @@ -61,7 +62,7 @@ nsresult nsMsgRecipientArray::StringAt(PRInt32 idx, PRUnichar **_retval) nsString aStr; m_array->StringAt(idx, aStr); - *_retval = aStr.ToNewUnicode(); + *_retval = ToNewUnicode(aStr); return NS_OK; } diff --git a/mozilla/mailnews/compose/src/nsMsgSend.cpp b/mozilla/mailnews/compose/src/nsMsgSend.cpp index 89ca4f5679d..f2882fc233e 100644 --- a/mozilla/mailnews/compose/src/nsMsgSend.cpp +++ b/mozilla/mailnews/compose/src/nsMsgSend.cpp @@ -62,6 +62,7 @@ #include "nsIFileSpec.h" #include "nsMsgCopy.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMsgPrompts.h" #include "nsIDOMHTMLImageElement.h" #include "nsIDOMHTMLLinkElement.h" @@ -1686,11 +1687,11 @@ nsMsgComposeAndSend::ProcessMultipartRelated(PRInt32 *aMailboxCount, PRInt32 *aN if (NS_FAILED(image->GetName(tName))) return NS_ERROR_OUT_OF_MEMORY; - attachment.real_name = tName.ToNewCString(); + attachment.real_name = ToNewCString(tName); if (NS_FAILED(image->GetLongDesc(tDesc))) return NS_ERROR_OUT_OF_MEMORY; - attachment.description = tDesc.ToNewCString(); + attachment.description = ToNewCString(tDesc); } else if (link) // Is this a link? @@ -1724,7 +1725,7 @@ nsMsgComposeAndSend::ProcessMultipartRelated(PRInt32 *aMailboxCount, PRInt32 *aN if (NS_FAILED(anchor->GetName(tName))) return NS_ERROR_OUT_OF_MEMORY; - attachment.real_name = tName.ToNewCString(); + attachment.real_name = ToNewCString(tName); } else { @@ -1861,7 +1862,7 @@ nsMsgComposeAndSend::ProcessMultipartRelated(PRInt32 *aMailboxCount, PRInt32 *aN } if (!domURL.IsEmpty()) - domSaveArray[j].url = domURL.ToNewCString(); + domSaveArray[j].url = ToNewCString(domURL); } } @@ -2181,7 +2182,7 @@ nsMsgComposeAndSend::AddCompFieldRemoteAttachments(PRUint32 aStartLocation, str.Find("snews_message:") != -1) (*aNewsCount)++; - m_attachments[newLoc].m_uri = str.ToNewCString(); + m_attachments[newLoc].m_uri = ToNewCString(str); ++newLoc; } } diff --git a/mozilla/mailnews/compose/src/nsMsgSendLater.cpp b/mozilla/mailnews/compose/src/nsMsgSendLater.cpp index d0090f3f81b..789992af08d 100644 --- a/mozilla/mailnews/compose/src/nsMsgSendLater.cpp +++ b/mozilla/mailnews/compose/src/nsMsgSendLater.cpp @@ -463,8 +463,7 @@ nsCOMPtr pMsgSend = nsnull; nsMsgCompFields * fields = (nsMsgCompFields *)compFields.get(); - nsString authorStr; authorStr.AssignWithConversion(author); - fields->SetFrom(authorStr.ToNewUnicode()); + fields->SetFrom(author.get()); if (m_to) fields->SetTo(m_to); diff --git a/mozilla/mailnews/compose/src/nsMsgSendReport.cpp b/mozilla/mailnews/compose/src/nsMsgSendReport.cpp index 81addea4266..3edb758c25e 100644 --- a/mozilla/mailnews/compose/src/nsMsgSendReport.cpp +++ b/mozilla/mailnews/compose/src/nsMsgSendReport.cpp @@ -43,6 +43,7 @@ #include "nsMsgComposeStringBundle.h" #include "nsMsgCompCID.h" #include "nsMsgPrompts.h" +#include "nsReadableUtils.h" NS_IMPL_ISUPPORTS1(nsMsgProcessReport, nsIMsgProcessReport) @@ -87,7 +88,7 @@ NS_IMETHODIMP nsMsgProcessReport::SetError(nsresult aError) NS_IMETHODIMP nsMsgProcessReport::GetMessage(PRUnichar * *aMessage) { NS_ENSURE_ARG_POINTER(aMessage); - *aMessage = mMessage.ToNewUnicode(); + *aMessage = ToNewUnicode(mMessage); return NS_OK; } NS_IMETHODIMP nsMsgProcessReport::SetMessage(const PRUnichar * aMessage) @@ -298,7 +299,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError nsMsgBuildErrorMessageByID(currError, errorMsg); if (! errorMsg.IsEmpty()) - currMessage.Adopt(errorMsg.ToNewUnicode()); + currMessage.Adopt(ToNewUnicode(errorMsg)); break; } } @@ -364,7 +365,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError if (! dialogMessage.IsEmpty()) temp.Append(NS_LITERAL_STRING("\n")); temp.Append(currMessage); - dialogMessage.Adopt(temp.ToNewUnicode()); + dialogMessage.Adopt(ToNewUnicode(temp)); } } @@ -377,7 +378,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError if (! dialogMessage.IsEmpty()) temp.Append(NS_LITERAL_STRING("\n")); temp.Append(text1); - dialogMessage.Adopt(temp.ToNewUnicode()); + dialogMessage.Adopt(ToNewUnicode(temp)); nsMsgAskBooleanQuestionByString(prompt, dialogMessage, &oopsGiveMeBackTheComposeWindow, dialogTitle); if (!oopsGiveMeBackTheComposeWindow) *_retval = NS_OK; @@ -430,7 +431,7 @@ NS_IMETHODIMP nsMsgSendReport::DisplayReport(nsIPrompt *prompt, PRBool showError if (! dialogMessage.IsEmpty()) temp.Append(NS_LITERAL_STRING("\n")); temp.Append(currMessage); - dialogMessage.Adopt(temp.ToNewUnicode()); + dialogMessage.Adopt(ToNewUnicode(temp)); } nsMsgDisplayMessageByString(prompt, dialogMessage, dialogTitle); diff --git a/mozilla/mailnews/compose/src/nsSmtpServer.cpp b/mozilla/mailnews/compose/src/nsSmtpServer.cpp index fa2486ef708..37e7092c9e5 100644 --- a/mozilla/mailnews/compose/src/nsSmtpServer.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpServer.cpp @@ -42,6 +42,7 @@ #include "nsIPrompt.h" #include "nsIWalletService.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kWalletServiceCID, NS_WALLETSERVICE_CID); @@ -69,7 +70,7 @@ nsSmtpServer::GetKey(char * *aKey) if (mKey.IsEmpty()) *aKey = nsnull; else - *aKey = mKey.ToNewCString(); + *aKey = ToNewCString(mKey); return NS_OK; } @@ -210,7 +211,7 @@ NS_IMETHODIMP nsSmtpServer::GetPassword(char * *aPassword) { NS_ENSURE_ARG_POINTER(aPassword); - *aPassword = m_password.ToNewCString(); + *aPassword = ToNewCString(m_password); return NS_OK; } @@ -375,7 +376,7 @@ nsSmtpServer::GetServerURI(char **aResult) uri.Append(escapedHostname); } - *aResult = uri.ToNewCString(); + *aResult = ToNewCString(uri); return NS_OK; } diff --git a/mozilla/mailnews/compose/src/nsSmtpService.cpp b/mozilla/mailnews/compose/src/nsSmtpService.cpp index 386f64b616a..84bb96a3894 100644 --- a/mozilla/mailnews/compose/src/nsSmtpService.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpService.cpp @@ -38,6 +38,7 @@ #include "msgCore.h" // precompiled header... #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPref.h" #include "nsIIOService.h" #include "nsNetCID.h" @@ -812,7 +813,7 @@ nsSmtpService::DeleteSmtpServer(nsISmtpServer *aServer) nsCAutoString newServerList; char *newStr; - char *rest = mServerKeyList.ToNewCString(); + char *rest = ToNewCString(mServerKeyList); char *token = nsCRT::strtok(rest, ",", &newStr); while (token) { diff --git a/mozilla/mailnews/compose/src/nsSmtpUrl.cpp b/mozilla/mailnews/compose/src/nsSmtpUrl.cpp index ff616e44cb9..b780a80288d 100644 --- a/mozilla/mailnews/compose/src/nsSmtpUrl.cpp +++ b/mozilla/mailnews/compose/src/nsSmtpUrl.cpp @@ -41,6 +41,7 @@ #include "nsNetCID.h" #include "nsSmtpUrl.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsXPIDLString.h" #include "nsEscape.h" @@ -274,35 +275,35 @@ NS_IMETHODIMP nsMailtoUrl::GetMessageContents(char ** aToPart, char ** aCcPart, char ** aNewsgroupPart, char ** aNewsHostPart, PRBool * aForcePlainText) { if (aToPart) - *aToPart = m_toPart.ToNewCString(); + *aToPart = ToNewCString(m_toPart); if (aCcPart) - *aCcPart = m_ccPart.ToNewCString(); + *aCcPart = ToNewCString(m_ccPart); if (aBccPart) - *aBccPart = m_bccPart.ToNewCString(); + *aBccPart = ToNewCString(m_bccPart); if (aFromPart) - *aFromPart = m_fromPart.ToNewCString(); + *aFromPart = ToNewCString(m_fromPart); if (aFollowUpToPart) - *aFollowUpToPart = m_followUpToPart.ToNewCString(); + *aFollowUpToPart = ToNewCString(m_followUpToPart); if (aOrganizationPart) - *aOrganizationPart = m_organizationPart.ToNewCString(); + *aOrganizationPart = ToNewCString(m_organizationPart); if (aReplyToPart) - *aReplyToPart = m_replyToPart.ToNewCString(); + *aReplyToPart = ToNewCString(m_replyToPart); if (aSubjectPart) - *aSubjectPart = m_subjectPart.ToNewCString(); + *aSubjectPart = ToNewCString(m_subjectPart); if (aBodyPart) - *aBodyPart = m_bodyPart.ToNewCString(); + *aBodyPart = ToNewCString(m_bodyPart); if (aHtmlPart) - *aHtmlPart = m_htmlPart.ToNewCString(); + *aHtmlPart = ToNewCString(m_htmlPart); if (aReferencePart) - *aReferencePart = m_referencePart.ToNewCString(); + *aReferencePart = ToNewCString(m_referencePart); if (aAttachmentPart) *aAttachmentPart = nsnull; // never pass out an attachment part as part of a mailto url if (aPriorityPart) - *aPriorityPart = m_priorityPart.ToNewCString(); + *aPriorityPart = ToNewCString(m_priorityPart); if (aNewsgroupPart) - *aNewsgroupPart = m_newsgroupPart.ToNewCString(); + *aNewsgroupPart = ToNewCString(m_newsgroupPart); if (aNewsHostPart) - *aNewsHostPart = m_newsHostPart.ToNewCString(); + *aNewsHostPart = ToNewCString(m_newsHostPart); if (aForcePlainText) *aForcePlainText = m_forcePlainText; return NS_OK; @@ -483,7 +484,7 @@ nsSmtpUrl::GetRecipients(char ** aRecipientsList) { NS_ENSURE_ARG_POINTER(aRecipientsList); if (aRecipientsList) - *aRecipientsList = m_toPart.ToNewCString(); + *aRecipientsList = ToNewCString(m_toPart); return NS_OK; } diff --git a/mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp b/mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp index 051b33ee3ad..7418e2f10b2 100644 --- a/mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp +++ b/mozilla/mailnews/db/msgdb/src/nsDBFolderInfo.cpp @@ -44,6 +44,7 @@ #include "nsIObserver.h" #include "nsIObserverService.h" #include "nsIMsgDBView.h" +#include "nsReadableUtils.h" static const char *kDBFolderInfoScope = "ns:msg:db:row:scope:dbfolderinfo:all"; static const char *kDBFolderInfoTableKind = "ns:msg:db:table:kind:dbfolderinfo"; @@ -672,7 +673,7 @@ nsDBFolderInfo::GetCharPtrCharacterSet(char **result) if (NS_SUCCEEDED(rv) && (*result == nsnull || **result == '\0')) { - *result = gDefaultCharacterSet.ToNewCString(); + *result = ToNewCString(gDefaultCharacterSet); } return rv; diff --git a/mozilla/mailnews/db/msgdb/src/nsMsgDatabase.cpp b/mozilla/mailnews/db/msgdb/src/nsMsgDatabase.cpp index 61229e9f828..14a84fa63bc 100644 --- a/mozilla/mailnews/db/msgdb/src/nsMsgDatabase.cpp +++ b/mozilla/mailnews/db/msgdb/src/nsMsgDatabase.cpp @@ -48,6 +48,7 @@ #include "nsFileStream.h" #include "nsString.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIMsgHeaderParser.h" #include "nsMsgBaseCID.h" #include "nsMorkCID.h" @@ -2949,7 +2950,7 @@ nsresult nsMsgDatabase::RowCellColumnToCharPtr(nsIMdbRow *row, mdb_token columnT /* static */struct mdbYarn *nsMsgDatabase::nsStringToYarn(struct mdbYarn *yarn, nsString *str) { - yarn->mYarn_Buf = str->ToNewCString(); + yarn->mYarn_Buf = ToNewCString(*str); yarn->mYarn_Size = PL_strlen((const char *) yarn->mYarn_Buf) + 1; yarn->mYarn_Fill = yarn->mYarn_Size - 1; yarn->mYarn_Form = 0; // what to do with this? we're storing csid in the msg hdr... diff --git a/mozilla/mailnews/db/msgdb/src/nsMsgOfflineImapOperation.cpp b/mozilla/mailnews/db/msgdb/src/nsMsgOfflineImapOperation.cpp index 505657f6356..30a9f3e23f4 100644 --- a/mozilla/mailnews/db/msgdb/src/nsMsgOfflineImapOperation.cpp +++ b/mozilla/mailnews/db/msgdb/src/nsMsgOfflineImapOperation.cpp @@ -37,6 +37,7 @@ #include "msgCore.h" #include "nsMsgOfflineImapOperation.h" +#include "nsReadableUtils.h" /* Implementation file */ NS_IMPL_ISUPPORTS1(nsMsgOfflineImapOperation, nsIMsgOfflineImapOperation) @@ -262,7 +263,7 @@ NS_IMETHODIMP nsMsgOfflineImapOperation::GetCopyDestination(PRInt32 copyIndex, c nsCString *copyDest = m_copyDestinations.CStringAt(copyIndex); if (copyDest) { - *retval = copyDest->ToNewCString(); + *retval = ToNewCString(*copyDest); return (*retval) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } else diff --git a/mozilla/mailnews/imap/src/nsIMAPGenericParser.cpp b/mozilla/mailnews/imap/src/nsIMAPGenericParser.cpp index 966204c6db8..454a1d28be3 100644 --- a/mozilla/mailnews/imap/src/nsIMAPGenericParser.cpp +++ b/mozilla/mailnews/imap/src/nsIMAPGenericParser.cpp @@ -41,6 +41,7 @@ #include "nsImapProtocol.h" #include "nsIMAPGenericParser.h" #include "nsString.h" +#include "nsReadableUtils.h" /************************************************* The following functions are used to implement @@ -507,7 +508,7 @@ char *nsIMAPGenericParser::CreateQuoted(PRBool /*skipToEnd*/) else NS_ASSERTION(PR_FALSE, "didn't find close quote"); - return returnString.ToNewCString(); + return ToNewCString(returnString); } @@ -755,6 +756,6 @@ char *nsIMAPGenericParser::CreateParenGroup() fNextToken = GetNextToken(); } - return returnString.ToNewCString(); + return ToNewCString(returnString); } diff --git a/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp b/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp index addbec6eaca..2f2f4768eb4 100644 --- a/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp +++ b/mozilla/mailnews/imap/src/nsImapIncomingServer.cpp @@ -45,6 +45,7 @@ #include "nsMsgImapCID.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIMAPHostSessionList.h" #include "nsImapIncomingServer.h" @@ -2069,7 +2070,7 @@ NS_IMETHODIMP nsImapIncomingServer::GetImapStringByID(PRInt32 aMsgId, PRUnichar resultString.AssignWithConversion("[StringID"); resultString.AppendInt(aMsgId, 10); resultString.AssignWithConversion("?]"); - *aString = resultString.ToNewUnicode(); + *aString = ToNewUnicode(resultString); } else { @@ -2079,7 +2080,7 @@ NS_IMETHODIMP nsImapIncomingServer::GetImapStringByID(PRInt32 aMsgId, PRUnichar else { res = NS_OK; - *aString = resultString.ToNewUnicode(); + *aString = ToNewUnicode(resultString); } return res; } @@ -2366,7 +2367,7 @@ NS_IMETHODIMP nsImapIncomingServer::GetManageMailAccountUrl(char **manageMailAcc if (!manageMailAccountUrl) return NS_ERROR_NULL_POINTER; - *manageMailAccountUrl = m_manageMailAccountUrl.ToNewCString(); + *manageMailAccountUrl = ToNewCString(m_manageMailAccountUrl); return NS_OK; } diff --git a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp index bd67310e05e..820078b96e2 100644 --- a/mozilla/mailnews/imap/src/nsImapMailFolder.cpp +++ b/mozilla/mailnews/imap/src/nsImapMailFolder.cpp @@ -77,6 +77,7 @@ #include "nsIInterfaceRequestorUtils.h" #include "nsSpecialSystemDirectory.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIImapFlagAndUidState.h" #include "nsIMessenger.h" #include "nsIMsgSearchAdapter.h" @@ -302,7 +303,7 @@ NS_IMETHODIMP nsImapMailFolder::AddSubfolderWithPath(nsAutoString *name, nsIFile uri.AppendWithConversion('/'); uri.Append(*name); - char* uriStr = uri.ToNewCString(); + char* uriStr = ToNewCString(uri); if (uriStr == nsnull) return NS_ERROR_OUT_OF_MEMORY; @@ -949,7 +950,7 @@ NS_IMETHODIMP nsImapMailFolder::GetOnlineDelimiter(char** onlineDelimiter) PRUnichar delimiter = 0; rv = GetHierarchyDelimiter(&delimiter); nsAutoString aString(delimiter); - *onlineDelimiter = aString.ToNewCString(); + *onlineDelimiter = ToNewCString(aString); return rv; } return NS_ERROR_NULL_POINTER; @@ -1680,7 +1681,7 @@ NS_IMETHODIMP nsImapMailFolder::GetOnlineName(char ** aOnlineFolderName) if (!aOnlineFolderName) return NS_ERROR_NULL_POINTER; ReadDBFolderInfo(PR_FALSE); // update cache first. - *aOnlineFolderName = m_onlineFolderName.ToNewCString(); + *aOnlineFolderName = ToNewCString(m_onlineFolderName); return (*aOnlineFolderName) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; // ### do we want to read from folder cache first, or has that been done? diff --git a/mozilla/mailnews/imap/src/nsImapProtocol.cpp b/mozilla/mailnews/imap/src/nsImapProtocol.cpp index 57534c4c53d..9d20a67233b 100644 --- a/mozilla/mailnews/imap/src/nsImapProtocol.cpp +++ b/mozilla/mailnews/imap/src/nsImapProtocol.cpp @@ -68,6 +68,7 @@ #include "nsISocketTransportService.h" #include "nsNetUtil.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPipe.h" #include "nsIMsgFolder.h" #include "nsImapStringBundle.h" @@ -2357,7 +2358,7 @@ char *nsImapProtocol::CreateEscapedMailboxName(const char *rawName) escapedName.Insert('\\', strIndex++); } } - return escapedName.ToNewCString(); + return ToNewCString(escapedName); } void nsImapProtocol::SelectMailbox(const char *mailboxName) @@ -2672,7 +2673,7 @@ nsImapProtocol::FetchMessage(const char * messageIds, if (protocolString) { - char *cCommandStr = commandString.ToNewCString(); + char *cCommandStr = ToNewCString(commandString); if ((whatToFetch == kMIMEPart) || (whatToFetch == kMIMEHeader)) { @@ -4254,7 +4255,7 @@ PRUnichar * nsImapProtocol::CreatePRUnicharStringFromUTF7(const char * aSourceSt NS_IF_RELEASE(decoder); // convert the unicode to 8 bit ascii. nsString unicodeStr(unichars); - convertedString = unicodeStr.ToNewUnicode(); + convertedString = ToNewUnicode(unicodeStr); } } return convertedString; @@ -6067,7 +6068,7 @@ char * nsImapProtocol::CreatePossibleTrashName(const char *prefix) nsCString returnTrash(prefix); returnTrash += "Trash"; - return returnTrash.ToNewCString(); + return ToNewCString(returnTrash); } void nsImapProtocol::Lsub(const char *mailboxPattern, PRBool addDirectoryIfNecessary) @@ -7297,7 +7298,7 @@ NS_IMETHODIMP nsImapMockChannel::GetContentType(char * *aContentType) if (m_ContentType.IsEmpty()) *aContentType = nsCRT::strdup("message/rfc822"); else - *aContentType = m_ContentType.ToNewCString(); + *aContentType = ToNewCString(m_ContentType); return NS_OK; } diff --git a/mozilla/mailnews/imap/src/nsImapService.cpp b/mozilla/mailnews/imap/src/nsImapService.cpp index 746e8ebcd81..688f7ec428c 100644 --- a/mozilla/mailnews/imap/src/nsImapService.cpp +++ b/mozilla/mailnews/imap/src/nsImapService.cpp @@ -57,6 +57,7 @@ #include "nsIRDFService.h" #include "nsIEventQueueService.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsRDFCID.h" #include "nsEscape.h" #include "nsIMsgStatusFeedback.h" @@ -1073,7 +1074,7 @@ nsresult nsImapService::DecomposeImapURI(const char * aMessageURI, nsIMsgFolder if (msgKey) { nsCAutoString messageIdString; messageIdString.AppendInt(msgKey, 10 /* base 10 */); - *aMsgKey = messageIdString.ToNewCString(); + *aMsgKey = ToNewCString(messageIdString); } return rv; diff --git a/mozilla/mailnews/imap/src/nsImapUrl.cpp b/mozilla/mailnews/imap/src/nsImapUrl.cpp index 2c1ae8575e3..8dd1fb6a5d1 100644 --- a/mozilla/mailnews/imap/src/nsImapUrl.cpp +++ b/mozilla/mailnews/imap/src/nsImapUrl.cpp @@ -55,6 +55,7 @@ #include "nsMsgBaseCID.h" #include "nsImapUtils.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsAutoLock.h" #include "nsIMAPNamespace.h" #include "nsICacheEntryDescriptor.h" @@ -374,7 +375,7 @@ NS_IMETHODIMP nsImapUrl::CreateListOfMessageIdsString(char ** aResult) bytesToCopy = PR_MIN(bytesToCopy, wherePart - m_listOfMessageIds); newStr.Assign(m_listOfMessageIds, bytesToCopy); - *aResult = newStr.ToNewCString(); + *aResult = ToNewCString(newStr); return NS_OK; } @@ -737,7 +738,7 @@ NS_IMETHODIMP nsImapUrl::AddOnlineDirectoryIfNecessary(const char *onlineMailbox rv = server->GetKey(getter_Copies(serverKey)); if (NS_FAILED(rv)) return rv; rv = hostSessionList->GetOnlineDirForHost(serverKey, aString); - char *onlineDir = aString.Length() > 0 ? aString.ToNewCString() : nsnull; + char *onlineDir = !aString.IsEmpty() ? ToNewCString(aString) : nsnull; // If this host has an online server directory configured if (onlineMailboxName && onlineDir) @@ -940,7 +941,7 @@ NS_IMETHODIMP nsImapUrl::AllocateCanonicalPath(const char *serverPath, char onli // First we have to check to see if we should strip off an online server // subdirectory // If this host has an online server directory configured - onlineDir = aString.Length() > 0? aString.ToNewCString(): nsnull; + onlineDir = !aString.IsEmpty() ? ToNewCString(aString) : nsnull; if (currentPath && onlineDir) { @@ -1202,7 +1203,7 @@ NS_IMETHODIMP nsImapUrl::GetUri(char** aURI) { nsresult rv = NS_OK; if (!mURI.IsEmpty()) - *aURI = mURI.ToNewCString(); + *aURI = ToNewCString(mURI); else { *aURI = nsnull; @@ -1224,7 +1225,7 @@ NS_IMETHODIMP nsImapUrl::GetUri(char** aURI) nsCAutoString uriStr; rv = nsBuildImapMessageURI(baseMessageURI, key, uriStr); nsCRT::free(baseMessageURI); - *aURI = uriStr.ToNewCString(); + *aURI = ToNewCString(uriStr); } return rv; @@ -1512,7 +1513,7 @@ NS_IMETHODIMP nsImapUrl::GetFolderCharsetOverride(PRBool * aCharacterSetOverride NS_IMETHODIMP nsImapUrl::GetCharsetOverRide(PRUnichar ** aCharacterSet) { if (!mCharsetOverride.IsEmpty()) - *aCharacterSet = mCharsetOverride.ToNewUnicode(); + *aCharacterSet = ToNewUnicode(mCharsetOverride); else *aCharacterSet = nsnull; return NS_OK; diff --git a/mozilla/mailnews/imap/src/nsImapUtils.cpp b/mozilla/mailnews/imap/src/nsImapUtils.cpp index 1b4d9778795..0953d0ba930 100644 --- a/mozilla/mailnews/imap/src/nsImapUtils.cpp +++ b/mozilla/mailnews/imap/src/nsImapUtils.cpp @@ -39,6 +39,7 @@ #include "msgCore.h" #include "nsImapUtils.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "prsystem.h" #include "nsEscape.h" @@ -114,7 +115,7 @@ nsImapURI2Path(const char* rootURI, const char* uriStr, nsFileSpec& pathResult) do_GetService(NS_MSGACCOUNTMANAGER_CONTRACTID, &rv); if(NS_FAILED(rv)) return rv; - char *unescapedUserName = username.ToNewCString(); + char *unescapedUserName = ToNewCString(username); if (unescapedUserName) { nsUnescape(unescapedUserName); @@ -187,7 +188,7 @@ nsImapURI2FullName(const char* rootURI, const char* hostname, const char* uriStr if (hostEnd <= 0) return NS_ERROR_FAILURE; uri.Right(fullName, uri.Length() - hostEnd - 1); if (fullName.IsEmpty()) return NS_ERROR_FAILURE; - *name = fullName.ToNewCString(); + *name = ToNewCString(fullName); return NS_OK; } @@ -222,7 +223,7 @@ nsresult nsParseImapMessageURI(const char* uri, nsCString& folderURI, PRUint32 * { nsCString partSubStr; uriStr.Right(partSubStr, uriStr.Length() - keyEndSeparator); - *part = partSubStr.ToNewCString(); + *part = ToNewCString(partSubStr); } } @@ -254,7 +255,7 @@ nsresult nsCreateImapBaseMessageURI(const char *baseURI, char **baseMessageURI) nsCAutoString baseURIStr(kImapMessageRootURI); baseURIStr += tailURI; - *baseMessageURI = baseURIStr.ToNewCString(); + *baseMessageURI = ToNewCString(baseURIStr); if(!*baseMessageURI) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraAddress.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraAddress.cpp index 28d58ca4958..fc9025d8c0d 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraAddress.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraAddress.cpp @@ -24,6 +24,7 @@ #include "nsIAbCard.h" #include "nsIServiceManager.h" #include "nsEudoraImport.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kAbCardPropertyCID, NS_ABCARDPROPERTY_CID); @@ -705,7 +706,6 @@ void nsEudoraAddress::BuildSingleCard( CAliasEntry *pEntry, CAliasData *pData, n nsIMdbRow* newRow = nsnull; pDb->GetNewRow( &newRow); - char * pCStr; /* @@ -736,55 +736,46 @@ void nsEudoraAddress::BuildSingleCard( CAliasEntry *pEntry, CAliasData *pData, n phone.ReplaceSubstring( "\x03", " "); name.ReplaceSubstring( "\x03", " "); - nsString uniStr; - if (newRow) { - ConvertToUnicode( displayName, uniStr); - pDb->AddDisplayName( newRow, pCStr = uniStr.ToNewUTF8String()); - nsCRT::free( pCStr); - - ConvertToUnicode( pEntry->m_name, uniStr); - pDb->AddNickName( newRow, pCStr = uniStr.ToNewUTF8String()); - nsCRT::free( pCStr); - - - ConvertToUnicode( pData->m_email, uniStr); - pDb->AddPrimaryEmail( newRow, pCStr = uniStr.ToNewUTF8String()); - nsCRT::free( pCStr); - + nsAutoString uniStr; + + ConvertToUnicode( displayName.get(), uniStr); + pDb->AddDisplayName( newRow, NS_ConvertUCS2toUTF8(uniStr).get()); + + ConvertToUnicode( pEntry->m_name.get(), uniStr); + pDb->AddNickName( newRow, NS_ConvertUCS2toUTF8(uniStr).get()); + + ConvertToUnicode( pData->m_email.get(), uniStr); + pDb->AddPrimaryEmail( newRow, NS_ConvertUCS2toUTF8(uniStr).get()); + if (!fax.IsEmpty()) { - ConvertToUnicode( fax, uniStr); - pDb->AddFaxNumber( newRow, pCStr = uniStr.ToNewUTF8String()); - nsCRT::free( pCStr); + ConvertToUnicode( fax.get(), uniStr); + pDb->AddFaxNumber( newRow, NS_ConvertUCS2toUTF8(uniStr).get()); } if (!phone.IsEmpty()) { - ConvertToUnicode( phone, uniStr); - pDb->AddHomePhone( newRow, pCStr = uniStr.ToNewUTF8String()); - nsCRT::free( pCStr); + ConvertToUnicode( phone.get(), uniStr); + pDb->AddHomePhone( newRow, NS_ConvertUCS2toUTF8(uniStr).get()); } if (!address.IsEmpty()) { - ConvertToUnicode( address, uniStr); - pDb->AddHomeAddress( newRow, pCStr = uniStr.ToNewUTF8String()); - nsCRT::free( pCStr); + ConvertToUnicode( address.get(), uniStr); + pDb->AddHomeAddress( newRow, NS_ConvertUCS2toUTF8(uniStr).get()); } if (!address2.IsEmpty()) { - ConvertToUnicode( address2, uniStr); - pDb->AddHomeAddress2( newRow, pCStr = uniStr.ToNewUTF8String()); - nsCRT::free( pCStr); + ConvertToUnicode( address2.get(), uniStr); + pDb->AddHomeAddress2( newRow, NS_ConvertUCS2toUTF8(uniStr).get()); } if (!note.IsEmpty()) { - ConvertToUnicode( note, uniStr); - pDb->AddNotes( newRow, pCStr = uniStr.ToNewUTF8String()); - nsCRT::free( pCStr); + ConvertToUnicode( note.get(), uniStr); + pDb->AddNotes( newRow, NS_ConvertUCS2toUTF8(uniStr).get()); } pDb->AddCardRowToDB( newRow); - - IMPORT_LOG1( "Added card to db: %s\n", (const char *)displayName); + + IMPORT_LOG1( "Added card to db: %s\n", displayName.get()); } } diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraCompose.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraCompose.cpp index 0644607bf20..84249737978 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraCompose.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraCompose.cpp @@ -20,6 +20,7 @@ #include "nscore.h" #include "prthread.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsIFileSpec.h" #include "nsIComponentManager.h" @@ -641,7 +642,7 @@ nsresult nsEudoraCompose::SendTheMessage( nsIFileSpec *pMsg) // what about all of the other headers?!?!?!?!?!?! char *pMimeType = nsnull; if (bodyType.Length()) - pMimeType = bodyType.ToNewCString(); + pMimeType = ToNewCString(bodyType); // IMPORT_LOG0( "Outlook compose calling CreateAndSendMessage\n"); nsMsgAttachedFile *pAttach = GetLocalAttachments(); diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp index a463359101b..6b786da2ae1 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraImport.cpp @@ -47,6 +47,7 @@ #include "nsEudoraStringBundle.h" #include "nsIStringBundle.h" #include "nsEudoraSettings.h" +#include "nsReadableUtils.h" #ifdef XP_PC @@ -225,7 +226,7 @@ NS_IMETHODIMP nsEudoraImport::GetName( PRUnichar **name) return NS_ERROR_NULL_POINTER; // nsString title = "Outlook Express"; - // *name = title.ToNewUnicode(); + // *name = ToNewUnicode(title); *name = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NAME); return NS_OK; @@ -238,7 +239,7 @@ NS_IMETHODIMP nsEudoraImport::GetDescription( PRUnichar **name) return NS_ERROR_NULL_POINTER; // nsString desc = "Outlook Express mail and address books"; - // *name = desc.ToNewUnicode(); + // *name = ToNewUnicode(desc); *name = nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_DESCRIPTION); return NS_OK; @@ -452,9 +453,9 @@ void ImportEudoraMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsStri void ImportEudoraMailImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess) { if (pError) - *pError = error.ToNewUnicode(); + *pError = ToNewUnicode(error); if (pSuccess) - *pSuccess = success.ToNewUnicode(); + *pSuccess = ToNewUnicode(success); } NS_IMETHODIMP ImportEudoraMailImpl::ImportMailbox( nsIImportMailboxDescriptor *pSource, @@ -590,7 +591,7 @@ NS_IMETHODIMP ImportEudoraAddressImpl::GetAutoFind(PRUnichar **description, PRBo nsString str; *_retval = PR_FALSE; nsEudoraStringBundle::GetStringByID( EUDORAIMPORT_NICKNAMES_NAME, str); - *description = str.ToNewUnicode(); + *description = ToNewUnicode(str); return( NS_OK); } diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraMac.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraMac.cpp index d9d8d73993f..54f2f5a7343 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraMac.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraMac.cpp @@ -36,6 +36,7 @@ #include "nsEudoraStringBundle.h" #include "nsEudoraImport.h" #include "nsIPop3IncomingServer.h" +#include "nsReadableUtils.h" #include "EudoraDebugLog.h" @@ -712,7 +713,7 @@ PRBool nsEudoraMac::BuildPOPAccount( nsIMsgAccountManager *accMgr, nsCString **p IMPORT_LOG2( "Created POP3 server named: %s, userName: %s\n", (const char *)(*(pStrs[kPopServerStr])), (const char *)(*(pStrs[kPopAccountNameStr]))); - PRUnichar *pretty = accName.ToNewUnicode(); + PRUnichar *pretty = ToNewUnicode(accName); IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty); rv = in->SetPrettyName( pretty); nsCRT::free( pretty); @@ -764,7 +765,7 @@ PRBool nsEudoraMac::BuildIMAPAccount( nsIMsgAccountManager *accMgr, nsCString ** IMPORT_LOG2( "Created IMAP server named: %s, userName: %s\n", (const char *)(*(pStrs[kPopServerStr])), (const char *)(*(pStrs[kPopAccountNameStr]))); - PRUnichar *pretty = accName.ToNewUnicode(); + PRUnichar *pretty = ToNewUnicode(accName); IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty); diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraMailbox.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraMailbox.cpp index e17df3fe9e1..939d4137de2 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraMailbox.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraMailbox.cpp @@ -20,6 +20,7 @@ */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsEudoraMailbox.h" #include "nsSpecialSystemDirectory.h" #include "nsEudoraCompose.h" @@ -1028,7 +1029,7 @@ PRBool nsEudoraMailbox::AddAttachment( nsCString& fileName) } ImportAttachment *a = new ImportAttachment; - a->mimeType = mimeType.ToNewCString(); + a->mimeType = ToNewCString(mimeType); a->description = nsCRT::strdup( "Attached File"); a->pAttachment = pSpec; diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraStringBundle.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraStringBundle.cpp index 995b0d7064e..0cb72e702b9 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraStringBundle.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraStringBundle.cpp @@ -19,6 +19,7 @@ #include "prprf.h" #include "prmem.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsEudoraStringBundle.h" #include "nsIServiceManager.h" @@ -97,7 +98,7 @@ PRUnichar *nsEudoraStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle resultString.AppendInt(stringID, 10); resultString.AppendWithConversion("?]"); - return( resultString.ToNewUnicode()); + return ToNewUnicode(resultString); } void nsEudoraStringBundle::Cleanup( void) diff --git a/mozilla/mailnews/import/eudora/src/nsEudoraWin32.cpp b/mozilla/mailnews/import/eudora/src/nsEudoraWin32.cpp index b65167261e9..8e50268cb1d 100644 --- a/mozilla/mailnews/import/eudora/src/nsEudoraWin32.cpp +++ b/mozilla/mailnews/import/eudora/src/nsEudoraWin32.cpp @@ -20,6 +20,7 @@ */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIMsgAccountManager.h" @@ -747,7 +748,7 @@ PRBool nsEudoraWin32::BuildPOPAccount( nsIMsgAccountManager *accMgr, const char nsString prettyName; GetAccountName( pSection, prettyName); - PRUnichar *pretty = prettyName.ToNewUnicode(); + PRUnichar *pretty = ToNewUnicode(prettyName); IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty); rv = in->SetPrettyName( pretty); nsCRT::free( pretty); @@ -808,7 +809,7 @@ PRBool nsEudoraWin32::BuildIMAPAccount( nsIMsgAccountManager *accMgr, const char nsString prettyName; GetAccountName( pSection, prettyName); - PRUnichar *pretty = prettyName.ToNewUnicode(); + PRUnichar *pretty = ToNewUnicode(prettyName); IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty); diff --git a/mozilla/mailnews/import/oexpress/nsOEAddressIterator.cpp b/mozilla/mailnews/import/oexpress/nsOEAddressIterator.cpp index 162402500b9..b60489bd986 100644 --- a/mozilla/mailnews/import/oexpress/nsOEAddressIterator.cpp +++ b/mozilla/mailnews/import/oexpress/nsOEAddressIterator.cpp @@ -46,6 +46,7 @@ #include "nsCRT.h" #include "nsCOMPtr.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIImportService.h" @@ -246,28 +247,22 @@ PRBool nsOEAddressIterator::BuildCard( const PRUnichar * pName, nsIMdbRow *newRo } } - char *pCStr; // We now have the required fields // write them out followed by any optional fields! if (!displayName.IsEmpty()) { - m_database->AddDisplayName( newRow, pCStr = displayName.ToNewUTF8String()); - nsCRT::free( pCStr); + m_database->AddDisplayName( newRow, NS_ConvertUCS2toUTF8(displayName).get()); } if (!firstName.IsEmpty()) { - m_database->AddFirstName( newRow, pCStr = firstName.ToNewUTF8String()); - nsCRT::free( pCStr); + m_database->AddFirstName( newRow, NS_ConvertUCS2toUTF8(firstName).get()); } if (!lastName.IsEmpty()) { - m_database->AddLastName( newRow, pCStr = lastName.ToNewUTF8String()); - nsCRT::free( pCStr); + m_database->AddLastName( newRow, NS_ConvertUCS2toUTF8(lastName).get()); } if (!nickName.IsEmpty()) { - m_database->AddNickName( newRow, pCStr = nickName.ToNewUTF8String()); - nsCRT::free( pCStr); + m_database->AddNickName( newRow, NS_ConvertUCS2toUTF8(nickName).get()); } if (!eMail.IsEmpty()) { - m_database->AddPrimaryEmail( newRow, pCStr = eMail.ToNewUTF8String()); - nsCRT::free( pCStr); + m_database->AddPrimaryEmail( newRow, NS_ConvertUCS2toUTF8(eMail).get()); } // Do all of the extra fields! diff --git a/mozilla/mailnews/import/oexpress/nsOEImport.cpp b/mozilla/mailnews/import/oexpress/nsOEImport.cpp index 7501a6ab580..9b5583ab27d 100644 --- a/mozilla/mailnews/import/oexpress/nsOEImport.cpp +++ b/mozilla/mailnews/import/oexpress/nsOEImport.cpp @@ -45,6 +45,7 @@ #include "nscore.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIImportService.h" #include "nsOEImport.h" @@ -202,7 +203,7 @@ NS_IMETHODIMP nsOEImport::GetName( PRUnichar **name) return NS_ERROR_NULL_POINTER; // nsString title = "Outlook Express"; - // *name = title.ToNewUnicode(); + // *name = ToNewUnicode(title); *name = nsOEStringBundle::GetStringByID( OEIMPORT_NAME); return NS_OK; @@ -215,7 +216,7 @@ NS_IMETHODIMP nsOEImport::GetDescription( PRUnichar **name) return NS_ERROR_NULL_POINTER; // nsString desc = "Outlook Express mail and address books"; - // *name = desc.ToNewUnicode(); + // *name = ToNewUnicode(desc); *name = nsOEStringBundle::GetStringByID( OEIMPORT_DESCRIPTION); return NS_OK; @@ -426,9 +427,9 @@ void ImportOEMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsString * void ImportOEMailImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess) { if (pError) - *pError = error.ToNewUnicode(); + *pError = ToNewUnicode(error); if (pSuccess) - *pSuccess = success.ToNewUnicode(); + *pSuccess = ToNewUnicode(success); } NS_IMETHODIMP ImportOEMailImpl::ImportMailbox( nsIImportMailboxDescriptor *pSource, @@ -567,7 +568,7 @@ NS_IMETHODIMP ImportOEAddressImpl::GetAutoFind(PRUnichar **description, PRBool * *_retval = PR_TRUE; nsString str; str.Append(nsOEStringBundle::GetStringByID(OEIMPORT_AUTOFIND)); - *description = str.ToNewUnicode(); + *description = ToNewUnicode(str); return( NS_OK); } diff --git a/mozilla/mailnews/import/oexpress/nsOESettings.cpp b/mozilla/mailnews/import/oexpress/nsOESettings.cpp index e055bd753fe..6f1c3c1578a 100644 --- a/mozilla/mailnews/import/oexpress/nsOESettings.cpp +++ b/mozilla/mailnews/import/oexpress/nsOESettings.cpp @@ -44,6 +44,7 @@ #include "nsCOMPtr.h" #include "nscore.h" +#include "nsReadableUtils.h" #include "nsOEImport.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" @@ -358,7 +359,7 @@ PRBool OESettings::DoIMAPServer( nsIMsgAccountManager *pMgr, HKEY hKey, char *pS else prettyName.AssignWithConversion((const char *)pServerName); - PRUnichar *pretty = prettyName.ToNewUnicode(); + PRUnichar *pretty = ToNewUnicode(prettyName); IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty); @@ -423,7 +424,7 @@ PRBool OESettings::DoPOP3Server( nsIMsgAccountManager *pMgr, HKEY hKey, char *pS else prettyName.AssignWithConversion((const char *)pServerName); - PRUnichar *pretty = prettyName.ToNewUnicode(); + PRUnichar *pretty = ToNewUnicode(prettyName); IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty); @@ -488,7 +489,7 @@ PRBool OESettings::IdentityMatches( nsIMsgIdentity *pIdent, const char *pName, c if (ppIName) { nsString name(ppIName); nsCRT::free( ppIName); - pIName = name.ToNewCString(); + pIName = ToNewCString(name); } // for now, if it's the same server and reply to and email then it matches diff --git a/mozilla/mailnews/import/oexpress/nsOEStringBundle.cpp b/mozilla/mailnews/import/oexpress/nsOEStringBundle.cpp index 70eaf16bed1..5b43fa93f96 100644 --- a/mozilla/mailnews/import/oexpress/nsOEStringBundle.cpp +++ b/mozilla/mailnews/import/oexpress/nsOEStringBundle.cpp @@ -37,6 +37,7 @@ #include "prprf.h" #include "prmem.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsOEStringBundle.h" #include "nsIServiceManager.h" @@ -117,7 +118,7 @@ PRUnichar *nsOEStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle *pB resultString.AppendInt(stringID, 10); resultString.AppendWithConversion("?]"); - return( resultString.ToNewUnicode()); + return( ToNewUnicode(resultString)); } void nsOEStringBundle::Cleanup( void) diff --git a/mozilla/mailnews/import/outlook/src/MapiApi.cpp b/mozilla/mailnews/import/outlook/src/MapiApi.cpp index 1f9b5fd89f0..057b135cf2e 100644 --- a/mozilla/mailnews/import/outlook/src/MapiApi.cpp +++ b/mozilla/mailnews/import/outlook/src/MapiApi.cpp @@ -40,6 +40,7 @@ #include "nsCRT.h" #include "prprf.h" +#include "nsReadableUtils.h" int CMapiApi::m_clients = 0; @@ -1602,13 +1603,13 @@ void CMapiFolderList::DumpList( void) nsCRT::memset( prefix, ' ', depth); prefix[depth] = 0; #ifdef MAPI_DEBUG - char *ansiStr = str.ToNewCString(); + char *ansiStr = ToNewCString(str); MAPI_TRACE2( "%s%s: ", prefix, ansiStr); nsCRT::free(ansiStr); #endif pFolder->GetFilePath( str); #ifdef MAPI_DEBUG - ansiStr = str.ToNewCString(); + ansiStr = ToNewCString(str); MAPI_TRACE2( "depth=%d, filePath=%s\n", pFolder->GetDepth(), ansiStr); nsCRT::free(ansiStr); #endif diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookCompose.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookCompose.cpp index 4aab91505b4..41f69193403 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookCompose.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookCompose.cpp @@ -20,6 +20,7 @@ #include "nscore.h" #include "prthread.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsIFileSpec.h" #include "nsIComponentManager.h" @@ -616,7 +617,7 @@ nsresult nsOutlookCompose::SendTheMessage( nsIFileSpec *pMsg) // what about all of the other headers?!?!?!?!?!?! char *pMimeType = nsnull; if (bodyType.Length()) - pMimeType = bodyType.ToNewCString(); + pMimeType = ToNewCString(bodyType); // IMPORT_LOG0( "Outlook compose calling CreateAndSendMessage\n"); nsMsgAttachedFile *pAttach = GetLocalAttachments(); diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp index 9c4042c36f7..5ccf530d5ab 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookImport.cpp @@ -45,6 +45,7 @@ #include "nscore.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIImportService.h" #include "nsIComponentManager.h" @@ -205,7 +206,7 @@ NS_IMETHODIMP nsOutlookImport::GetName( PRUnichar **name) return NS_ERROR_NULL_POINTER; // nsString title = "Outlook Express"; - // *name = title.ToNewUnicode(); + // *name = ToNewUnicode(title); *name = nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_NAME); return NS_OK; @@ -218,7 +219,7 @@ NS_IMETHODIMP nsOutlookImport::GetDescription( PRUnichar **name) return NS_ERROR_NULL_POINTER; // nsString desc = "Outlook Express mail and address books"; - // *name = desc.ToNewUnicode(); + // *name = ToNewUnicode(desc); *name = nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_DESCRIPTION); return NS_OK; @@ -431,9 +432,9 @@ void ImportOutlookMailImpl::ReportError( PRInt32 errorNum, nsString& name, nsStr void ImportOutlookMailImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess) { if (pError) - *pError = error.ToNewUnicode(); + *pError = ToNewUnicode(error); if (pSuccess) - *pSuccess = success.ToNewUnicode(); + *pSuccess = ToNewUnicode(success); } NS_IMETHODIMP ImportOutlookMailImpl::ImportMailbox( nsIImportMailboxDescriptor *pSource, @@ -549,7 +550,7 @@ NS_IMETHODIMP ImportOutlookAddressImpl::GetAutoFind(PRUnichar **description, PRB *_retval = PR_TRUE; nsString str; nsOutlookStringBundle::GetStringByID( OUTLOOKIMPORT_ADDRNAME, str); - *description = str.ToNewUnicode(); + *description = ToNewUnicode(str); return( NS_OK); } diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp index 5f50c7387ea..5cd62ec2ae0 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookMail.cpp @@ -49,6 +49,7 @@ #include "nsIImportABDescriptor.h" #include "nsIImportMimeEncode.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsOutlookStringBundle.h" #include "nsABBaseCID.h" #include "nsIAbCard.h" @@ -1091,32 +1092,25 @@ PRBool nsOutlookMail::BuildCard( const PRUnichar *pName, nsIAddrDatabase *pDb, n } } - char *pCStr; // We now have the required fields // write them out followed by any optional fields! if (!displayName.IsEmpty()) { - pDb->AddDisplayName( newRow, pCStr = displayName.ToNewUTF8String()); - nsCRT::free( pCStr); + pDb->AddDisplayName( newRow, NS_ConvertUCS2toUTF8(displayName).get()); } if (!firstName.IsEmpty()) { - pDb->AddFirstName( newRow, pCStr = firstName.ToNewUTF8String()); - nsCRT::free( pCStr); + pDb->AddFirstName( newRow, NS_ConvertUCS2toUTF8(firstName).get()); } if (!lastName.IsEmpty()) { - pDb->AddLastName( newRow, pCStr = lastName.ToNewUTF8String()); - nsCRT::free( pCStr); + pDb->AddLastName( newRow, NS_ConvertUCS2toUTF8(lastName).get()); } if (!nickName.IsEmpty()) { - pDb->AddNickName( newRow, pCStr = nickName.ToNewUTF8String()); - nsCRT::free( pCStr); + pDb->AddNickName( newRow, NS_ConvertUCS2toUTF8(nickName).get()); } if (!eMail.IsEmpty()) { - pDb->AddPrimaryEmail( newRow, pCStr = eMail.ToNewUTF8String()); - nsCRT::free( pCStr); + pDb->AddPrimaryEmail( newRow, NS_ConvertUCS2toUTF8(eMail).get()); } if (!secondEMail.IsEmpty()) { - pDb->Add2ndEmail( newRow, pCStr = secondEMail.ToNewUTF8String()); - nsCRT::free( pCStr); + pDb->Add2ndEmail( newRow, NS_ConvertUCS2toUTF8(secondEMail).get()); } // Do all of the extra fields! diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookSettings.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookSettings.cpp index f6bcd2b0fb8..12dfa982e3c 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookSettings.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookSettings.cpp @@ -44,6 +44,7 @@ #include "nsCOMPtr.h" #include "nscore.h" +#include "nsReadableUtils.h" #include "nsOutlookImport.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" @@ -315,7 +316,7 @@ PRBool OutlookSettings::DoIMAPServer( nsIMsgAccountManager *pMgr, HKEY hKey, cha else prettyName.AssignWithConversion((const char *)pServerName); - PRUnichar *pretty = prettyName.ToNewUnicode(); + PRUnichar *pretty = ToNewUnicode(prettyName); IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty); @@ -380,7 +381,7 @@ PRBool OutlookSettings::DoPOP3Server( nsIMsgAccountManager *pMgr, HKEY hKey, cha else prettyName.AssignWithConversion((const char *)pServerName); - PRUnichar *pretty = prettyName.ToNewUnicode(); + PRUnichar *pretty = ToNewUnicode(prettyName); IMPORT_LOG1( "\tSet pretty name to: %S\n", pretty); @@ -447,7 +448,7 @@ PRBool OutlookSettings::IdentityMatches( nsIMsgIdentity *pIdent, const char *pNa if (ppIName) { nsString name(ppIName); nsCRT::free( ppIName); - pIName = name.ToNewCString(); + pIName = ToNewCString(name); } // for now, if it's the same server and reply to and email then it matches diff --git a/mozilla/mailnews/import/outlook/src/nsOutlookStringBundle.cpp b/mozilla/mailnews/import/outlook/src/nsOutlookStringBundle.cpp index 1e1f8fa1965..a6954414b12 100644 --- a/mozilla/mailnews/import/outlook/src/nsOutlookStringBundle.cpp +++ b/mozilla/mailnews/import/outlook/src/nsOutlookStringBundle.cpp @@ -37,6 +37,7 @@ #include "prprf.h" #include "prmem.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsOutlookStringBundle.h" #include "nsIServiceManager.h" @@ -117,7 +118,7 @@ PRUnichar *nsOutlookStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundl resultString.AppendInt(stringID, 10); resultString.AppendWithConversion("?]"); - return( resultString.ToNewUnicode()); + return ToNewUnicode(resultString); } void nsOutlookStringBundle::Cleanup( void) diff --git a/mozilla/mailnews/import/src/nsImportABDescriptor.h b/mozilla/mailnews/import/src/nsImportABDescriptor.h index df5d1a48158..ddf1b7d955f 100644 --- a/mozilla/mailnews/import/src/nsImportABDescriptor.h +++ b/mozilla/mailnews/import/src/nsImportABDescriptor.h @@ -40,6 +40,7 @@ #include "nscore.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIImportABDescriptor.h" #include "nsIFileSpec.h" @@ -63,7 +64,7 @@ public: NS_IMETHOD SetSize( PRUint32 theSize) { m_size = theSize; return( NS_OK);} /* attribute wstring displayName; */ - NS_IMETHOD GetPreferredName( PRUnichar **pName) { *pName = m_displayName.ToNewUnicode(); return( NS_OK);} + NS_IMETHOD GetPreferredName( PRUnichar **pName) { *pName = ToNewUnicode(m_displayName); return( NS_OK);} NS_IMETHOD SetPreferredName( const PRUnichar * pName) { m_displayName = pName; return( NS_OK);} /* readonly attribute nsIFileSpec fileSpec; */ diff --git a/mozilla/mailnews/import/src/nsImportFieldMap.cpp b/mozilla/mailnews/import/src/nsImportFieldMap.cpp index 29b07907eb1..f46a7d939a6 100644 --- a/mozilla/mailnews/import/src/nsImportFieldMap.cpp +++ b/mozilla/mailnews/import/src/nsImportFieldMap.cpp @@ -41,6 +41,7 @@ #include "nsIStringBundle.h" #include "nsImportFieldMap.h" #include "nsImportStringBundle.h" +#include "nsReadableUtils.h" #include "ImportDebug.h" @@ -138,7 +139,7 @@ NS_IMETHODIMP nsImportFieldMap::GetFieldDescription(PRInt32 index, PRUnichar **_ if ((index < 0) || (index >= m_descriptions.Count())) return( NS_ERROR_FAILURE); - *_retval = ((nsString *)m_descriptions.ElementAt( index))->ToNewUnicode(); + *_retval = ToNewUnicode(*((nsString *)m_descriptions.ElementAt(index))); return( NS_OK); } @@ -257,7 +258,7 @@ NS_IMETHODIMP nsImportFieldMap::SetFieldValue(nsIAddrDatabase *database, nsIMdbR nsresult rv; nsString str(value); - char *pVal = str.ToNewUTF8String(); + char *pVal = ToNewUTF8String(str); switch( fieldNum) { case 0: diff --git a/mozilla/mailnews/import/src/nsImportMailboxDescriptor.h b/mozilla/mailnews/import/src/nsImportMailboxDescriptor.h index 4c9aca40254..8e928fbcc04 100644 --- a/mozilla/mailnews/import/src/nsImportMailboxDescriptor.h +++ b/mozilla/mailnews/import/src/nsImportMailboxDescriptor.h @@ -39,6 +39,7 @@ #define nsImportMailboxDescriptor_h___ #include "nscore.h" +#include "nsReadableUtils.h" #include "nsIImportMailboxDescriptor.h" #include "nsIFileSpec.h" @@ -62,7 +63,7 @@ public: NS_IMETHOD SetSize( PRUint32 theSize) { m_size = theSize; return( NS_OK);} /* attribute wstring displayName; */ - NS_IMETHOD GetDisplayName( PRUnichar **pName) { *pName = m_displayName.ToNewUnicode(); return( NS_OK);} + NS_IMETHOD GetDisplayName( PRUnichar **pName) { *pName = ToNewUnicode(m_displayName); return( NS_OK);} NS_IMETHOD SetDisplayName( const PRUnichar * pName) { m_displayName = pName; return( NS_OK);} /* attribute boolean import; */ diff --git a/mozilla/mailnews/import/src/nsImportStringBundle.cpp b/mozilla/mailnews/import/src/nsImportStringBundle.cpp index 2ab1b7ceafd..e5b1cbd603d 100644 --- a/mozilla/mailnews/import/src/nsImportStringBundle.cpp +++ b/mozilla/mailnews/import/src/nsImportStringBundle.cpp @@ -37,6 +37,7 @@ #include "prprf.h" #include "prmem.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsImportStringBundle.h" #include "nsIServiceManager.h" @@ -115,7 +116,7 @@ PRUnichar *nsImportStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle resultString.AppendInt(stringID, 10); resultString.AppendWithConversion("?]"); - return( resultString.ToNewUnicode()); + return( ToNewUnicode(resultString)); } void nsImportStringBundle::Cleanup( void) diff --git a/mozilla/mailnews/import/text/src/nsTextAddress.cpp b/mozilla/mailnews/import/text/src/nsTextAddress.cpp index 20f0e519831..3dd7ed283b0 100644 --- a/mozilla/mailnews/import/text/src/nsTextAddress.cpp +++ b/mozilla/mailnews/import/text/src/nsTextAddress.cpp @@ -24,6 +24,7 @@ #include "nsIAddrDatabase.h" #include "nsAbBaseCID.h" #include "nsIAbCard.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kAbCardPropertyCID, NS_ABCARDPROPERTY_CID); static NS_DEFINE_CID(kImportServiceCID, NS_IMPORTSERVICE_CID); @@ -966,7 +967,7 @@ void nsTextAddress::AddLdifRowToDatabase(PRBool bIsList) else return; - char* cursor = (char*)m_ldifLine.ToNewCString(); + char* cursor = ToNewCString(m_ldifLine); char* saveCursor = cursor; /* keep for deleting */ char* line = 0; char* typeSlot = 0; diff --git a/mozilla/mailnews/import/text/src/nsTextImport.cpp b/mozilla/mailnews/import/text/src/nsTextImport.cpp index 0cb77f7fa21..102424bdb6d 100644 --- a/mozilla/mailnews/import/text/src/nsTextImport.cpp +++ b/mozilla/mailnews/import/text/src/nsTextImport.cpp @@ -28,6 +28,7 @@ #include "nscore.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIImportService.h" #include "nsIComponentManager.h" @@ -277,7 +278,7 @@ NS_IMETHODIMP ImportAddressImpl::GetAutoFind(PRUnichar **addrDescription, PRBool nsString str; *_retval = PR_FALSE; nsTextStringBundle::GetStringByID( TEXTIMPORT_ADDRESS_NAME, str); - *addrDescription = str.ToNewUnicode(); + *addrDescription = ToNewUnicode(str); return( NS_OK); } @@ -431,9 +432,9 @@ void ImportAddressImpl::ReportError( PRInt32 errorNum, nsString& name, nsString void ImportAddressImpl::SetLogs( nsString& success, nsString& error, PRUnichar **pError, PRUnichar **pSuccess) { if (pError) - *pError = error.ToNewUnicode(); + *pError = ToNewUnicode(error); if (pSuccess) - *pSuccess = success.ToNewUnicode(); + *pSuccess = ToNewUnicode(success); } diff --git a/mozilla/mailnews/import/text/src/nsTextStringBundle.cpp b/mozilla/mailnews/import/text/src/nsTextStringBundle.cpp index 96af4fd54ac..36ce20caa5e 100644 --- a/mozilla/mailnews/import/text/src/nsTextStringBundle.cpp +++ b/mozilla/mailnews/import/text/src/nsTextStringBundle.cpp @@ -19,6 +19,7 @@ #include "prprf.h" #include "prmem.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsTextStringBundle.h" #include "nsIServiceManager.h" @@ -98,7 +99,7 @@ PRUnichar *nsTextStringBundle::GetStringByID(PRInt32 stringID, nsIStringBundle * resultString.AppendInt(stringID, 10); resultString.AppendWithConversion("?]"); - return( resultString.ToNewUnicode()); + return ToNewUnicode(resultString); } void nsTextStringBundle::Cleanup( void) diff --git a/mozilla/mailnews/local/src/nsLocalMailFolder.cpp b/mozilla/mailnews/local/src/nsLocalMailFolder.cpp index 0ebcb592598..57eb7b6c54c 100644 --- a/mozilla/mailnews/local/src/nsLocalMailFolder.cpp +++ b/mozilla/mailnews/local/src/nsLocalMailFolder.cpp @@ -81,6 +81,7 @@ #include "nsMsgBaseCID.h" #include "nsMsgLocalCID.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsLocalFolderSummarySpec.h" #include "nsMsgUtils.h" #include "nsICopyMsgStreamListener.h" @@ -650,7 +651,7 @@ NS_IMETHODIMP nsMsgLocalMailFolder::GetFolderURL(char **url) nsCAutoString urlStr(urlScheme); urlStr.Append(tmpPath); - *url = urlStr.ToNewCString(); + *url = ToNewCString(urlStr); return NS_OK; } diff --git a/mozilla/mailnews/local/src/nsLocalUtils.cpp b/mozilla/mailnews/local/src/nsLocalUtils.cpp index 28057773a73..8b8d29f4b30 100644 --- a/mozilla/mailnews/local/src/nsLocalUtils.cpp +++ b/mozilla/mailnews/local/src/nsLocalUtils.cpp @@ -40,6 +40,7 @@ #include "nsIServiceManager.h" #include "prsystem.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsEscape.h" #include "nsIFileSpec.h" @@ -315,7 +316,7 @@ nsresult nsCreateLocalBaseMessageURI(const char *baseURI, char **baseMessageURI) nsCAutoString baseURIStr(kMailboxMessageRootURI); baseURIStr += tailURI; - *baseMessageURI = baseURIStr.ToNewCString(); + *baseMessageURI = ToNewCString(baseURIStr); if(!*baseMessageURI) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/mailnews/local/src/nsMailboxUrl.cpp b/mozilla/mailnews/local/src/nsMailboxUrl.cpp index caf75fca094..163076a518e 100644 --- a/mozilla/mailnews/local/src/nsMailboxUrl.cpp +++ b/mozilla/mailnews/local/src/nsMailboxUrl.cpp @@ -43,6 +43,7 @@ #include "nsMailboxUrl.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsEscape.h" #include "nsCRT.h" #include "nsLocalUtils.h" @@ -251,7 +252,7 @@ NS_IMETHODIMP nsMailboxUrl::GetUri(char ** aURI) // otherwise try to reconstruct a URI on the fly.... if (!mURI.IsEmpty()) - *aURI = mURI.ToNewCString(); + *aURI = ToNewCString(mURI); else { nsFileSpec * filePath = nsnull; @@ -267,7 +268,7 @@ NS_IMETHODIMP nsMailboxUrl::GetUri(char ** aURI) nsBuildLocalMessageURI(baseMessageURI, m_messageKey, uriStr); PL_strfree(baseuri); nsCRT::free(baseMessageURI); - uri = uriStr.ToNewCString(); + uri = ToNewCString(uriStr); *aURI = uri; } else @@ -505,7 +506,7 @@ NS_IMETHODIMP nsMailboxUrl::GetFolderCharsetOverride(PRBool * aCharacterSetOverr NS_IMETHODIMP nsMailboxUrl::GetCharsetOverRide(PRUnichar ** aCharacterSet) { if (!mCharsetOverride.IsEmpty()) - *aCharacterSet = mCharsetOverride.ToNewUnicode(); + *aCharacterSet = ToNewUnicode(mCharsetOverride); else *aCharacterSet = nsnull; return NS_OK; diff --git a/mozilla/mailnews/local/src/nsPop3Sink.cpp b/mozilla/mailnews/local/src/nsPop3Sink.cpp index 5c383ee4841..5f1252889ff 100644 --- a/mozilla/mailnews/local/src/nsPop3Sink.cpp +++ b/mozilla/mailnews/local/src/nsPop3Sink.cpp @@ -50,6 +50,7 @@ #include "nsLocalUtils.h" #include "nsMsgLocalFolderHdrs.h" #include "nsIMsgFolder.h" // TO include biffState enum. Change to bool later... +#include "nsReadableUtils.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsPop3Sink, nsIPop3Sink) @@ -561,7 +562,7 @@ nsPop3Sink::GetMessageUri(char **messageUri) { if (!messageUri || m_messageUri.Length() <= 0) return NS_ERROR_NULL_POINTER; - *messageUri = m_messageUri.ToNewCString(); + *messageUri = ToNewCString(m_messageUri); return NS_OK; } diff --git a/mozilla/mailnews/local/src/nsPop3URL.cpp b/mozilla/mailnews/local/src/nsPop3URL.cpp index 937d4bb62d2..19c1c099ae4 100644 --- a/mozilla/mailnews/local/src/nsPop3URL.cpp +++ b/mozilla/mailnews/local/src/nsPop3URL.cpp @@ -41,6 +41,7 @@ #include "nsPop3URL.h" #include "nsPop3Protocol.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prmem.h" #include "plstr.h" #include "prprf.h" @@ -83,7 +84,7 @@ nsPop3URL::GetMessageUri(char ** aMessageUri) { if(!aMessageUri || m_messageUri.Length() == 0) return NS_ERROR_NULL_POINTER; - *aMessageUri = m_messageUri.ToNewCString(); + *aMessageUri = ToNewCString(m_messageUri); return NS_OK; } diff --git a/mozilla/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp b/mozilla/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp index 43091b43883..c97f140325b 100644 --- a/mozilla/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp +++ b/mozilla/mailnews/mime/cthandlers/smimestub/nsSMIMEStub.cpp @@ -42,6 +42,7 @@ #include "mimecth.h" #include "mimeobj.h" #include "nsCRT.h" +#include "nsReadableUtils.h" // String bundles... #include "nsIStringBundle.h" @@ -93,7 +94,7 @@ nsCOMPtr stringBundle = nsnull; nsAutoString v; v.Append(ptrv); PR_FREEIF(ptrv); - tempString = v.ToNewUTF8String(); + tempString = ToNewUTF8String(v); } } @@ -162,7 +163,7 @@ GenerateMessage(char** html) PR_FREEIF(tString); temp.Append("
"); - *html = temp.ToNewCString(); + *html = ToNewCString(temp); return 0; } diff --git a/mozilla/mailnews/mime/cthandlers/vcard/mimevcrd.cpp b/mozilla/mailnews/mime/cthandlers/vcard/mimevcrd.cpp index cfd34fa622f..595e2b9c2a8 100644 --- a/mozilla/mailnews/mime/cthandlers/vcard/mimevcrd.cpp +++ b/mozilla/mailnews/mime/cthandlers/vcard/mimevcrd.cpp @@ -55,6 +55,7 @@ #include "nsIURI.h" #include "nsMsgI18N.h" #include "nsMsgUtils.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsIPref.h" @@ -1898,7 +1899,7 @@ nsCOMPtr stringBundle = nsnull; nsAutoString v; v.Append(ptrv); PR_FREEIF(ptrv); - tempString = v.ToNewUTF8String(); + tempString = ToNewUTF8String(v); } } diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp index 528bb9fba08..3dd55b03cc4 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeBaseEmitter.cpp @@ -39,6 +39,7 @@ #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "stdio.h" #include "nsMimeBaseEmitter.h" #include "nsMailHeaders.h" @@ -236,7 +237,7 @@ nsMimeBaseEmitter::MimeGetStringByName(const char *aHeaderName) // This returns a UTF-8 string so the caller needs to perform a conversion // if this is used as UCS-2 (e.g. cannot do nsString(utfStr); // - return v.ToNewUTF8String(); + return ToNewUTF8String(v); } else { diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp index 0379a082590..e6b5c9c26cf 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeHtmlEmitter.cpp @@ -188,7 +188,6 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders() // and broadcast them to the header sink. However, we need to // convert our UTF-8 header values into unicode before // broadcasting them.... - nsXPIDLString unicodeHeaderValue; for (PRInt32 i=0; iCount(); i++) { @@ -219,11 +218,8 @@ NS_IMETHODIMP nsMimeHtmlDisplayEmitter::WriteHTMLHeaders() } else { - // Convert UTF-8 to UCS2 - unicodeHeaderValue.Adopt(NS_ConvertUTF8toUCS2(headerValue).ToNewUnicode()); - if (NS_SUCCEEDED(rv)) - headerSink->HandleHeader(headerInfo->name, unicodeHeaderValue, bFromNewsgroups); + headerSink->HandleHeader(headerInfo->name, NS_ConvertUTF8toUCS2(headerValue).get(), bFromNewsgroups); } } } @@ -287,7 +283,7 @@ nsresult nsMimeHtmlDisplayEmitter::GenerateDateString(const char * dateString, P formattedDateString); if (NS_SUCCEEDED(rv)) - *aDateString = formattedDateString.ToNewUnicode(); + *aDateString = ToNewUnicode(formattedDateString); return rv; } @@ -349,7 +345,7 @@ nsMimeHtmlDisplayEmitter::StartAttachment(const char *name, const char *contentT if (NS_FAILED(rv)) { - unicodeHeaderValue.Adopt(NS_ConvertUTF8toUCS2(name).ToNewUnicode()); + unicodeHeaderValue.Adopt(ToNewUnicode(NS_ConvertUTF8toUCS2(name))); // but it's not really a failure if we didn't have a converter in the first place if ( !mUnicodeConverter ) diff --git a/mozilla/mailnews/mime/emitters/src/nsMimeXmlEmitter.cpp b/mozilla/mailnews/mime/emitters/src/nsMimeXmlEmitter.cpp index 6a06a03278c..0664dd45213 100644 --- a/mozilla/mailnews/mime/emitters/src/nsMimeXmlEmitter.cpp +++ b/mozilla/mailnews/mime/emitters/src/nsMimeXmlEmitter.cpp @@ -45,6 +45,7 @@ #include "prmem.h" #include "nsEmitterUtils.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" /* * nsMimeXmlEmitter definitions.... @@ -117,7 +118,7 @@ nsMimeXmlEmitter::WriteXMLTag(const char *tagName, const char *value) newTagName.CompressWhitespace(PR_TRUE, PR_TRUE); newTagName.ToUpperCase(); - upCaseTag = newTagName.ToNewCString(); + upCaseTag = ToNewCString(newTagName); UtilityWrite("
real_name = newAttachName.ToNewCString(); + aAttach->real_name = ToNewCString(newAttachName); } } @@ -1831,42 +1832,36 @@ char * MimeGetStringByID(PRInt32 stringID) { char *tempString = nsnull; - char *resultString = "???"; - nsresult res = NS_OK; + const char *resultString = "???"; + nsresult res = NS_OK; - if (!stringBundle) - { - char* propertyURL = NULL; + if (!stringBundle) + { + char* propertyURL = NULL; - propertyURL = MIME_URL; + propertyURL = MIME_URL; - nsCOMPtr sBundleService = - do_GetService(kStringBundleServiceCID, &res); - if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) - { - res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle)); - } - } - - if (stringBundle) - { - PRUnichar *ptrv = nsnull; - res = stringBundle->GetStringFromID(stringID, &ptrv); - - if (NS_FAILED(res)) - return nsCRT::strdup(resultString); - else + nsCOMPtr sBundleService = + do_GetService(kStringBundleServiceCID, &res); + if (NS_SUCCEEDED(res) && (nsnull != sBundleService)) { - nsAutoString v; - v = ptrv; - tempString = v.ToNewUTF8String(); + res = sBundleService->CreateBundle(propertyURL, getter_AddRefs(stringBundle)); } - } + } + + if (stringBundle) + { + nsXPIDLString v; + res = stringBundle->GetStringFromID(stringID, getter_Copies(v)); + + if (NS_SUCCEEDED(res)) + tempString = ToNewUTF8String(v); + } if (!tempString) - return nsCRT::strdup(resultString); - else - return tempString; + tempString = nsCRT::strdup(resultString); + + return tempString; } void PR_CALLBACK diff --git a/mozilla/mailnews/mime/src/mimetext.cpp b/mozilla/mailnews/mime/src/mimetext.cpp index a32fc1d5aa8..36126c44ce2 100644 --- a/mozilla/mailnews/mime/src/mimetext.cpp +++ b/mozilla/mailnews/mime/src/mimetext.cpp @@ -36,6 +36,7 @@ #include "nsIPref.h" #include "nsIServiceManager.h" #include "nsMimeTypes.h" +#include "nsReadableUtils.h" #define MIME_SUPERCLASS mimeLeafClass MimeDefClass(MimeInlineText, MimeInlineTextClass, mimeInlineTextClass, @@ -115,11 +116,10 @@ MimeInlineText_initialize (MimeObject *obj) nsCOMPtr prefs(do_GetService(kPrefServiceCID, &rv)); if ( NS_SUCCEEDED(rv) && prefs) { - PRUnichar* value; - rv = prefs->GetLocalizedUnicharPref("mailnews.view_default_charset", &value); + nsXPIDLString value; + rv = prefs->GetLocalizedUnicharPref("mailnews.view_default_charset", getter_Copies(value)); if(NS_SUCCEEDED(rv)) { - text->defaultCharset = NS_ConvertUCS2toUTF8(value).ToNewCString(); - nsMemory::Free(value); + text->defaultCharset = ToNewUTF8String(value); } } diff --git a/mozilla/mailnews/mime/src/mimetpfl.cpp b/mozilla/mailnews/mime/src/mimetpfl.cpp index 85e34faa563..a596c008b81 100644 --- a/mozilla/mailnews/mime/src/mimetpfl.cpp +++ b/mozilla/mailnews/mime/src/mimetpfl.cpp @@ -42,6 +42,7 @@ #include "plstr.h" #include "mozITXTToHTMLConv.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsMimeStringResources.h" #include "nsIPref.h" #include "nsIServiceManager.h" @@ -373,7 +374,7 @@ MimeInlineTextPlainFlowed_parse_line (char *line, PRInt32 length, MimeObject *ob // convert to unicode so it won't confuse ScanTXT. char *newcstr; - newcstr = lineSource.ToNewCString(); // lineSource uses nsString but the string is NOT unicode + newcstr = ToNewCString(lineSource); // lineSource uses nsString but the string is NOT unicode if (!newcstr) return -1; nsAutoString ustr; @@ -487,10 +488,10 @@ MimeInlineTextPlainFlowed_parse_line (char *line, PRInt32 length, MimeObject *ob if (!(exdata->isSig && quoting)) { - char* tmp = preface.ToNewCString(); + char* tmp = ToNewCString(preface); status = MimeObject_write(obj, tmp, preface.Length(), PR_TRUE); Recycle(tmp); - tmp = lineResult2.ToNewCString(); + tmp = ToNewCString(lineResult2); status = MimeObject_write(obj, tmp, lineResult2.Length(), PR_TRUE); Recycle(tmp); return status; diff --git a/mozilla/mailnews/mime/src/mimetpla.cpp b/mozilla/mailnews/mime/src/mimetpla.cpp index d7d9f9a267e..2409114f2ce 100644 --- a/mozilla/mailnews/mime/src/mimetpla.cpp +++ b/mozilla/mailnews/mime/src/mimetpla.cpp @@ -118,7 +118,7 @@ MimeTextBuildPrefixCSS(PRInt32 quotedSizeSetting, // mail.quoted_size formatString += ';'; } - formatCstr = formatString.ToNewCString(); + formatCstr = ToNewCString(formatString); return formatCstr; } diff --git a/mozilla/mailnews/mime/src/nsMimeConverter.cpp b/mozilla/mailnews/mime/src/nsMimeConverter.cpp index 2d7d8c7b9e7..d35d52ccbb3 100644 --- a/mozilla/mailnews/mime/src/nsMimeConverter.cpp +++ b/mozilla/mailnews/mime/src/nsMimeConverter.cpp @@ -43,6 +43,7 @@ #include "nsMsgI18N.h" #include "prmem.h" #include "plstr.h" +#include "nsReadableUtils.h" NS_IMPL_THREADSAFE_ADDREF(nsMimeConverter) NS_IMPL_THREADSAFE_RELEASE(nsMimeConverter) @@ -97,9 +98,9 @@ nsMimeConverter::DecodeMimeHeader(const char *header, decodedCstr = MIME_DecodeMimeHeader(header, default_charset, override_charset, eatContinuations); if (nsnull == decodedCstr) { - *decodedString = NS_ConvertUTF8toUCS2(header).ToNewUnicode(); + *decodedString = ToNewUnicode(NS_ConvertUTF8toUCS2(header)); } else { - *decodedString = NS_ConvertUTF8toUCS2(decodedCstr).ToNewUnicode(); + *decodedString = ToNewUnicode(NS_ConvertUTF8toUCS2(decodedCstr)); PR_FREEIF(decodedCstr); } if (!(*decodedString)) diff --git a/mozilla/mailnews/mime/src/nsMsgHeaderParser.cpp b/mozilla/mailnews/mime/src/nsMsgHeaderParser.cpp index 993ecb11f43..7e2646135ef 100644 --- a/mozilla/mailnews/mime/src/nsMsgHeaderParser.cpp +++ b/mozilla/mailnews/mime/src/nsMsgHeaderParser.cpp @@ -38,6 +38,7 @@ #include "msgCore.h" // precompiled header... #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMsgHeaderParser.h" #include "nsISimpleEnumerator.h" #include "comi18n.h" @@ -116,13 +117,13 @@ NS_IMETHODIMP nsMsgHeaderParserResult::GetAddressAndName(PRUnichar ** aAddress, if (aAddress) { result = MIME_DecodeMimeHeader(mCurrentAddress, NULL, PR_FALSE, PR_TRUE); - *aAddress = NS_ConvertUTF8toUCS2(result ? result : mCurrentAddress).ToNewUnicode(); + *aAddress = ToNewUnicode(NS_ConvertUTF8toUCS2(result ? result : mCurrentAddress)); PR_FREEIF(result); } if (aName) { result = MIME_DecodeMimeHeader(mCurrentName, NULL, PR_FALSE, PR_TRUE); - *aName = NS_ConvertUTF8toUCS2(result ? result : mCurrentName).ToNewUnicode(); + *aName = ToNewUnicode(NS_ConvertUTF8toUCS2(result ? result : mCurrentName)); PR_FREEIF(result); } if (aFullAddress) @@ -134,7 +135,7 @@ NS_IMETHODIMP nsMsgHeaderParserResult::GetAddressAndName(PRUnichar ** aAddress, if (NS_SUCCEEDED(rv) && (const char*)fullAddress) { result = MIME_DecodeMimeHeader(fullAddress, NULL, PR_FALSE, PR_TRUE); - *aFullAddress = NS_ConvertUTF8toUCS2(result ? result : (const char*)fullAddress).ToNewUnicode(); + *aFullAddress = ToNewUnicode(NS_ConvertUTF8toUCS2(result ? result : (const char*)fullAddress)); PR_FREEIF(result); } @@ -252,7 +253,7 @@ NS_IMETHODIMP nsMsgHeaderParser::ParseHeadersWithEnumerator(const PRUnichar *lin // need to convert unicode to UTF-8... nsAutoString tempString (line); - char * utf8String = tempString.ToNewUTF8String(); + char * utf8String = ToNewUTF8String(tempString); rv = ParseHeaderAddresses("UTF-8", utf8String, &names, &addresses, &numAddresses); nsCRT::free(utf8String); diff --git a/mozilla/mailnews/mime/src/nsStreamConverter.cpp b/mozilla/mailnews/mime/src/nsStreamConverter.cpp index b12d9e504d1..c2f71c951dd 100644 --- a/mozilla/mailnews/mime/src/nsStreamConverter.cpp +++ b/mozilla/mailnews/mime/src/nsStreamConverter.cpp @@ -51,6 +51,7 @@ #include "nsIComponentManager.h" #include "nsIURL.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsXPIDLString.h" #include "nsMemory.h" @@ -180,14 +181,14 @@ bridge_new_new_uri(void *bridgeStream, nsIURI *aURI, PRInt32 aOutputType) charset = uniCharset; if (NS_SUCCEEDED(rv) && !charset.IsEmpty() ) { *override_charset = PR_TRUE; - *default_charset = charset.ToNewCString(); + *default_charset = ToNewCString(charset); } else { i18nUrl->GetFolderCharset(getter_Copies(uniCharset)); charset = uniCharset; if (!charset.IsEmpty()) - *default_charset = charset.ToNewCString(); + *default_charset = ToNewCString(charset); } // if there is no manual override and a folder charset exists @@ -760,7 +761,7 @@ NS_IMETHODIMP nsStreamConverter::GetContentType(char **aOutputContentType) // and not nsCRT::strdup! // (1) check to see if we have a real content type...use it first... if (!mRealContentType.IsEmpty()) - *aOutputContentType = mRealContentType.ToNewCString(); + *aOutputContentType = ToNewCString(mRealContentType); else if (nsCRT::strcasecmp(mOutputFormat, "raw") == 0) *aOutputContentType = (char *) nsMemory::Clone(UNKNOWN_CONTENT_TYPE, nsCRT::strlen(UNKNOWN_CONTENT_TYPE) + 1); else diff --git a/mozilla/mailnews/news/src/nsNNTPProtocol.cpp b/mozilla/mailnews/news/src/nsNNTPProtocol.cpp index 9546328a4c9..1f82ce1e98d 100644 --- a/mozilla/mailnews/news/src/nsNNTPProtocol.cpp +++ b/mozilla/mailnews/news/src/nsNNTPProtocol.cpp @@ -58,6 +58,7 @@ #include "nsIMemory.h" #include "nsIPipe.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsMsgBaseCID.h" #include "nsMsgNewsCID.h" @@ -2650,25 +2651,25 @@ void nsNNTPProtocol::ParseHeaderForCancel(char *buf) case 'F': case 'f': if (header.Find("From",PR_TRUE) == 0) { PR_FREEIF(m_cancelFromHdr); - m_cancelFromHdr = value.ToNewCString(); + m_cancelFromHdr = ToNewCString(value); } break; case 'M': case 'm': if (header.Find("Message-ID",PR_TRUE) == 0) { PR_FREEIF(m_cancelID); - m_cancelID = value.ToNewCString(); + m_cancelID = ToNewCString(value); } break; case 'N': case 'n': if (header.Find("Newsgroups",PR_TRUE) == 0) { PR_FREEIF(m_cancelNewsgroups); - m_cancelNewsgroups = value.ToNewCString(); + m_cancelNewsgroups = ToNewCString(value); } break; case 'D': case 'd': if (header.Find("Distributions",PR_TRUE) == 0) { PR_FREEIF(m_cancelDistribution); - m_cancelDistribution = value.ToNewCString(); + m_cancelDistribution = ToNewCString(value); } break; } @@ -3679,7 +3680,7 @@ nsresult nsNNTPProtocol::GetNewsStringByID(PRInt32 stringID, PRUnichar **aString resultString.Assign(NS_LITERAL_STRING("[StringID")); resultString.AppendInt(stringID, 10); resultString.Append(NS_LITERAL_STRING("?]")); - *aString = resultString.ToNewUnicode(); + *aString = ToNewUnicode(resultString); } else { *aString = ptrv; @@ -3687,7 +3688,7 @@ nsresult nsNNTPProtocol::GetNewsStringByID(PRInt32 stringID, PRUnichar **aString } else { rv = NS_OK; - *aString = resultString.ToNewUnicode(); + *aString = ToNewUnicode(resultString); } return rv; } @@ -3718,7 +3719,7 @@ nsresult nsNNTPProtocol::GetNewsStringByName(const char *aName, PRUnichar **aStr resultString.Assign(NS_LITERAL_STRING("[StringName")); resultString.AppendWithConversion(aName); resultString.Append(NS_LITERAL_STRING("?]")); - *aString = resultString.ToNewUnicode(); + *aString = ToNewUnicode(resultString); } else { @@ -3728,7 +3729,7 @@ nsresult nsNNTPProtocol::GetNewsStringByName(const char *aName, PRUnichar **aStr else { rv = NS_OK; - *aString = resultString.ToNewUnicode(); + *aString = ToNewUnicode(resultString); } return rv; } @@ -5421,7 +5422,7 @@ NS_IMETHODIMP nsNNTPProtocol::GetContentType(char * *aContentType) // this happens when we go through libmime now as it sets our new content type if (!m_ContentType.IsEmpty()) { - *aContentType = m_ContentType.ToNewCString(); + *aContentType = ToNewCString(m_ContentType); return NS_OK; } diff --git a/mozilla/mailnews/news/src/nsNewsFolder.cpp b/mozilla/mailnews/news/src/nsNewsFolder.cpp index 6f3ab02e506..f3aa485f3a2 100644 --- a/mozilla/mailnews/news/src/nsNewsFolder.cpp +++ b/mozilla/mailnews/news/src/nsNewsFolder.cpp @@ -791,7 +791,7 @@ nsresult nsMsgNewsFolder::AbbreviatePrettyName(PRUnichar ** prettyName, PRInt32 // we are going to set *prettyName to something else, so free what was there PR_FREEIF(*prettyName); - *prettyName = out.ToNewUnicode(); + *prettyName = ToNewUnicode(out); return (*prettyName) ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/mailnews/news/src/nsNewsUtils.cpp b/mozilla/mailnews/news/src/nsNewsUtils.cpp index 0bf0c4da050..651cbc38a88 100644 --- a/mozilla/mailnews/news/src/nsNewsUtils.cpp +++ b/mozilla/mailnews/news/src/nsNewsUtils.cpp @@ -41,6 +41,7 @@ #include "nsIServiceManager.h" #include "prsystem.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIMsgAccountManager.h" #include "nsIMsgIncomingServer.h" #include "nsINntpIncomingServer.h" @@ -148,7 +149,7 @@ nsresult nsCreateNewsBaseMessageURI(const char *baseURI, char **baseMessageURI) nsCAutoString baseURIStr(kNewsMessageRootURI); baseURIStr += tailURI; - *baseMessageURI = baseURIStr.ToNewCString(); + *baseMessageURI = ToNewCString(baseURIStr); if(!*baseMessageURI) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/mailnews/news/src/nsNntpService.cpp b/mozilla/mailnews/news/src/nsNntpService.cpp index 59331b712d0..b64454cdb5d 100644 --- a/mozilla/mailnews/news/src/nsNntpService.cpp +++ b/mozilla/mailnews/news/src/nsNntpService.cpp @@ -47,6 +47,7 @@ #include "nsIMsgMailSession.h" #include "nsIMsgIdentity.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsNewsUtils.h" #include "nsNewsDatabase.h" #include "nsMsgDBCID.h" @@ -860,10 +861,10 @@ nsNntpService::GenerateNewsHeaderValsForPosting(const char *newsgroupsList, char } CRTFREEIF(list); - *newshostHeaderVal = host.ToNewCString(); + *newshostHeaderVal = ToNewCString(host); if (!*newshostHeaderVal) return NS_ERROR_OUT_OF_MEMORY; - *newsgroupsHeaderVal = newsgroups.ToNewCString(); + *newsgroupsHeaderVal = ToNewCString(newsgroups); if (!*newsgroupsHeaderVal) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; diff --git a/mozilla/mailnews/news/src/nsNntpUrl.cpp b/mozilla/mailnews/news/src/nsNntpUrl.cpp index 209f1838c76..079b183c088 100644 --- a/mozilla/mailnews/news/src/nsNntpUrl.cpp +++ b/mozilla/mailnews/news/src/nsNntpUrl.cpp @@ -43,6 +43,7 @@ #include "nsNntpUrl.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prmem.h" #include "plstr.h" #include "prprf.h" @@ -160,7 +161,7 @@ NS_IMETHODIMP nsNntpUrl::GetUri(char ** aURI) mURI = (const char *)spec; } - *aURI = mURI.ToNewCString(); + *aURI = ToNewCString(mURI); if (!*aURI) return NS_ERROR_OUT_OF_MEMORY; return rv; } @@ -313,7 +314,7 @@ NS_IMETHODIMP nsNntpUrl::GetFolderCharsetOverride(PRBool * aCharacterSetOverride NS_IMETHODIMP nsNntpUrl::GetCharsetOverRide(PRUnichar ** aCharacterSet) { if (!mCharsetOverride.IsEmpty()) - *aCharacterSet = mCharsetOverride.ToNewUnicode(); + *aCharacterSet = ToNewUnicode(mCharsetOverride); else *aCharacterSet = nsnull; return NS_OK; diff --git a/mozilla/modules/libjar/nsJAR.cpp b/mozilla/modules/libjar/nsJAR.cpp index b09c73abacc..f7a7d6f05a9 100644 --- a/mozilla/modules/libjar/nsJAR.cpp +++ b/mozilla/modules/libjar/nsJAR.cpp @@ -29,6 +29,7 @@ #include "nsJARInputStream.h" #include "nsJAR.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "plbase64.h" #include "nsIConsoleService.h" @@ -821,13 +822,10 @@ void nsJAR::ReportError(const char* aFilename, PRInt16 errorCode) nsCOMPtr console(do_GetService("@mozilla.org/consoleservice;1")); if (console) { - PRUnichar* messageUni = message.ToNewUnicode(); - if (!messageUni) return; - console->LogStringMessage(messageUni); - nsMemory::Free(messageUni); + console->LogStringMessage(message.get()); } #ifdef DEBUG - char* messageCstr = message.ToNewCString(); + char* messageCstr = ToNewCString(message); if (!messageCstr) return; fprintf(stderr, "%s\n", messageCstr); nsMemory::Free(messageCstr); @@ -903,7 +901,7 @@ PrintManItem(nsHashKey* aKey, void* aData, void* closure) if (manItem) { nsCStringKey* key2 = (nsCStringKey*)aKey; - char* name = key2->GetString().ToNewCString(); + char* name = ToNewCString(key2->GetString()); if (!(PL_strcmp(name, "") == 0)) printf("%s s=%i\n",name, manItem->status); } diff --git a/mozilla/modules/libjar/nsJARChannel.cpp b/mozilla/modules/libjar/nsJARChannel.cpp index c411c816f3d..ca7b6afc892 100644 --- a/mozilla/modules/libjar/nsJARChannel.cpp +++ b/mozilla/modules/libjar/nsJARChannel.cpp @@ -33,6 +33,7 @@ #include "nsIAggregatePrincipal.h" #include "nsIProgressEventSink.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIJAR.h" #include "prthread.h" @@ -142,7 +143,7 @@ nsJARChannel::GetName(PRUnichar* *result) if (NS_FAILED(rv)) return rv; nsString name; name.AppendWithConversion(urlStr); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/modules/libjar/nsJARURI.cpp b/mozilla/modules/libjar/nsJARURI.cpp index 040f4d11398..db0c6e4e6a4 100644 --- a/mozilla/modules/libjar/nsJARURI.cpp +++ b/mozilla/modules/libjar/nsJARURI.cpp @@ -24,6 +24,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIZipReader.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -392,7 +393,7 @@ nsJARURI::GetJAREntry(char* *entryPath) PRInt32 pos = entry.RFindCharInSet("#?;"); if (pos >= 0) entry.Truncate(pos); - *entryPath = entry.ToNewCString(); + *entryPath = ToNewCString(entry); return *entryPath ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/modules/libpr0n/decoders/icon/nsIconURI.cpp b/mozilla/modules/libpr0n/decoders/icon/nsIconURI.cpp index c50d1d1ece5..f4677d78adf 100644 --- a/mozilla/modules/libpr0n/decoders/icon/nsIconURI.cpp +++ b/mozilla/modules/libpr0n/decoders/icon/nsIconURI.cpp @@ -24,6 +24,7 @@ #include "nsIIOService.h" #include "nsIURL.h" #include "nsCRT.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #define DEFAULT_IMAGE_SIZE 16 @@ -360,7 +361,7 @@ nsMozIconURI::SetImageSize(PRUint32 aImageSize) // measured by # of pixels in a NS_IMETHODIMP nsMozIconURI::GetContentType(char ** aContentType) { - *aContentType = mContentType.ToNewCString(); + *aContentType = ToNewCString(mContentType); return NS_OK; } @@ -393,7 +394,7 @@ nsMozIconURI::GetFileExtension(char ** aFileExtension) tempFileExt = "."; tempFileExt.Append(fileExt); - *aFileExtension = tempFileExt.ToNewCString(); + *aFileExtension = ToNewCString(tempFileExt); return NS_OK; } } diff --git a/mozilla/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp b/mozilla/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp index 0ed6f82b725..d5516869682 100644 --- a/mozilla/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp +++ b/mozilla/modules/libpr0n/decoders/icon/win/nsIconChannel.cpp @@ -27,6 +27,7 @@ #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMimeTypes.h" #include "nsMemory.h" #include "nsIStringStream.h" @@ -336,7 +337,7 @@ NS_IMETHODIMP nsIconChannel::AsyncOpen(nsIStreamListener *aListener, nsISupports nsCAutoString formattedFileExt; formattedFileExt = "."; formattedFileExt.Append(fileExt.get()); - *((char **)getter_Copies(filePath)) = formattedFileExt.ToNewCString(); // yuck...shove it into our xpidl string... + filePath.Adopt(ToNewCString(formattedFileExt)); } } diff --git a/mozilla/modules/libpref/src/nsAutoConfig.cpp b/mozilla/modules/libpref/src/nsAutoConfig.cpp index df47b232dbb..5b0d868465f 100644 --- a/mozilla/modules/libpref/src/nsAutoConfig.cpp +++ b/mozilla/modules/libpref/src/nsAutoConfig.cpp @@ -48,6 +48,7 @@ #include "nsIObserverService.h" #include "nsIEventQueueService.h" #include "nsLiteralString.h" +#include "nsReadableUtils.h" // nsISupports Implementation @@ -91,7 +92,7 @@ NS_IMETHODIMP nsAutoConfig::GetConfigURL(char * *aConfigURL) return NS_OK; } - *aConfigURL = mConfigURL.ToNewCString(); + *aConfigURL = ToNewCString(mConfigURL); if (!*aConfigURL) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; diff --git a/mozilla/modules/libpref/src/nsPrefBranch.cpp b/mozilla/modules/libpref/src/nsPrefBranch.cpp index bf0d64d2a15..019b159b148 100644 --- a/mozilla/modules/libpref/src/nsPrefBranch.cpp +++ b/mozilla/modules/libpref/src/nsPrefBranch.cpp @@ -42,6 +42,7 @@ #include "nsIObserverService.h" #include "nsISupportsPrimitives.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsXPIDLString.h" #include "nsScriptSecurityManager.h" #include "nsIStringBundle.h" @@ -170,7 +171,7 @@ NS_IMETHODIMP nsPrefBranch::GetRoot(char * *aRoot) NS_ENSURE_ARG_POINTER(aRoot); mPrefRoot.Truncate(mPrefRootLength); - *aRoot = mPrefRoot.ToNewCString(); + *aRoot = ToNewCString(mPrefRoot); return NS_OK; } diff --git a/mozilla/modules/oji/tests/src/TestLoader/OJITestLoader.cpp b/mozilla/modules/oji/tests/src/TestLoader/OJITestLoader.cpp index 44f9a5fc043..e641a96d97a 100755 --- a/mozilla/modules/oji/tests/src/TestLoader/OJITestLoader.cpp +++ b/mozilla/modules/oji/tests/src/TestLoader/OJITestLoader.cpp @@ -20,6 +20,7 @@ */ #include "OJITestLoader.h" //#include +#include "nsReadableUtils.h" static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static NS_DEFINE_IID(kIOJITestLoaderIID, OJITESTLOADER_IID); @@ -96,7 +97,7 @@ TestResult* OJITestLoader::runTest(const char* testCase, const char* libName) { void OJITestLoader::registerRes(TestResult* res, char* tc){ char *outBuf = (char*)calloc(1, res->comment.Length() + PL_strlen(tc) + 100); - sprintf(outBuf, "%s: %s (%s)\n", tc, res->status?"PASS":"FAILED", (res->comment).ToNewCString()); + sprintf(outBuf, "%s: %s (%s)\n", tc, res->status?"PASS":"FAILED", NS_LossyConvertUCS2toASCII(res->comment).get()); if (fdResFile) { printf("%s", outBuf); if (PR_Write(fdResFile, outBuf, PL_strlen(outBuf)) < PL_strlen(outBuf)) diff --git a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp index 9a653e36ef2..681e545edd0 100644 --- a/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -62,6 +62,7 @@ #include "nsIPluginStreamListener2.h" #include "nsIURL.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPref.h" #include "nsIProtocolProxyService.h" #include "nsIStreamConverterService.h" @@ -1285,7 +1286,7 @@ nsPluginStreamInfo::MakeByteRangeString(nsByteRange* aRangeList, char** rangeReq // get rid of possible trailing comma string.Trim(",", PR_FALSE); - *rangeRequest = string.ToNewCString(); + *rangeRequest = ToNewCString(string); *numRequests = requestCnt; return; } @@ -5368,7 +5369,7 @@ NS_IMETHODIMP nsPluginHostImpl::Observe(nsISupports *aSubject, { #ifdef NS_DEBUG nsAutoString topic(aTopic); - char * newString = topic.ToNewCString(); + char * newString = ToNewCString(topic); printf("nsPluginHostImpl::Observe \"%s\"\n", newString ? newString : ""); if (newString) nsCRT::free(newString); diff --git a/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp b/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp index 82fc1b38654..9ea08b3b884 100644 --- a/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp +++ b/mozilla/modules/plugin/base/src/nsPluginsDirBeOS.cpp @@ -49,6 +49,7 @@ #include "prlink.h" #include "plstr.h" #include "prmem.h" +#include "nsReadableUtils.h" #include "nsSpecialSystemDirectory.h" @@ -254,8 +255,8 @@ nsresult nsPluginFile::GetPluginInfo(nsPluginInfo& info) if (appinfo.GetVersionInfo(&vinfo, B_APP_VERSION_KIND) == B_OK && strlen(vinfo.short_info) > 0) { // XXX convert UTF-8 2byte chars to 1 byte chars, to avoid string corruption - info.fName = PL_strdup(NS_ConvertUTF8toUCS2(vinfo.short_info).ToNewCString()); - info.fDescription = PL_strdup(NS_ConvertUTF8toUCS2(vinfo.long_info).ToNewCString()); + info.fName = ToNewCString(NS_ConvertUTF8toUCS2(vinfo.short_info)); + info.fDescription = ToNewCString(NS_ConvertUTF8toUCS2(vinfo.long_info)); } else { // use filename as its name info.fName = GetFileName(path); diff --git a/mozilla/netwerk/base/src/nsAuthURLParser.cpp b/mozilla/netwerk/base/src/nsAuthURLParser.cpp index 63b521608ca..d69619013f4 100644 --- a/mozilla/netwerk/base/src/nsAuthURLParser.cpp +++ b/mozilla/netwerk/base/src/nsAuthURLParser.cpp @@ -21,6 +21,7 @@ #include "nsURLHelper.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prprf.h" #include "prnetdb.h" // IPv6 support @@ -392,7 +393,7 @@ nsAuthURLParser::ParseAtPath(const char* i_Spec, char* *o_Path) dir += i_Spec; - *o_Path = dir.ToNewCString(); + *o_Path = ToNewCString(dir); return (*o_Path ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } @@ -486,7 +487,7 @@ nsAuthURLParser::ParseAtDirectory(const char* i_Path, char* *o_Directory, dir += "/" ; dir += *o_Directory; CRTFREEIF(*o_Directory); - *o_Directory = dir.ToNewCString(); + *o_Directory = ToNewCString(dir); } } else { DupString(o_Directory, "/"); diff --git a/mozilla/netwerk/base/src/nsFileTransport.cpp b/mozilla/netwerk/base/src/nsFileTransport.cpp index e616fbc70c6..707545dd61c 100644 --- a/mozilla/netwerk/base/src/nsFileTransport.cpp +++ b/mozilla/netwerk/base/src/nsFileTransport.cpp @@ -46,6 +46,7 @@ #include "netCore.h" #include "nsIFileStreams.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIProxyObjectManager.h" #include "nsNetUtil.h" @@ -342,7 +343,7 @@ nsFileTransport::GetName(PRUnichar* *result) { nsAutoString name; name.AppendWithConversion(mStreamName); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/base/src/nsIOService.cpp b/mozilla/netwerk/base/src/nsIOService.cpp index 63663bdb01c..3a6b32b0715 100644 --- a/mozilla/netwerk/base/src/nsIOService.cpp +++ b/mozilla/netwerk/base/src/nsIOService.cpp @@ -47,6 +47,7 @@ #include "nsLoadGroup.h" #include "nsInputStreamChannel.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIErrorService.h" #include "netCore.h" #include "nsIObserverService.h" @@ -937,7 +938,7 @@ nsIOService::ResolveRelativePath(const char *relativePath, const char* basePath, if (c != '\0') path += --relativePath; - *result = path.ToNewCString(); + *result = ToNewCString(path); return NS_OK; } diff --git a/mozilla/netwerk/base/src/nsInputStreamChannel.cpp b/mozilla/netwerk/base/src/nsInputStreamChannel.cpp index 8d1175c2a13..15ee80a6175 100644 --- a/mozilla/netwerk/base/src/nsInputStreamChannel.cpp +++ b/mozilla/netwerk/base/src/nsInputStreamChannel.cpp @@ -42,6 +42,7 @@ #include "nsIFileTransportService.h" #include "netCore.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsNetCID.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -210,7 +211,7 @@ nsStreamIOChannel::GetName(PRUnichar* *result) if (NS_FAILED(rv)) return rv; nsString name; name.AppendWithConversion(urlStr); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/base/src/nsLoadGroup.cpp b/mozilla/netwerk/base/src/nsLoadGroup.cpp index f73897e3594..658db47ec8c 100644 --- a/mozilla/netwerk/base/src/nsLoadGroup.cpp +++ b/mozilla/netwerk/base/src/nsLoadGroup.cpp @@ -47,6 +47,7 @@ #include "nsCRT.h" #include "netCore.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsString.h" #if defined(PR_LOGGING) @@ -174,7 +175,7 @@ nsLoadGroup::GetName(PRUnichar* *result) if (NS_SUCCEEDED(rv)) { nsString name; name.Assign(nameStr); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } } diff --git a/mozilla/netwerk/base/src/nsNoAuthURLParser.cpp b/mozilla/netwerk/base/src/nsNoAuthURLParser.cpp index 17dbf71b2a8..af942c4e127 100644 --- a/mozilla/netwerk/base/src/nsNoAuthURLParser.cpp +++ b/mozilla/netwerk/base/src/nsNoAuthURLParser.cpp @@ -21,6 +21,7 @@ #include "nsURLHelper.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prprf.h" #include "prnetdb.h" @@ -199,7 +200,7 @@ nsNoAuthURLParser::ParseAtPath(const char* i_Spec, char* *o_Path) dir += i_Spec; - *o_Path = dir.ToNewCString(); + *o_Path = ToNewCString(dir); return (*o_Path ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } @@ -280,7 +281,7 @@ nsNoAuthURLParser::ParseAtDirectory(const char* i_Path, char* *o_Directory, tempdir += dirfile; tempdir += "/"; CRTFREEIF(dirfile); - dirfile = tempdir.ToNewCString(); + dirfile = ToNewCString(tempdir); if (!dirfile) return NS_ERROR_OUT_OF_MEMORY; } #if 0 @@ -301,7 +302,7 @@ nsNoAuthURLParser::ParseAtDirectory(const char* i_Path, char* *o_Directory, } tempdir += dirfile; CRTFREEIF(dirfile); - dirfile = tempdir.ToNewCString(); + dirfile = ToNewCString(tempdir); if (!dirfile) return NS_ERROR_OUT_OF_MEMORY; } } @@ -328,7 +329,7 @@ nsNoAuthURLParser::ParseAtDirectory(const char* i_Path, char* *o_Directory, dir += "/" ; dir += *o_Directory; CRTFREEIF(*o_Directory); - *o_Directory = dir.ToNewCString(); + *o_Directory = ToNewCString(dir); } } else { DupString(o_Directory, "/"); diff --git a/mozilla/netwerk/base/src/nsSimpleURI.cpp b/mozilla/netwerk/base/src/nsSimpleURI.cpp index 773f35ccd02..233c4009369 100644 --- a/mozilla/netwerk/base/src/nsSimpleURI.cpp +++ b/mozilla/netwerk/base/src/nsSimpleURI.cpp @@ -41,6 +41,7 @@ #include "nscore.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prmem.h" #include "prprf.h" #include "nsURLHelper.h" @@ -138,7 +139,7 @@ nsSimpleURI::GetSpec(char* *result) string.AppendWithConversion(mPath); // NS_UNLOCK_INSTANCE(); - *result = string.ToNewCString(); + *result = ToNewCString(string); return NS_OK; } @@ -160,13 +161,13 @@ nsSimpleURI::SetSpec(const char* aSpec) NS_ASSERTION(n == count, "Mid failed"); if (mScheme) nsCRT::free(mScheme); - mScheme = scheme.ToNewCString(); + mScheme = ToNewCString(scheme); if (mScheme == nsnull) return NS_ERROR_OUT_OF_MEMORY; ToLowerCase(mScheme); if (mPath) nsCRT::free(mPath); - mPath = path.ToNewCString(); + mPath = ToNewCString(path); if (mPath == nsnull) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; @@ -193,7 +194,7 @@ nsSimpleURI::GetPrePath(char* *result) { nsCAutoString prePath(mScheme); prePath += ":"; - *result = prePath.ToNewCString(); + *result = ToNewCString(prePath); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/base/src/nsSocketTransport.cpp b/mozilla/netwerk/base/src/nsSocketTransport.cpp index ac574cca034..8006bf93ea6 100644 --- a/mozilla/netwerk/base/src/nsSocketTransport.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransport.cpp @@ -55,6 +55,7 @@ #include "nsIInterfaceRequestorUtils.h" #include "nsIProxyObjectManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsISSLSocketControl.h" #include "nsITransportSecurityInfo.h" @@ -1347,7 +1348,7 @@ nsSocketTransport::GetName(PRUnichar **result) name.AppendWithConversion(mHostName); name.AppendWithConversion(":"); name.AppendInt(mPort); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/base/src/nsSocketTransportService.cpp b/mozilla/netwerk/base/src/nsSocketTransportService.cpp index 1231bf77b18..96476f2312a 100644 --- a/mozilla/netwerk/base/src/nsSocketTransportService.cpp +++ b/mozilla/netwerk/base/src/nsSocketTransportService.cpp @@ -44,6 +44,7 @@ #include "nsIServiceManager.h" #include "nsProxiedService.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsNetCID.h" #include "prlog.h" #include "nsProtocolProxyService.h" @@ -801,7 +802,7 @@ nsSocketTransportService::GetNeckoStringByName (const char *aName, PRUnichar **a resultString.AssignWithConversion("[StringName"); resultString.AppendWithConversion(aName); resultString.AppendWithConversion("?]"); - *aString = resultString.ToNewUnicode(); + *aString = ToNewUnicode(resultString); } else { @@ -811,7 +812,7 @@ nsSocketTransportService::GetNeckoStringByName (const char *aName, PRUnichar **a else { res = NS_OK; - *aString = resultString.ToNewUnicode(); + *aString = ToNewUnicode(resultString); } return res; diff --git a/mozilla/netwerk/base/src/nsStdURL.cpp b/mozilla/netwerk/base/src/nsStdURL.cpp index 706abb176ed..a5da4bc2d09 100644 --- a/mozilla/netwerk/base/src/nsStdURL.cpp +++ b/mozilla/netwerk/base/src/nsStdURL.cpp @@ -44,6 +44,7 @@ #include "nscore.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prmem.h" #include "prprf.h" #include "nsXPIDLString.h" @@ -646,7 +647,7 @@ nsStdURL::GetSpec(char **o_Spec) { finalSpec += ePath; } - *o_Spec = finalSpec.ToNewCString(); + *o_Spec = ToNewCString(finalSpec); CRTFREEIF(ePath); return (*o_Spec ? NS_OK : NS_ERROR_OUT_OF_MEMORY); @@ -682,7 +683,7 @@ nsStdURL::GetPrePath(char **o_Spec) portBuffer = 0; } } - *o_Spec = finalSpec.ToNewCString(); + *o_Spec = ToNewCString(finalSpec); return (*o_Spec ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } @@ -734,7 +735,7 @@ nsStdURL::GetPreHost(char **o_PreHost) if (NS_FAILED(rv)) return rv; - *o_PreHost = temp.ToNewCString(); + *o_PreHost = ToNewCString(temp); if (!*o_PreHost) return NS_ERROR_OUT_OF_MEMORY; } @@ -762,7 +763,7 @@ nsStdURL::SetDirectory(const char* i_Directory) } CRTFREEIF(mDirectory); - mDirectory = dir.ToNewCString(); + mDirectory = ToNewCString(dir); if (!mDirectory) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; @@ -787,7 +788,7 @@ nsStdURL::SetFileName(const char* i_FileName) nsresult status = AppendString(dir,mDirectory,ESCAPED, esc_Directory); dir += i_FileName; - char *eNewPath = dir.ToNewCString(); + char *eNewPath = ToNewCString(dir); if (!eNewPath) return NS_ERROR_OUT_OF_MEMORY; status = SetPath(eNewPath); @@ -854,7 +855,7 @@ nsStdURL::Resolve(const char *relativePath, char **result) } finalSpec += relativePath; - *result = finalSpec.ToNewCString(); + *result = ToNewCString(finalSpec); if (*result) { char* path = PL_strstr(*result,"://"); if (path) { @@ -940,7 +941,7 @@ nsStdURL::Resolve(const char *relativePath, char **result) finalSpec += (char*)start; } } - *result = finalSpec.ToNewCString(); + *result = ToNewCString(finalSpec); if (*result) { char* path = PL_strstr(*result,"://"); @@ -992,7 +993,7 @@ nsStdURL::GetPath(char** o_Path) if (NS_FAILED(rv)) return rv; } - *o_Path = path.ToNewCString(); + *o_Path = ToNewCString(path); return (*o_Path ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } @@ -1005,7 +1006,7 @@ nsStdURL::GetDirectory(char** o_Directory) esc_Directory); if (NS_FAILED(rv)) return rv; - *o_Directory = directory.ToNewCString(); + *o_Directory = ToNewCString(directory); return (*o_Directory ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } @@ -1120,7 +1121,7 @@ nsStdURL::GetFilePath(char **o_DirFile) if (NS_FAILED(rv)) return rv; - *o_DirFile = temp.ToNewCString(); + *o_DirFile = ToNewCString(temp); if (!*o_DirFile) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; @@ -1140,7 +1141,7 @@ nsStdURL::GetFileName(char **o_FileName) if (NS_FAILED(rv)) return rv; - *o_FileName = temp.ToNewCString(); + *o_FileName = ToNewCString(temp); if (!*o_FileName) return NS_ERROR_OUT_OF_MEMORY; } else { diff --git a/mozilla/netwerk/base/src/nsStdURLParser.cpp b/mozilla/netwerk/base/src/nsStdURLParser.cpp index e2e570dcf83..332f8a0f6e3 100644 --- a/mozilla/netwerk/base/src/nsStdURLParser.cpp +++ b/mozilla/netwerk/base/src/nsStdURLParser.cpp @@ -21,6 +21,7 @@ #include "nsURLHelper.h" #include "nsCRT.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prprf.h" #include "prnetdb.h" @@ -394,7 +395,7 @@ nsStdURLParser::ParseAtPath(const char* i_Spec, char* *o_Path) dir += i_Spec; - *o_Path = dir.ToNewCString(); + *o_Path = ToNewCString(dir); return (*o_Path ? NS_OK : NS_ERROR_OUT_OF_MEMORY); } @@ -488,7 +489,7 @@ nsStdURLParser::ParseAtDirectory(const char* i_Path, char* *o_Directory, dir += "/" ; dir += *o_Directory; CRTFREEIF(*o_Directory); - *o_Directory = dir.ToNewCString(); + *o_Directory = ToNewCString(dir); } } else { DupString(o_Directory, "/"); diff --git a/mozilla/netwerk/base/tests/urltest.cpp b/mozilla/netwerk/base/tests/urltest.cpp index f3822d8cb98..9dbab12b541 100644 --- a/mozilla/netwerk/base/tests/urltest.cpp +++ b/mozilla/netwerk/base/tests/urltest.cpp @@ -58,6 +58,7 @@ #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIURL.h" #include "nsINetService.h" @@ -151,7 +152,7 @@ NS_IMETHODIMP TestConsumer::OnStatus(nsIURL* aURL, const PRUnichar* aMsg) if (bTraceEnabled) { printf("\n+++ TestConsumer::OnStatus: "); nsAutoString str(aMsg); - char* c = str.ToNewCString(); + char* c = ToNewCString(str); fputs(c, stdout); free(c); fputs("\n", stdout); diff --git a/mozilla/netwerk/cache/filecache/nsNetDiskCache.cpp b/mozilla/netwerk/cache/filecache/nsNetDiskCache.cpp index 48ee8638569..d54326a0f79 100644 --- a/mozilla/netwerk/cache/filecache/nsNetDiskCache.cpp +++ b/mozilla/netwerk/cache/filecache/nsNetDiskCache.cpp @@ -45,6 +45,7 @@ #include "nsIFile.h" #include "nsILocalFile.h" #include "nsString.h" +#include "nsReadableUtils.h" #if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN) ERROR! Must have a byte order @@ -353,7 +354,7 @@ nsNetDiskCache::GetDescription(PRUnichar* *aDescription) nsAutoString description ; description.AssignWithConversion("Disk Cache") ; - *aDescription = description.ToNewUnicode() ; + *aDescription = ToNewUnicode(description) ; if(!*aDescription) return NS_ERROR_OUT_OF_MEMORY ; diff --git a/mozilla/netwerk/cache/memcache/nsMemCache.cpp b/mozilla/netwerk/cache/memcache/nsMemCache.cpp index 7589b3ae65a..7f5b172f0d4 100644 --- a/mozilla/netwerk/cache/memcache/nsMemCache.cpp +++ b/mozilla/netwerk/cache/memcache/nsMemCache.cpp @@ -33,6 +33,7 @@ #include "nsMemCacheRecord.h" #include "nsIGenericFactory.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsHashtable.h" #include "nsHashtableEnumerator.h" #include "nsEnumeratorUtils.h" @@ -74,7 +75,7 @@ nsMemCache::GetDescription(PRUnichar * *aDescription) nsAutoString description; description.AssignWithConversion("Memory Cache"); - *aDescription = description.ToNewUnicode(); + *aDescription = ToNewUnicode(description); if (!*aDescription) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; diff --git a/mozilla/netwerk/cache/src/nsDiskCacheDevice.cpp b/mozilla/netwerk/cache/src/nsDiskCacheDevice.cpp index 404b4dcadc1..b53f867fd97 100644 --- a/mozilla/netwerk/cache/src/nsDiskCacheDevice.cpp +++ b/mozilla/netwerk/cache/src/nsDiskCacheDevice.cpp @@ -36,6 +36,7 @@ #include "nsITransport.h" #include "nsICacheVisitor.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIInputStream.h" #include "nsIOutputStream.h" @@ -188,7 +189,7 @@ NS_IMETHODIMP nsDiskCacheDeviceInfo::GetUsageReport(char ** usageReport) buffer.Append(""); // buffer.Append("Files: XXX"); buffer.Append(""); - *usageReport = buffer.ToNewCString(); + *usageReport = ToNewCString(buffer); if (!*usageReport) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; diff --git a/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp b/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp index f4692fcc7dd..b9f8a2b238d 100644 --- a/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp +++ b/mozilla/netwerk/mime/src/nsMIMEInfoImpl.cpp @@ -37,6 +37,7 @@ #include "nsMIMEInfoImpl.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsEscape.h" @@ -73,7 +74,7 @@ nsMIMEInfoImpl::GetFileExtensions(PRUint32 *elementCount, char ***extensions) { for (PRUint32 i=0; i < count; i++) { nsCString* ext = mExtensions.CStringAt(i); - _retExts[i] = ext->ToNewCString(); + _retExts[i] = ToNewCString(*ext); if (!_retExts[i]) { // clean up all the strings we've allocated while (i-- != 0) nsMemory::Free(_retExts[i]); @@ -114,7 +115,7 @@ nsMIMEInfoImpl::FirstExtension(char **_retval) { PRUint32 extCount = mExtensions.Count(); if (extCount < 1) return NS_ERROR_NOT_INITIALIZED; - *_retval = (mExtensions.CStringAt(0))->ToNewCString(); + *_retval = ToNewCString(*(mExtensions.CStringAt(0))); if (!*_retval) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -132,7 +133,7 @@ nsMIMEInfoImpl::GetMIMEType(char * *aMIMEType) { if (mMIMEType.Length() < 1) return NS_ERROR_NOT_INITIALIZED; - *aMIMEType = mMIMEType.ToNewCString(); + *aMIMEType = ToNewCString(mMIMEType); if (!*aMIMEType) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -149,7 +150,7 @@ NS_IMETHODIMP nsMIMEInfoImpl::GetDescription(PRUnichar * *aDescription) { if (!aDescription) return NS_ERROR_NULL_POINTER; - *aDescription = mDescription.ToNewUnicode(); + *aDescription = ToNewUnicode(mDescription); if (!*aDescription) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -221,7 +222,7 @@ NS_IMETHODIMP nsMIMEInfoImpl::SetFileExtensions( const char* aExtensions ) NS_IMETHODIMP nsMIMEInfoImpl::GetApplicationDescription(PRUnichar ** aApplicationDescription) { - *aApplicationDescription = mPreferredAppDescription.ToNewUnicode(); + *aApplicationDescription = ToNewUnicode(mPreferredAppDescription); return NS_OK; } diff --git a/mozilla/netwerk/mime/src/nsMIMEService.cpp b/mozilla/netwerk/mime/src/nsMIMEService.cpp index cf360eecd51..b0241612f01 100644 --- a/mozilla/netwerk/mime/src/nsMIMEService.cpp +++ b/mozilla/netwerk/mime/src/nsMIMEService.cpp @@ -36,6 +36,7 @@ #include "nsMIMEService.h" #include "nsVoidArray.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsMIMEInfoImpl.h" #include "nsIURL.h" #include "nsIFileChannel.h" @@ -172,7 +173,7 @@ nsMIMEService::GetTypeFromURI(nsIURI *aURI, char **aContentType) { PRInt32 extLoc = specStr.RFindChar('.'); if (-1 != extLoc) { specStr.Right(extStr, specStr.Length() - extLoc - 1); - char *ext = extStr.ToNewCString(); + char *ext = ToNewCString(extStr); if (!ext) return NS_ERROR_OUT_OF_MEMORY; rv = GetTypeFromExtension(ext, aContentType); nsMemory::Free(ext); diff --git a/mozilla/netwerk/mime/src/nsXMLMIMEDataSource.cpp b/mozilla/netwerk/mime/src/nsXMLMIMEDataSource.cpp index e01b5ec670e..fc1484c289b 100644 --- a/mozilla/netwerk/mime/src/nsXMLMIMEDataSource.cpp +++ b/mozilla/netwerk/mime/src/nsXMLMIMEDataSource.cpp @@ -41,6 +41,7 @@ #include "nsIURL.h" #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsEnumeratorUtils.h" #include "nsITransport.h" #include "nsIFileTransportService.h" @@ -348,7 +349,7 @@ nsXMLMIMEDataSource::Serialize() { buffer+="=\""; nsString temp( unidata ); nsMemory::Free( unidata ); - char* utf8 = temp.ToNewUTF8String(); + char* utf8 = ToNewUTF8String(temp); buffer+=utf8; nsMemory::Free( utf8 ); buffer+="\" "; diff --git a/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp b/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp index f42c25b4279..37b29f13af0 100644 --- a/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp +++ b/mozilla/netwerk/protocol/data/src/nsDataChannel.cpp @@ -49,6 +49,7 @@ #include "nsIInputStream.h" #include "nsIOutputStream.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID); @@ -170,7 +171,7 @@ nsDataChannel::ParseData() { // it's ascii encoded binary, don't let any spaces in nsCAutoString dataBuf(comma+1); dataBuf.StripWhitespace(); - dataBuffer = dataBuf.ToNewCString(); + dataBuffer = ToNewCString(dataBuf); cleanup = PR_TRUE; } @@ -375,7 +376,7 @@ nsDataChannel::GetContentType(char* *aContentType) { if (!aContentType) return NS_ERROR_NULL_POINTER; if (mContentType.Length()) { - *aContentType = mContentType.ToNewCString(); + *aContentType = ToNewCString(mContentType); if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY; } else { NS_ASSERTION(0, "data protocol should have content type by now"); diff --git a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp index dacbde46fca..fc8936fb173 100644 --- a/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp +++ b/mozilla/netwerk/protocol/file/src/nsFileChannel.cpp @@ -39,6 +39,7 @@ #include "nsIFileChannel.h" #include "nsIURL.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsCExternalHandlerService.h" #include "nsIMIMEService.h" @@ -143,7 +144,7 @@ nsFileChannel::GetName(PRUnichar* *result) if (NS_FAILED(rv)) return rv; nsAutoString name; name.AppendWithConversion(urlStr); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } @@ -347,7 +348,7 @@ nsFileChannel::GetContentType(char * *aContentType) mContentType = UNKNOWN_CONTENT_TYPE; } } - *aContentType = mContentType.ToNewCString(); + *aContentType = ToNewCString(mContentType); if (!*aContentType) { return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp index 9f72e82fb50..5c44210d4e8 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFTPChannel.cpp @@ -44,6 +44,7 @@ #include "nsNetUtil.h" #include "nsMimeTypes.h" #include "nsIProxyObjectManager.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -167,7 +168,7 @@ nsFTPChannel::GetName(PRUnichar* *result) if (NS_FAILED(rv)) return rv; nsString name; name.AppendWithConversion(urlStr); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } @@ -395,7 +396,7 @@ nsFTPChannel::GetContentType(char* *aContentType) { } if (!*aContentType) { - *aContentType = mContentType.ToNewCString(); + *aContentType = ToNewCString(mContentType); } if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp index 8eb93c51e3e..ba2f45b466b 100644 --- a/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp +++ b/mozilla/netwerk/protocol/ftp/src/nsFtpConnectionThread.cpp @@ -43,6 +43,7 @@ #include "nsISocketTransport.h" #include "nsIStreamConverterService.h" +#include "nsReadableUtils.h" #include "prprf.h" #include "prlog.h" #include "prnetdb.h" @@ -422,7 +423,7 @@ nsFtpState::OnDataAvailable(nsIRequest *request, char *cleanup = nsnull; if (!mControlReadCarryOverBuf.IsEmpty() ) { mControlReadCarryOverBuf += buffer; - cleanup = tmpBuffer = mControlReadCarryOverBuf.ToNewCString(); + cleanup = tmpBuffer = ToNewCString(mControlReadCarryOverBuf); mControlReadCarryOverBuf.Truncate(0); if (!tmpBuffer) return NS_ERROR_OUT_OF_MEMORY; } else { @@ -1417,7 +1418,7 @@ nsFtpState::R_pasv() { return FTP_ERROR; } - char *response = mResponseMsg.ToNewCString(); + char *response = ToNewCString(mResponseMsg); if (!response) return FTP_ERROR; char *ptr = response; @@ -1556,7 +1557,7 @@ nsFtpState::GetName(PRUnichar* *result) if (NS_FAILED(rv)) return rv; nsString name; name.AppendWithConversion(urlStr); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.cpp b/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.cpp index 33cc4bbb278..389f90c2079 100644 --- a/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.cpp +++ b/mozilla/netwerk/protocol/gopher/src/nsGopherChannel.cpp @@ -29,6 +29,7 @@ #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsISocketTransportService.h" #include "nsIStringStream.h" #include "nsMimeTypes.h" @@ -149,7 +150,7 @@ nsGopherChannel::GetName(PRUnichar* *result) name.AppendWithConversion(mHost); name.AppendWithConversion(":"); name.AppendInt(mPort); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp b/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp index c411c816f3d..ca7b6afc892 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARChannel.cpp @@ -33,6 +33,7 @@ #include "nsIAggregatePrincipal.h" #include "nsIProgressEventSink.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIJAR.h" #include "prthread.h" @@ -142,7 +143,7 @@ nsJARChannel::GetName(PRUnichar* *result) if (NS_FAILED(rv)) return rv; nsString name; name.AppendWithConversion(urlStr); - *result = name.ToNewUnicode(); + *result = ToNewUnicode(name); return *result ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp index 040f4d11398..db0c6e4e6a4 100644 --- a/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp +++ b/mozilla/netwerk/protocol/jar/src/nsJARURI.cpp @@ -24,6 +24,7 @@ #include "nsIComponentManager.h" #include "nsIServiceManager.h" #include "nsIZipReader.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -392,7 +393,7 @@ nsJARURI::GetJAREntry(char* *entryPath) PRInt32 pos = entry.RFindCharInSet("#?;"); if (pos >= 0) entry.Truncate(pos); - *entryPath = entry.ToNewCString(); + *entryPath = ToNewCString(entry); return *entryPath ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/protocol/keyword/src/nsKeywordProtocolHandler.cpp b/mozilla/netwerk/protocol/keyword/src/nsKeywordProtocolHandler.cpp index d3069090394..76c4e311905 100644 --- a/mozilla/netwerk/protocol/keyword/src/nsKeywordProtocolHandler.cpp +++ b/mozilla/netwerk/protocol/keyword/src/nsKeywordProtocolHandler.cpp @@ -44,6 +44,7 @@ #include "nsEscape.h" #include "nsIPref.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsNetCID.h" static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID); @@ -157,7 +158,7 @@ MangleKeywordIntoHTTPURL(const char *aSpec, const char *aHTTPURL) { // XXX this url should come from somewhere else query.Insert(aHTTPURL, 0); - return query.ToNewCString(); + return ToNewCString(query); } // digests a spec of the form "keyword:blah" diff --git a/mozilla/netwerk/protocol/viewsource/src/nsViewSourceChannel.cpp b/mozilla/netwerk/protocol/viewsource/src/nsViewSourceChannel.cpp index 73b9699ac24..5fdb82568d1 100644 --- a/mozilla/netwerk/protocol/viewsource/src/nsViewSourceChannel.cpp +++ b/mozilla/netwerk/protocol/viewsource/src/nsViewSourceChannel.cpp @@ -27,6 +27,7 @@ #include "nsIInterfaceRequestor.h" #include "nsIInterfaceRequestorUtils.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMimeTypes.h" #include "nsNetUtil.h" @@ -248,7 +249,7 @@ nsViewSourceChannel::GetContentType(char* *aContentType) } else { - *aContentType = mContentType.ToNewCString(); + *aContentType = ToNewCString(mContentType); if (!*aContentType) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp index 9bb3db80456..8e0b90f9f79 100644 --- a/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp +++ b/mozilla/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp @@ -36,6 +36,7 @@ #include "mozTXTToHTMLConv.h" #include "nsIServiceManager.h" #include "nsNetCID.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); @@ -369,7 +370,7 @@ mozTXTToHTMLConv::CheckURLAndCreateHTML( if (NS_FAILED(rv) || !mIOService) return PR_FALSE; - char* specStr = txtURL.ToNewCString(); //I18N this forces a single byte char + char* specStr = ToNewCString(txtURL); //I18N this forces a single byte char if (specStr == nsnull) return PR_FALSE; @@ -1250,7 +1251,7 @@ mozTXTToHTMLConv::ScanTXT(const PRUnichar *text, PRUint32 whattodo, outString.SetCapacity(PRUint32(inLength * growthRate)); ScanTXT(text, inLength, whattodo, outString); - *_retval = outString.ToNewUnicode(); + *_retval = ToNewUnicode(outString); return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } @@ -1266,7 +1267,7 @@ mozTXTToHTMLConv::ScanHTML(const PRUnichar *text, PRUint32 whattodo, outString.SetCapacity(PRUint32(inString.Length() * growthRate)); ScanHTML(inString, whattodo, outString); - *_retval = outString.ToNewUnicode(); + *_retval = ToNewUnicode(outString); return *_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp index fd39a35c5fb..bfde4a4ad4b 100644 --- a/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsFTPDirListingConv.cpp @@ -43,6 +43,7 @@ #include "nsIServiceManager.h" #include "nsIGenericFactory.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsEscape.h" #include "nsNetUtil.h" @@ -184,7 +185,7 @@ nsFTPDirListingConv::Convert(nsIInputStream *aFromStream, PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("::OnData() sending the following %d bytes...\n\n%s\n\n", convertedData.Length(), convertedData.get()) ); #else - char *unescData = convertedData.ToNewCString(); + char *unescData = ToNewCString(convertedData); nsUnescape(unescData); printf("::OnData() sending the following %d bytes...\n\n%s\n\n", convertedData.Length(), unescData); nsMemory::Free(unescData); @@ -283,7 +284,7 @@ nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, // combine the buffers so we don't lose any data. mBuffer.Append(buffer); nsMemory::Free(buffer); - buffer = mBuffer.ToNewCString(); + buffer = ToNewCString(mBuffer); mBuffer.Truncate(); } @@ -325,7 +326,7 @@ nsFTPDirListingConv::OnDataAvailable(nsIRequest* request, nsISupports *ctxt, PR_LOG(gFTPDirListConvLog, PR_LOG_DEBUG, ("::OnData() sending the following %d bytes...\n\n%s\n\n", indexFormat.Length(), indexFormat.get()) ); #else - char *unescData = indexFormat.ToNewCString(); + char *unescData = ToNewCString(indexFormat); nsUnescape(unescData); printf("::OnData() sending the following %d bytes...\n\n%s\n\n", indexFormat.Length(), unescData); nsMemory::Free(unescData); diff --git a/mozilla/netwerk/streamconv/converters/nsGopherDirListingConv.cpp b/mozilla/netwerk/streamconv/converters/nsGopherDirListingConv.cpp index 47de68ed07c..0fb7be39291 100644 --- a/mozilla/netwerk/streamconv/converters/nsGopherDirListingConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsGopherDirListingConv.cpp @@ -28,6 +28,7 @@ #include "nsIServiceManager.h" #include "nsIGenericFactory.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsIURI.h" #include "nsEscape.h" @@ -183,7 +184,7 @@ nsGopherDirListingConv::OnDataAvailable(nsIRequest *request, // combine the buffers so we don't lose any data. mBuffer.Append(buffer); nsMemory::Free(buffer); - buffer = mBuffer.ToNewCString(); + buffer = ToNewCString(mBuffer); mBuffer.Truncate(); } diff --git a/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp b/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp index 6cd33818863..2f91e4e6e9a 100644 --- a/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsHTTPChunkConv.cpp @@ -41,6 +41,7 @@ #include "prlog.h" #include "nsIChannel.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIByteArrayInputStream.h" #include "nsIStringStream.h" @@ -82,8 +83,8 @@ nsHTTPChunkConv::AsyncConvertData ( nsString from (aFromType); nsString to ( aToType ); - char * fromStr = from.ToNewCString (); - char * toStr = to.ToNewCString (); + char * fromStr = ToNewCString(from); + char * toStr = ToNewCString(to); if (!PL_strncasecmp (fromStr, HTTP_CHUNK_TYPE, strlen (HTTP_CHUNK_TYPE ) ) && diff --git a/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp b/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp index 713902925e4..57c7defc57a 100644 --- a/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsHTTPCompressConv.cpp @@ -41,6 +41,7 @@ #include "prlog.h" #include "nsIChannel.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIByteArrayInputStream.h" #include "nsIStringStream.h" @@ -81,8 +82,8 @@ nsHTTPCompressConv::AsyncConvertData ( nsString from (aFromType); nsString to ( aToType ); - char * fromStr = from.ToNewCString (); - char * toStr = to.ToNewCString (); + char * fromStr = ToNewCString(from); + char * toStr = ToNewCString(to); if (!PL_strncasecmp (fromStr, HTTP_COMPRESS_TYPE , strlen (HTTP_COMPRESS_TYPE )) || diff --git a/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp b/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp index eae9876d924..68bf6b21c99 100644 --- a/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp +++ b/mozilla/netwerk/streamconv/converters/nsMultiMixedConv.cpp @@ -44,6 +44,7 @@ #include "nsNetUtil.h" #include "nsMimeTypes.h" #include "nsIByteArrayInputStream.h" +#include "nsReadableUtils.h" // @@ -287,7 +288,7 @@ nsPartChannel::GetSecurityInfo(nsISupports * *aSecurityInfo) NS_IMETHODIMP nsPartChannel::GetContentType(char * *aContentType) { - *aContentType = mContentType.ToNewCString(); + *aContentType = ToNewCString(mContentType); return NS_OK; } @@ -859,7 +860,7 @@ nsMultiMixedConv::ParseHeaders(nsIChannel *aChannel, char *&aPtr, // examine header if (headerStr.EqualsIgnoreCase("content-type")) { - char *tmpString = headerVal.ToNewCString(); + char *tmpString = ToNewCString(headerVal); ParseContentType(tmpString); nsCRT::free(tmpString); } else if (headerStr.EqualsIgnoreCase("content-length")) { diff --git a/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp b/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp index 3ae541c4a28..fc42a48c2d5 100644 --- a/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp +++ b/mozilla/netwerk/streamconv/src/nsStreamConverterService.cpp @@ -37,6 +37,7 @@ #include "nsIServiceManager.h" #include "nsIComponentManager.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIAtom.h" #include "nsDeque.h" #include "nsIInputStream.h" @@ -150,7 +151,7 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) { // Each MIME-type is a vertex in the graph, so first lets make sure // each MIME-type is represented as a key in our hashtable. - nsCStringKey *fromKey = new nsCStringKey(fromStr.ToNewCString(), -1, nsCStringKey::OWN); + nsCStringKey *fromKey = new nsCStringKey(ToNewCString(fromStr), fromStr.Length(), nsCStringKey::OWN); if (!fromKey) return NS_ERROR_OUT_OF_MEMORY; SCTableData *fromEdges = (SCTableData*)mAdjacencyList->Get(fromKey); @@ -178,7 +179,7 @@ nsStreamConverterService::AddAdjacency(const char *aContractID) { fromKey = nsnull; } - nsCStringKey *toKey = new nsCStringKey(toStr.ToNewCString(), -1, nsCStringKey::OWN); + nsCStringKey *toKey = new nsCStringKey(ToNewCString(toStr), toStr.Length(), nsCStringKey::OWN); if (!toKey) return NS_ERROR_OUT_OF_MEMORY; if (!mAdjacencyList->Get(toKey)) { @@ -333,7 +334,7 @@ nsStreamConverterService::FindConverter(const char *aContractID, nsCStringArray nsIAtom *curVertexAtom = (nsIAtom*)edges->ElementAt(i); nsAutoString curVertexStr; curVertexAtom->ToString(curVertexStr); - nsCStringKey *curVertex = new nsCStringKey(curVertexStr.ToNewCString(), + nsCStringKey *curVertex = new nsCStringKey(ToNewCString(curVertexStr), curVertexStr.Length(), nsCStringKey::OWN); SCTableData *data3 = (SCTableData*)lBFSTable.Get(curVertex); @@ -488,12 +489,12 @@ nsStreamConverterService::Convert(nsIInputStream *aFromStream, return rv; } - PRUnichar *fromUni = fromStr.ToNewUnicode(); + PRUnichar *fromUni = ToNewUnicode(fromStr); if (!fromUni) { delete converterChain; return NS_ERROR_OUT_OF_MEMORY; } - PRUnichar *toUni = toStr.ToNewUnicode(); + PRUnichar *toUni = ToNewUnicode(toStr); if (!toUni) { delete fromUni; delete converterChain; @@ -589,13 +590,13 @@ nsStreamConverterService::AsyncConvertData(const PRUnichar *aFromType, return rv; } - PRUnichar *fromStrUni = fromStr.ToNewUnicode(); + PRUnichar *fromStrUni = ToNewUnicode(fromStr); if (!fromStrUni) { delete converterChain; return NS_ERROR_OUT_OF_MEMORY; } - PRUnichar *toStrUni = toStr.ToNewUnicode(); + PRUnichar *toStrUni = ToNewUnicode(toStr); if (!toStrUni) { delete fromStrUni; delete converterChain; diff --git a/mozilla/netwerk/streamconv/test/Converters.cpp b/mozilla/netwerk/streamconv/test/Converters.cpp index be5ac8e59ed..ce8d618f8b9 100644 --- a/mozilla/netwerk/streamconv/test/Converters.cpp +++ b/mozilla/netwerk/streamconv/test/Converters.cpp @@ -1,6 +1,7 @@ #include "Converters.h" #include "nsIStringStream.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" ////////////////////////////////////////////////// // TestConverter @@ -29,7 +30,7 @@ TestConverter::Convert(nsIInputStream *aFromStream, // verify that the data we're converting matches the from type // if it doesn't then we're being handed the wrong data. nsString from(aFromType); - char *fromMIME = from.ToNewCString(); + char *fromMIME = ToNewCString(from); char fromChar = *fromMIME; nsMemory::Free(fromMIME); @@ -41,7 +42,7 @@ TestConverter::Convert(nsIInputStream *aFromStream, // Get the first character nsString to(aToType); - char *toMIME = to.ToNewCString(); + char *toMIME = ToNewCString(to); char toChar = *toMIME; nsMemory::Free(toMIME); diff --git a/mozilla/netwerk/test/TestPageLoad.cpp b/mozilla/netwerk/test/TestPageLoad.cpp index bf682759708..b5eeedb929a 100644 --- a/mozilla/netwerk/test/TestPageLoad.cpp +++ b/mozilla/netwerk/test/TestPageLoad.cpp @@ -49,6 +49,7 @@ #include "plstr.h" #include "nsSupportsArray.h" #include +#include "nsReadableUtils.h" int getStrLine(const char *src, char *str, int ind, int max); nsresult auxLoad(char *uriBuf); @@ -92,7 +93,7 @@ static NS_METHOD streamParse (nsIInputStream* in, if(globalStream.Length() > 0) { globalStream.AppendWithConversion(fromRawSegment); - tmp = globalStream.ToNewCString(); + tmp = ToNewCString(globalStream); //printf("\n>>NOW:\n^^^^^\n%s\n^^^^^^^^^^^^^^", tmp); } else { tmp = (char *)fromRawSegment; diff --git a/mozilla/netwerk/test/urltest.cpp b/mozilla/netwerk/test/urltest.cpp index 92d703131b8..c20cf5a7767 100644 --- a/mozilla/netwerk/test/urltest.cpp +++ b/mozilla/netwerk/test/urltest.cpp @@ -53,6 +53,7 @@ #include "iostream.h" #include "nsXPIDLString.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsNetCID.h" // Define CIDs... @@ -136,10 +137,10 @@ nsresult writeoutto(const char* i_pURL, char** o_Result, PRBool bUseStd = PR_TRU output += ','; tURL->GetSpec(getter_Copies(temp)); output += temp ? (const char*)temp : ""; - *o_Result = output.ToNewCString(); + *o_Result = ToNewCString(output); } else { output = "Can not create URL"; - *o_Result = output.ToNewCString(); + *o_Result = ToNewCString(output); } return NS_OK; } diff --git a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp index efdbe56af79..43b3ab9ef42 100644 --- a/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp +++ b/mozilla/parser/htmlparser/robot/nsDebugRobot.cpp @@ -46,6 +46,7 @@ #include "nsWeakReference.h" #include "nsVoidArray.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIURL.h" #include "nsIServiceManager.h" #include "nsIURL.h" @@ -262,7 +263,7 @@ extern "C" NS_EXPORT int DebugRobot( if (NS_FAILED(rv)) return rv; nsIURI *uri = nsnull; - char *uriStr = urlName->ToNewCString(); + char *uriStr = ToNewCString(*urlName); if (!uriStr) return NS_ERROR_OUT_OF_MEMORY; rv = service->NewURI(uriStr, nsnull, &uri); nsCRT::free(uriStr); diff --git a/mozilla/parser/htmlparser/robot/nsRobotSink.cpp b/mozilla/parser/htmlparser/robot/nsRobotSink.cpp index a193b8dfa24..8aa2e81b755 100644 --- a/mozilla/parser/htmlparser/robot/nsRobotSink.cpp +++ b/mozilla/parser/htmlparser/robot/nsRobotSink.cpp @@ -41,6 +41,7 @@ #include "nsIParserNode.h" #include "nsIParser.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIURL.h" #include "nsIURL.h" #include "nsIServiceManager.h" @@ -372,7 +373,7 @@ void RobotSink::ProcessLink(const nsString& aLink) rv = mDocumentURL->QueryInterface(NS_GET_IID(nsIURI), (void**)&baseUri); if (NS_FAILED(rv)) return; - char *uriStr = aLink.ToNewCString(); + char *uriStr = ToNewCString(aLink); if (!uriStr) return; rv = service->NewURI(uriStr, baseUri, &uri); nsCRT::free(uriStr); diff --git a/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp b/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp index 93d0f5175fe..235338995f1 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLContentSinkStream.cpp @@ -50,6 +50,7 @@ #include "nsIParserNode.h" #include #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIParser.h" #include "nsICharsetAlias.h" #include "nsIServiceManager.h" @@ -667,7 +668,7 @@ void nsHTMLContentSinkStream::AddStartTag(const nsIParserNode& aNode) #ifdef DEBUG_prettyprint if (isDirty) printf("AddStartTag(%s): BBO=%d, BAO=%d, BBC=%d, BAC=%d\n", - name.ToNewCString(), + NS_LossyConvertUCS2toASCII(name).get(), BreakBeforeOpen(tag), BreakAfterOpen(tag), BreakBeforeClose(tag), diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index 56bada1d3d7..2ef8f943443 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -2126,7 +2126,7 @@ PRInt32 CEntityToken::TranslateToUnicodeStr(nsString& aString) { * @return */ void CEntityToken::DebugDumpSource(nsOutputStream& out) { - char* cp=mTextValue.ToNewCString(); + char* cp = ToNewCString(mTextValue); out << "&" << *cp; delete[] cp; } diff --git a/mozilla/parser/htmlparser/src/nsLoggingSink.cpp b/mozilla/parser/htmlparser/src/nsLoggingSink.cpp index 4eb85dff6b5..0c85be21a1d 100644 --- a/mozilla/parser/htmlparser/src/nsLoggingSink.cpp +++ b/mozilla/parser/htmlparser/src/nsLoggingSink.cpp @@ -38,6 +38,7 @@ #include "nsLoggingSink.h" #include "nsHTMLTags.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prprf.h" static NS_DEFINE_IID(kIContentSinkIID, NS_ICONTENT_SINK_IID); @@ -754,7 +755,7 @@ nsLoggingSink::GetNewCString(const nsAReadableString& aValue, char** aResult) result=QuoteText(aValue,temp); if(NS_SUCCEEDED(result)) { if(temp.Length()>0) { - *aResult=temp.ToNewCString(); + *aResult = ToNewCString(temp); } } return result; diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp index 3627c9a5076..2ed2290bb7e 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.cpp +++ b/mozilla/parser/htmlparser/src/nsScanner.cpp @@ -109,7 +109,7 @@ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharset { MOZ_COUNT_CTOR(nsScanner); - PRUnichar* buffer = anHTMLString.ToNewUnicode(); + PRUnichar* buffer = ToNewUnicode(anHTMLString); mTotalRead = anHTMLString.Length(); mSlidingBuffer = nsnull; mCountRemaining = 0; diff --git a/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp b/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp index b0de07cd7e9..1c412e4d3b8 100644 --- a/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp +++ b/mozilla/parser/htmlparser/tests/grabpage/grabpage.cpp @@ -44,6 +44,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "nsString.h" +#include "nsReadableUtils.h" #include "nsCRT.h" #include "prprf.h" @@ -204,7 +205,7 @@ PageGrabber::NextFile(const char* aExtension) // See if file already exists; if it does advance mFileNum by 100 and // try again. - cname = name.ToNewCString(); + cname = ToNewCString(name); struct stat sb; int s = stat(cname, &sb); if (s < 0) { diff --git a/mozilla/parser/htmlparser/tests/outsinks/Convert.cpp b/mozilla/parser/htmlparser/tests/outsinks/Convert.cpp index f0db039bbcf..7e8ba64b758 100644 --- a/mozilla/parser/htmlparser/tests/outsinks/Convert.cpp +++ b/mozilla/parser/htmlparser/tests/outsinks/Convert.cpp @@ -29,6 +29,7 @@ #include "nsLayoutCID.h" #include "nsIHTMLToTextSink.h" #include "nsIComponentManager.h" +#include "nsReadableUtils.h" extern "C" void NS_SetupRegistry(); @@ -49,7 +50,7 @@ Compare(nsString& str, nsString& aFileName) { // Open the file in a Unix-centric way, // until I find out how to use nsFileSpec: - char* filename = aFileName.ToNewCString(); + char* filename = ToNewCString(aFileName); FILE* file = fopen(filename, "r"); if (!file) { @@ -89,7 +90,7 @@ Compare(nsString& str, nsString& aFileName) { nsAutoString left; str.Left(left, different); - char* cstr = left.ToNewUTF8String(); + char* cstr = ToNewUTF8String(left); printf("Comparison failed at char %d:\n-----\n%s\n-----\n", different, cstr); Recycle(cstr); @@ -141,8 +142,8 @@ HTML2text(nsString& inString, nsString& inType, nsString& outType, if (inType != NS_LITERAL_STRING("text/html") || outType != NS_LITERAL_STRING("text/plain")) { - char* in = inType.ToNewCString(); - char* out = outType.ToNewCString(); + char* in = ToNewCString(inType); + char* out = ToNewCString(outType); printf("Don't know how to convert from %s to %s\n", in, out); Recycle(in); Recycle(out); @@ -177,7 +178,7 @@ HTML2text(nsString& inString, nsString& inType, nsString& outType, parser->RegisterDTD(dtd); - char* inTypeStr = inType.ToNewCString(); + char* inTypeStr = ToNewCString(inType); rv = parser->Parse(inString, 0, NS_ConvertASCIItoUCS2(inTypeStr), PR_FALSE, PR_TRUE); delete[] inTypeStr; if (NS_FAILED(rv)) @@ -190,7 +191,7 @@ HTML2text(nsString& inString, nsString& inType, nsString& outType, if (compareAgainst.Length() > 0) return Compare(outString, compareAgainst); - char* charstar = outString.ToNewUTF8String(); + char* charstar = ToNewUTF8String(outString); printf("Output string is:\n--------------------\n%s--------------------\n", charstar); delete[] charstar; diff --git a/mozilla/profile/Acct/dialshr.cpp b/mozilla/profile/Acct/dialshr.cpp index da1a9e72604..d7ef1e92599 100644 --- a/mozilla/profile/Acct/dialshr.cpp +++ b/mozilla/profile/Acct/dialshr.cpp @@ -65,6 +65,7 @@ //nclude "prefapi.h" //#include "prmem.h" //#include "nsString.h" +#include "nsReadableUtils.h" #define trace @@ -4255,12 +4256,12 @@ void SetDataArray(nsString data) #if defined(DEBUG_profile) printf("ProfileManager : Setting new profile data\n"); - printf("SetDataArray data : %s\n", data.ToNewCString()); + printf("SetDataArray data : %s\n", NS_LossyConvertUCS2toASCII(data).get()); #endif int index = 0; char *newStr=nsnull; - char *tokstr = data.ToNewCString(); + char *tokstr = ToNewCString(data); char *token = nsCRT::strtok(tokstr, "%", &newStr); #if defined(DEBUG_profile) @@ -4361,9 +4362,9 @@ char* GetModemConfig(void) // strcpy( returnData, (const char*)str ); */ returnData.AssignWithConversion(modemResults[0]); // returnData = tmp; - printf("this is the modem inside the modemconfig %s \n", returnData.ToNewCString()); + printf("this is the modem inside the modemconfig %s \n", NS_LossyConvertUCS2toASCII(returnData).get()); delete []modemResults; -return returnData.ToNewCString(); + return ToNewCString(returnData); } diff --git a/mozilla/profile/Acct/nsAccount.cpp b/mozilla/profile/Acct/nsAccount.cpp index 6ab9e88a020..016fbbd6c9d 100644 --- a/mozilla/profile/Acct/nsAccount.cpp +++ b/mozilla/profile/Acct/nsAccount.cpp @@ -55,6 +55,7 @@ #include "nsIFileSpec.h" #include "nsFileStream.h" #include "nsString.h" +#include "nsReadableUtils.h" //#include "nsIFileLocator.h" //#include "nsFileLocations.h" //#include "nsEscape.h" @@ -344,12 +345,12 @@ int nsAccount::IterateDirectoryChildren(nsFileSpec& startChild) int nsAccount::GetNCIValues(nsString MiddleValue) { - nsresult ret; + nsresult ret; nsIInputStream* in = nsnull; - nsString Trial; Trial.AssignWithConversion("resource:/res/acct/NCI_Dir/"); - Trial = Trial + MiddleValue; - printf("this is the trial value %s \n", Trial.ToNewCString()); + nsAutoString Trial(NS_LITERAL_STRING("resource:/res/acct/NCI_Dir/") + + MiddleValue); + printf("this is the trial value %s \n", NS_LossyConvertUCS2toASCII(Trial).get()); nsCOMPtr service(do_GetService(kIOServiceCID, &ret)); if (NS_FAILED(ret)) return ret; @@ -392,11 +393,10 @@ int nsAccount::GetNCIValues(nsString MiddleValue) printf("Failed to return the Get property \n"); } - PL_strcpy(IspLocation[LocCount], v.ToNewCString()); - char* lvalue = v.ToNewCString(); + PL_strcpy(IspLocation[LocCount], v.get()); + cout << "the value is " << IspLocation[LocCount] << "." << endl; - delete[] lvalue; LocCount++; sprintf(name, "%s", "Phone"); @@ -406,8 +406,8 @@ int nsAccount::GetNCIValues(nsString MiddleValue) printf("Failed to return the Get property \n"); } - PL_strcpy(IspPhone[PhoneCount], v.ToNewCString()); - char* value = v.ToNewCString(); + char* value = ToNewCString(v); + PL_strcpy(IspPhone[PhoneCount], value); // if (value) { cout << "the value is " << IspPhone[PhoneCount] << "." << endl; // printf ("this is the %d and its value \n ",ind); @@ -431,7 +431,7 @@ int nsAccount::GetConfigValues(nsString fileName) nsIInputStream* in = nsnull; nsString Trial; Trial.AssignWithConversion("resource:/res/acct/NCI_Dir/"); Trial = Trial + fileName; - printf("this is the trial value %s \n", Trial.ToNewCString()); + printf("this is the trial value %s \n", NS_LossyConvertUCS2toASCII(Trial).get()); nsCOMPtr service(do_GetService(kIOServiceCID, &ret)); if (NS_FAILED(ret)) return ret; @@ -476,7 +476,7 @@ int nsAccount::GetConfigValues(nsString fileName) printf("Failed to return the Get property \n"); } - PL_strcpy(domainname, v.ToNewCString()); + PL_strcpy(domainname, ToNewCString(v)); sprintf(name, "%s", "DNSAddress"); ret = props->GetStringProperty(NS_ConvertASCIItoUCS2(name), v); @@ -485,7 +485,7 @@ int nsAccount::GetConfigValues(nsString fileName) printf("Failed to return the Get property \n"); } - PL_strcpy(dnsp, v.ToNewCString()); + PL_strcpy(dnsp, ToNewCString(v)); sprintf(name, "%s", "DNSAddress2"); ret = props->GetStringProperty(NS_ConvertASCIItoUCS2(name), v); @@ -494,7 +494,7 @@ int nsAccount::GetConfigValues(nsString fileName) printf("Failed to return the Get property \n"); } - PL_strcpy(dnss, v.ToNewCString()); + PL_strcpy(dnss, ToNewCString(v)); printf (" This is the dnsp name %s \n",dnsp); printf (" This is the dnss name %s \n",dnss); @@ -639,7 +639,7 @@ NS_IMETHODIMP nsAccount::GetModemConfig(nsString& ModemList) // strcpy( returnData, (const char*)str ); // returnData = modemResults[0]; // returnData = tmp; - printf("this is the modem inside the modemconfig %s \n", ModemList.ToNewCString()); + printf("this is the modem inside the modemconfig %s \n", NS_LossyConvertUCS2toASCII(ModemList).get()); delete []modemResults; @@ -692,7 +692,7 @@ NS_IMETHODIMP nsAccount::GetAcctConfig(nsString& AccountList) AccountList.AppendWithConversion(gNCIInfo[i]); } -// printf("this is the acct strings %s\n",AccountList.ToNewCString()); +// printf("this is the acct strings %s\n", NS_LossyConvertUCS2toASCII(AccountList).get()); delete []connectionNames; } } diff --git a/mozilla/profile/Acctidl/nsAccountServices.cpp b/mozilla/profile/Acctidl/nsAccountServices.cpp index a4a686ae79c..d1fd9a9e503 100644 --- a/mozilla/profile/Acctidl/nsAccountServices.cpp +++ b/mozilla/profile/Acctidl/nsAccountServices.cpp @@ -52,6 +52,7 @@ #include "nsIAccount.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kAccountCID, NS_Account_CID); @@ -129,7 +130,7 @@ AccountServicesImpl::GetAcctConfig(char** AccountList) { nsString localVar; mAccount->GetAcctConfig(localVar); - *AccountList = PL_strdup(localVar.ToNewCString()); + *AccountList = ToNewCString(localVar); return NS_OK; } @@ -139,7 +140,7 @@ AccountServicesImpl::GetModemConfig(char** ModemList) { nsString localVar; mAccount->GetModemConfig(localVar); - *ModemList = PL_strdup(localVar.ToNewCString()); + *ModemList = ToNewCString(localVar); return NS_OK; } @@ -149,7 +150,7 @@ AccountServicesImpl::GetSiteName(char** SiteList) { nsString localVar; mAccount->GetSiteName(localVar); - *SiteList = PL_strdup(localVar.ToNewCString()); + *SiteList = ToNewCString(localVar); return NS_OK; } @@ -159,7 +160,7 @@ AccountServicesImpl::GetPhone(char** PhoneList) { nsString localVar; mAccount->GetPhone(localVar); - *PhoneList = PL_strdup(localVar.ToNewCString()); + *PhoneList = ToNewCString(localVar); return NS_OK; } @@ -176,6 +177,6 @@ AccountServicesImpl::CheckForDun(char** dunlist) { nsString localVar; mAccount->CheckForDun(localVar); - *dunlist =PL_strdup(localVar.ToNewCString()); + *dunlist = ToNewCString(localVar); return NS_OK; } diff --git a/mozilla/profile/pref-migrator/src/nsPrefMigration.cpp b/mozilla/profile/pref-migrator/src/nsPrefMigration.cpp index 7a54f0dc80a..52ebbfbbeed 100644 --- a/mozilla/profile/pref-migrator/src/nsPrefMigration.cpp +++ b/mozilla/profile/pref-migrator/src/nsPrefMigration.cpp @@ -59,6 +59,7 @@ #include "plstr.h" #include "prprf.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIStringBundle.h" #include "nsISupportsPrimitives.h" #include "nsProxiedService.h" @@ -1606,7 +1607,7 @@ static nsresult PutCookieLine(nsOutputFileStream &strm, const nsString& aLine) { /* allocate a buffer from the heap */ - char * cp = aLine.ToNewCString(); + char * cp = ToNewCString(aLine); if (! cp) { return NS_ERROR_FAILURE; } @@ -1680,7 +1681,7 @@ Fix4xCookies(nsIFileSpec * profilePath) { inBuffer.Mid(suffix, nameIndex, inBuffer.Length()-nameIndex); /* correct the expires field */ - char * expiresCString = expiresString.ToNewCString(); + char * expiresCString = ToNewCString(expiresString); unsigned long expires = strtoul(expiresCString, nsnull, 10); nsCRT::free(expiresCString); @@ -2122,7 +2123,7 @@ ConvertStringToUTF8(nsAutoString& aCharset, const char* inString, char** outStri nsAutoString aString; aString.Assign(unichars, uniLength); // convert to UTF-8 - *outString = aString.ToNewUTF8String(); + *outString = ToNewUTF8String(aString); } delete [] unichars; } diff --git a/mozilla/profile/src/nsProfileAccess.cpp b/mozilla/profile/src/nsProfileAccess.cpp index 91bdf2a17e7..2454e92bf06 100644 --- a/mozilla/profile/src/nsProfileAccess.cpp +++ b/mozilla/profile/src/nsProfileAccess.cpp @@ -549,7 +549,7 @@ nsProfileAccess::GetFirstProfile(PRUnichar **firstProfile) if (profileItem->isMigrated) { - *firstProfile = profileItem->profileName.ToNewUnicode(); + *firstProfile = ToNewUnicode(profileItem->profileName); break; } } @@ -579,7 +579,7 @@ nsProfileAccess::GetCurrentProfile(PRUnichar **profileName) if (!mCurrentProfile.IsEmpty() || mForgetProfileCalled) { - *profileName = mCurrentProfile.ToNewUnicode(); + *profileName = ToNewUnicode(mCurrentProfile); } // If there are profiles and profileName is not @@ -876,7 +876,7 @@ nsProfileAccess::GetProfileList(PRInt32 whichKind, PRUint32 *length, PRUnichar * else if (whichKind == nsIProfileInternal::LIST_ONLY_NEW && !profileItem->isMigrated) continue; - *next = profileItem->profileName.ToNewUnicode(); + *next = ToNewUnicode(profileItem->profileName); if (*next == nsnull) { rv = NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/rdf/base/src/nsInMemoryDataSource.cpp b/mozilla/rdf/base/src/nsInMemoryDataSource.cpp index 4117185f69f..c5f037f603f 100644 --- a/mozilla/rdf/base/src/nsInMemoryDataSource.cpp +++ b/mozilla/rdf/base/src/nsInMemoryDataSource.cpp @@ -70,6 +70,7 @@ #include "nsRDFCID.h" #include "nsRDFBaseDataSources.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsXPIDLString.h" #include "nsFixedSizeAllocator.h" #include "rdfutil.h" @@ -888,7 +889,7 @@ InMemoryDataSource::LogOperation(const char* aOperation, nsXPIDLString value; literal->GetValue(getter_Copies(value)); nsAutoString valueStr(value); - char* valueCStr = valueStr.ToNewCString(); + char* valueCStr = ToNewCString(valueStr); PR_LOG(gLog, PR_LOG_ALWAYS, (" -->(\"%s\")\n", valueCStr)); diff --git a/mozilla/rdf/base/src/nsRDFContentSink.cpp b/mozilla/rdf/base/src/nsRDFContentSink.cpp index c4a1122d5a3..cf2a029c6c7 100644 --- a/mozilla/rdf/base/src/nsRDFContentSink.cpp +++ b/mozilla/rdf/base/src/nsRDFContentSink.cpp @@ -947,7 +947,7 @@ RDFContentSinkImpl::GetNameSpaceURI(nsIAtom* aPrefix, const char** aNameSpaceURI if (aPrefix) aPrefix->ToString(prefixStr); - char* prefixCStr = prefixStr.ToNewCString(); + char* prefixCStr = ToNewCString(prefixStr); PR_LOG(gLog, PR_LOG_ALWAYS, ("rdfxml: undeclared namespace prefix '%s'", diff --git a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp index 44cdb7f6e2a..43da94733e8 100644 --- a/mozilla/rdf/chrome/src/nsChromeRegistry.cpp +++ b/mozilla/rdf/chrome/src/nsChromeRegistry.cpp @@ -64,6 +64,7 @@ #include "nsIRDFContainerUtils.h" #include "nsHashtable.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsXPIDLString.h" #include "nsIStringBundle.h" #include "nsISimpleEnumerator.h" @@ -2751,7 +2752,7 @@ nsChromeRegistry::GetBackstopSheets(nsIDocShell* aDocShell, nsISupportsArray **a if (!sheets.IsEmpty()) { // Construct the URIs and try to load each sheet. nsCAutoString sheetsStr; sheetsStr.AssignWithConversion(sheets); - char* str = sheets.ToNewCString(); + char* str = ToNewCString(sheets); char* newStr; char* token = nsCRT::strtok( str, ", ", &newStr ); while (token) { diff --git a/mozilla/rdf/tests/domds/nsRDFDOMDataSource.cpp b/mozilla/rdf/tests/domds/nsRDFDOMDataSource.cpp index b3af0d2466a..1a41b635a19 100644 --- a/mozilla/rdf/tests/domds/nsRDFDOMDataSource.cpp +++ b/mozilla/rdf/tests/domds/nsRDFDOMDataSource.cpp @@ -42,6 +42,7 @@ #include "rdf.h" #include "plstr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsEnumeratorUtils.h" @@ -988,11 +989,9 @@ nsRDFDOMDataSource::createLiteral(nsString& str, nsIRDFNode **aResult) nsresult rv; nsCOMPtr literal; - PRUnichar* uniStr = str.ToNewUnicode(); - rv = getRDFService()->GetLiteral(uniStr, + rv = getRDFService()->GetLiteral(str.get(), getter_AddRefs(literal)); - nsMemory::Free(uniStr); - + *aResult = literal; NS_IF_ADDREF(*aResult); return NS_OK; @@ -1266,7 +1265,7 @@ nsRDFDOMDataSource::SetWindow(nsIDOMWindowInternal *window) { } #endif - printf("Got root frame: %s\n", framename.ToNewCString()); + printf("Got root frame: %s\n", NS_LossyConvertUCS2toASCII(framename).get()); return rv; } diff --git a/mozilla/rdf/tests/domds/nsRDFDOMViewerUtils.cpp b/mozilla/rdf/tests/domds/nsRDFDOMViewerUtils.cpp index 20f732fd689..a3ccf7cd239 100644 --- a/mozilla/rdf/tests/domds/nsRDFDOMViewerUtils.cpp +++ b/mozilla/rdf/tests/domds/nsRDFDOMViewerUtils.cpp @@ -70,10 +70,8 @@ nsDOMViewerObject::SetTargetLiteral(nsIRDFResource *aProperty, nsCOMPtr rdf = do_GetService(NS_RDF_CONTRACTID "/rdf-service;1", &rv); - PRUnichar* uniStr = str.ToNewUnicode(); nsCOMPtr literal; - rv = rdf->GetLiteral(uniStr, getter_AddRefs(literal)); - nsMemory::Free(uniStr); + rv = rdf->GetLiteral(str.get(), getter_AddRefs(literal)); SetTarget(aProperty, literal); return NS_OK; diff --git a/mozilla/rdf/tests/rdfpoll/rdfpoll.cpp b/mozilla/rdf/tests/rdfpoll/rdfpoll.cpp index 0bf6169b43a..3764bcadd41 100644 --- a/mozilla/rdf/tests/rdfpoll/rdfpoll.cpp +++ b/mozilla/rdf/tests/rdfpoll/rdfpoll.cpp @@ -72,6 +72,7 @@ #include "plstr.h" #include "nsParserCIID.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsNetCID.h" #if defined(XP_PC) @@ -202,7 +203,7 @@ rdf_WriteOp(const char* aOp, rv = literal->GetValue(getter_Copies(target)); if (NS_FAILED(rv)) return rv; - char* p = nsAutoString(target).ToNewCString(); + char* p = ToNewCString(target); if (! p) return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/security/manager/pki/src/nsNSSDialogs.cpp b/mozilla/security/manager/pki/src/nsNSSDialogs.cpp index 19530f73495..60a77194190 100644 --- a/mozilla/security/manager/pki/src/nsNSSDialogs.cpp +++ b/mozilla/security/manager/pki/src/nsNSSDialogs.cpp @@ -28,6 +28,7 @@ #include "nsCOMPtr.h" #include "nsString.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPrompt.h" #include "nsIDOMWindowInternal.h" #include "nsIDialogParamBlock.h" @@ -382,7 +383,7 @@ nsNSSDialogs::CertExpired(nsITransportSecurityInfo *socketInfo, aDateTimeFormat->FormatPRTime(nsnull, kDateFormatShort, kTimeFormatNoSeconds, timeToUse, formattedDate); - PRUnichar *formattedDatePR = formattedDate.ToNewUnicode(); + PRUnichar *formattedDatePR = ToNewUnicode(formattedDate); const PRUnichar *formatStrings[2] = { commonName, formattedDatePR }; nsString keyString = NS_ConvertASCIItoUCS2(key); nsString titleKeyString = NS_ConvertASCIItoUCS2(titleKey); diff --git a/mozilla/security/manager/ssl/src/nsCertOutliner.cpp b/mozilla/security/manager/ssl/src/nsCertOutliner.cpp index c83403af5f5..05e6e61a766 100644 --- a/mozilla/security/manager/ssl/src/nsCertOutliner.cpp +++ b/mozilla/security/manager/ssl/src/nsCertOutliner.cpp @@ -38,6 +38,7 @@ #include "nsIX509Cert.h" #include "nsIX509CertDB.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "prlog.h" #ifdef PR_LOGGING @@ -466,7 +467,7 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID, if (el != nsnull) { if (strcmp(col, "certcol") == 0) { nsAutoString oName(el->orgName); - *_retval = oName.ToNewUnicode(); + *_retval = ToNewUnicode(oName); } else { *_retval = nsnull; } @@ -483,12 +484,12 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnichar *tmp = nsnull; rv = cert->GetNickname(&tmp); nsAutoString nick(tmp); - char *tmps = nick.ToNewCString(); + char *tmps = ToNewCString(nick); char *mark = strchr(tmps, ':'); if (mark) { str = PL_strdup(mark + 1); } else { - wstr = nick.ToNewUnicode(); + wstr = ToNewUnicode(nick); } nsMemory::Free(tmp); nsMemory::Free(tmps); @@ -511,13 +512,13 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID, rv = nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("VerifiedTrue").get(), vfy); if (!NS_FAILED(rv)) - wstr = vfy.ToNewUnicode(); + wstr = ToNewUnicode(vfy); } else { nsAutoString vfy; rv = nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("VerifiedFalse").get(), vfy); if (!NS_FAILED(rv)) - wstr = vfy.ToNewUnicode(); + wstr = ToNewUnicode(vfy); } if (ocspEnabled) { nssComponent->EnableOCSP(); @@ -550,7 +551,7 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID, } if (str) { nsAutoString astr = NS_ConvertASCIItoUCS2(str); - wstr = astr.ToNewUnicode(); + wstr = ToNewUnicode(astr); } *_retval = wstr; return rv; @@ -643,7 +644,7 @@ nsCertOutliner::dumpMap() { for (int i=0; iorgName); - PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("thread desc[%d]: %s",i,td.ToNewCString())); + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("thread desc[%d]: %s", i, NS_LossyConvertUCS2toASCII(td).get())); } nsCOMPtr ct = GetCertAtIndex(i); if (ct != nsnull) { PRUnichar *goo; ct->GetCommonName(&goo); nsAutoString doo(goo); - PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("cert [%d]: %s",i,doo.ToNewCString())); + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("cert [%d]: %s", i, NS_LossyConvertUCS2toASCII(doo).get())); } } } diff --git a/mozilla/security/manager/ssl/src/nsCertTree.cpp b/mozilla/security/manager/ssl/src/nsCertTree.cpp index c83403af5f5..05e6e61a766 100644 --- a/mozilla/security/manager/ssl/src/nsCertTree.cpp +++ b/mozilla/security/manager/ssl/src/nsCertTree.cpp @@ -38,6 +38,7 @@ #include "nsIX509Cert.h" #include "nsIX509CertDB.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "prlog.h" #ifdef PR_LOGGING @@ -466,7 +467,7 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID, if (el != nsnull) { if (strcmp(col, "certcol") == 0) { nsAutoString oName(el->orgName); - *_retval = oName.ToNewUnicode(); + *_retval = ToNewUnicode(oName); } else { *_retval = nsnull; } @@ -483,12 +484,12 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID, PRUnichar *tmp = nsnull; rv = cert->GetNickname(&tmp); nsAutoString nick(tmp); - char *tmps = nick.ToNewCString(); + char *tmps = ToNewCString(nick); char *mark = strchr(tmps, ':'); if (mark) { str = PL_strdup(mark + 1); } else { - wstr = nick.ToNewUnicode(); + wstr = ToNewUnicode(nick); } nsMemory::Free(tmp); nsMemory::Free(tmps); @@ -511,13 +512,13 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID, rv = nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("VerifiedTrue").get(), vfy); if (!NS_FAILED(rv)) - wstr = vfy.ToNewUnicode(); + wstr = ToNewUnicode(vfy); } else { nsAutoString vfy; rv = nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("VerifiedFalse").get(), vfy); if (!NS_FAILED(rv)) - wstr = vfy.ToNewUnicode(); + wstr = ToNewUnicode(vfy); } if (ocspEnabled) { nssComponent->EnableOCSP(); @@ -550,7 +551,7 @@ nsCertOutliner::GetCellText(PRInt32 row, const PRUnichar *colID, } if (str) { nsAutoString astr = NS_ConvertASCIItoUCS2(str); - wstr = astr.ToNewUnicode(); + wstr = ToNewUnicode(astr); } *_retval = wstr; return rv; @@ -643,7 +644,7 @@ nsCertOutliner::dumpMap() { for (int i=0; iorgName); - PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("thread desc[%d]: %s",i,td.ToNewCString())); + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("thread desc[%d]: %s", i, NS_LossyConvertUCS2toASCII(td).get())); } nsCOMPtr ct = GetCertAtIndex(i); if (ct != nsnull) { PRUnichar *goo; ct->GetCommonName(&goo); nsAutoString doo(goo); - PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("cert [%d]: %s",i,doo.ToNewCString())); + PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("cert [%d]: %s", i, NS_LossyConvertUCS2toASCII(doo).get())); } } } diff --git a/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp b/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp index a0480662084..8d89ee0c750 100644 --- a/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp +++ b/mozilla/security/manager/ssl/src/nsKeygenHandler.cpp @@ -40,6 +40,7 @@ extern "C" { #include "nsIContent.h" #include "nsINSSDialogs.h" #include "nsKeygenThread.h" +#include "nsReadableUtils.h" //These defines are taken from the PKCS#11 spec #define CKM_RSA_PKCS_KEY_PAIR_GEN 0x00000000 @@ -186,17 +187,17 @@ nsKeygenFormProcessor::Init() nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("HighGrade").get(), str); - SECKeySizeChoiceList[0].name = str.ToNewUnicode(); + SECKeySizeChoiceList[0].name = ToNewUnicode(str); nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("MediumGrade").get(), str); - SECKeySizeChoiceList[1].name = str.ToNewUnicode(); + SECKeySizeChoiceList[1].name = ToNewUnicode(str); nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("LowGrade").get(), str); - SECKeySizeChoiceList[2].name = str.ToNewUnicode(); + SECKeySizeChoiceList[2].name = ToNewUnicode(str); return NS_OK; } @@ -282,7 +283,7 @@ GetSlotWithMechanism(PRUint32 aMechanism, i = 0; slotElement = PK11_GetFirstSafe(slotList); while (slotElement) { - tokenNameList[i] = NS_ConvertUTF8toUCS2(PK11_GetTokenName(slotElement->slot)).ToNewUnicode(); + tokenNameList[i] = ToNewUnicode(NS_ConvertUTF8toUCS2(PK11_GetTokenName(slotElement->slot))); slotElement = PK11_GetNextSafe(slotList, slotElement, PR_FALSE); i++; } @@ -385,7 +386,7 @@ nsKeygenFormProcessor::GetPublicKey(nsString& aValue, nsString& aChallenge, keyGenMechanism = CKM_RSA_PKCS_KEY_PAIR_GEN; } else if (aKeyType.Equals(dsaStr)) { char * end; - pqgString = aPqg.ToNewCString(); + pqgString = ToNewCString(aPqg); type = dsaKey; keyGenMechanism = CKM_DSA_KEY_PAIR_GEN; if (strcmp(pqgString, "null") == 0) @@ -499,7 +500,7 @@ found_match: */ pkac.spki = spkiItem; pkac.challenge.len = aChallenge.Length(); - pkac.challenge.data = (unsigned char *)aChallenge.ToNewCString(); + pkac.challenge.data = (unsigned char *)ToNewCString(aChallenge); sec_rv = DER_Encode(arena, &pkacItem, CERTPublicKeyAndChallengeTemplate, &pkac); if ( sec_rv != SECSuccess ) { diff --git a/mozilla/security/manager/ssl/src/nsNSSASN1Object.cpp b/mozilla/security/manager/ssl/src/nsNSSASN1Object.cpp index d80b3ffa539..00077c3e6e8 100644 --- a/mozilla/security/manager/ssl/src/nsNSSASN1Object.cpp +++ b/mozilla/security/manager/ssl/src/nsNSSASN1Object.cpp @@ -34,6 +34,7 @@ #include "nsNSSASN1Object.h" #include "nsIComponentManager.h" #include "secasn1.h" +#include "nsReadableUtils.h" NS_IMPL_THREADSAFE_ISUPPORTS2(nsNSSASN1Sequence, nsIASN1Sequence, nsIASN1Object); @@ -300,7 +301,7 @@ NS_IMETHODIMP nsNSSASN1Sequence::GetDisplayName(PRUnichar * *aDisplayName) { NS_ENSURE_ARG_POINTER(aDisplayName); - *aDisplayName = mDisplayName.ToNewUnicode(); + *aDisplayName = ToNewUnicode(mDisplayName); return (*aDisplayName) ? NS_OK : NS_ERROR_FAILURE; } @@ -316,7 +317,7 @@ NS_IMETHODIMP nsNSSASN1Sequence::GetDisplayValue(PRUnichar * *aDisplayValue) { NS_ENSURE_ARG_POINTER(aDisplayValue); - *aDisplayValue = mDisplayValue.ToNewUnicode(); + *aDisplayValue = ToNewUnicode(mDisplayValue); return NS_OK; } @@ -379,7 +380,7 @@ nsNSSASN1PrintableItem::~nsNSSASN1PrintableItem() NS_IMETHODIMP nsNSSASN1PrintableItem::GetDisplayValue(PRUnichar * *aValue) { - *aValue = mValue.ToNewUnicode(); + *aValue = ToNewUnicode(mValue); return NS_OK; } @@ -461,7 +462,7 @@ NS_IMETHODIMP nsNSSASN1PrintableItem::GetDisplayName(PRUnichar * *aDisplayName) { NS_ENSURE_ARG_POINTER(aDisplayName); - *aDisplayName = mDisplayName.ToNewUnicode(); + *aDisplayName = ToNewUnicode(mDisplayName); return (*aDisplayName) ? NS_OK : NS_ERROR_FAILURE; } diff --git a/mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp b/mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp index 4571652e1bf..8770bd98e1f 100644 --- a/mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp +++ b/mozilla/security/manager/ssl/src/nsNSSCallbacks.cpp @@ -178,7 +178,7 @@ char* PK11PasswordPrompt(PK11SlotInfo* slot, PRBool retry, void* arg) { rv = proxyPrompt->PromptPassword(nsnull, promptString.get(), &password, nsnull, nsnull, &value); if (NS_SUCCEEDED(rv) && value) { - char* str = nsString(password).ToNewCString(); + char* str = ToNewCString(nsDependentString(password)); Recycle(password); return str; } diff --git a/mozilla/security/manager/ssl/src/nsNSSCertificate.cpp b/mozilla/security/manager/ssl/src/nsNSSCertificate.cpp index 569d410a7d0..0137fdf34af 100644 --- a/mozilla/security/manager/ssl/src/nsNSSCertificate.cpp +++ b/mozilla/security/manager/ssl/src/nsNSSCertificate.cpp @@ -32,7 +32,7 @@ * may use your version of this file under either the MPL or the * GPL. * - * $Id: nsNSSCertificate.cpp,v 1.52 2001-09-25 00:08:48 ddrinan%netscape.com Exp $ + * $Id: nsNSSCertificate.cpp,v 1.53 2001-09-29 08:27:59 jaggernaut%netscape.com Exp $ */ #include "prmem.h" @@ -51,6 +51,7 @@ #include "nsNSSASN1Object.h" #include "nsString.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIDateTimeFormat.h" #include "nsDateTimeFormatCID.h" #include "nsILocaleService.h" @@ -539,7 +540,7 @@ NS_IMETHODIMP nsX509CertValidity::GetNotBeforeLocalTime(PRUnichar **aNotBeforeLo PR_ExplodeTime(mNotBefore, PR_LocalTimeParameters, &explodedTime); dateFormatter->FormatPRExplodedTime(nsnull, kDateFormatShort, kTimeFormatSecondsForce24Hour, &explodedTime, date); - *aNotBeforeLocalTime = date.ToNewUnicode(); + *aNotBeforeLocalTime = ToNewUnicode(date); return NS_OK; } @@ -561,7 +562,7 @@ NS_IMETHODIMP nsX509CertValidity::GetNotBeforeGMT(PRUnichar **aNotBeforeGMT) PR_ExplodeTime(mNotBefore, PR_GMTParameters, &explodedTime); dateFormatter->FormatPRExplodedTime(nsnull, kDateFormatShort, kTimeFormatSecondsForce24Hour, &explodedTime, date); - *aNotBeforeGMT = date.ToNewUnicode(); + *aNotBeforeGMT = ToNewUnicode(date); return NS_OK; } @@ -596,7 +597,7 @@ NS_IMETHODIMP nsX509CertValidity::GetNotAfterLocalTime(PRUnichar **aNotAfterLoca PR_ExplodeTime(mNotAfter, PR_LocalTimeParameters, &explodedTime); dateFormatter->FormatPRExplodedTime(nsnull, kDateFormatShort, kTimeFormatSecondsForce24Hour, &explodedTime, date); - *aNotAfterLocaltime = date.ToNewUnicode(); + *aNotAfterLocaltime = ToNewUnicode(date); return NS_OK; } @@ -618,7 +619,7 @@ NS_IMETHODIMP nsX509CertValidity::GetNotAfterGMT(PRUnichar **aNotAfterGMT) PR_ExplodeTime(mNotAfter, PR_GMTParameters, &explodedTime); dateFormatter->FormatPRExplodedTime(nsnull, kDateFormatShort, kTimeFormatSecondsForce24Hour, &explodedTime, date); - *aNotAfterGMT = date.ToNewUnicode(); + *aNotAfterGMT = ToNewUnicode(date); return NS_OK; } @@ -731,8 +732,7 @@ nsNSSCertificate::GetNickname(PRUnichar **_nickname) { NS_ENSURE_ARG(_nickname); const char *nickname = (mCert->nickname) ? mCert->nickname : "(no nickname)"; - nsAutoString nn = NS_ConvertASCIItoUCS2(nickname); - *_nickname = nn.ToNewUnicode(); + *_nickname = ToNewUnicode(nsDependentCString(nickname)); return NS_OK; } @@ -742,8 +742,7 @@ nsNSSCertificate::GetEmailAddress(PRUnichar **_emailAddress) { NS_ENSURE_ARG(_emailAddress); const char *email = (mCert->emailAddr) ? mCert->emailAddr : "(no email address)"; - nsAutoString em = NS_ConvertASCIItoUCS2(email); - *_emailAddress = em.ToNewUnicode(); + *_emailAddress = ToNewUnicode(nsDependentCString(email)); return NS_OK; } @@ -755,10 +754,9 @@ nsNSSCertificate::GetCommonName(PRUnichar **aCommonName) if (mCert) { char *commonName = CERT_GetCommonName(&mCert->subject); if (commonName) { - nsAutoString cn = NS_ConvertASCIItoUCS2(commonName); - *aCommonName = cn.ToNewUnicode(); + *aCommonName = ToNewUnicode(nsDependentCString(commonName)); } /*else { - *aCommonName = NS_LITERAL_STRING("").get(), + *aCommonName = ToNewUnicode(NS_LITERAL_STRING("")), }*/ } return NS_OK; @@ -772,10 +770,9 @@ nsNSSCertificate::GetOrganization(PRUnichar **aOrganization) if (mCert) { char *organization = CERT_GetOrgName(&mCert->subject); if (organization) { - nsAutoString org = NS_ConvertASCIItoUCS2(organization); - *aOrganization = org.ToNewUnicode(); + *aOrganization = ToNewUnicode(nsDependentCString(organization)); } /*else { - *aOrganization = NS_LITERAL_STRING("").get(), + *aOrganization = ToNewUnicode(NS_LITERAL_STRING("")), }*/ } return NS_OK; @@ -789,8 +786,7 @@ nsNSSCertificate::GetIssuerCommonName(PRUnichar **aCommonName) if (mCert) { char *commonName = CERT_GetCommonName(&mCert->issuer); if (commonName) { - nsAutoString cn = NS_ConvertASCIItoUCS2(commonName); - *aCommonName = cn.ToNewUnicode(); + *aCommonName = ToNewUnicode(nsDependentCString(commonName)); } } return NS_OK; @@ -804,8 +800,7 @@ nsNSSCertificate::GetIssuerOrganization(PRUnichar **aOrganization) if (mCert) { char *organization = CERT_GetOrgName(&mCert->issuer); if (organization) { - nsAutoString org = NS_ConvertASCIItoUCS2(organization); - *aOrganization = org.ToNewUnicode(); + *aOrganization = ToNewUnicode(nsDependentCString(organization)); } } return NS_OK; @@ -819,8 +814,7 @@ nsNSSCertificate::GetIssuerOrganizationUnit(PRUnichar **aOrganizationUnit) if (mCert) { char *organizationUnit = CERT_GetOrgUnitName(&mCert->issuer); if (organizationUnit) { - nsAutoString orgUnit = NS_ConvertASCIItoUCS2(organizationUnit); - *aOrganizationUnit = orgUnit.ToNewUnicode(); + *aOrganizationUnit = ToNewUnicode(nsDependentCString(organizationUnit)); } } return NS_OK; @@ -851,10 +845,9 @@ nsNSSCertificate::GetOrganizationalUnit(PRUnichar **aOrganizationalUnit) if (mCert) { char *orgunit = CERT_GetOrgUnitName(&mCert->subject); if (orgunit) { - nsAutoString ou = NS_ConvertASCIItoUCS2(orgunit); - *aOrganizationalUnit = ou.ToNewUnicode(); + *aOrganizationalUnit = ToNewUnicode(nsDependentCString(orgunit)); } /*else { - *aOrganizationalUnit = NS_LITERAL_STRING("").get(), + *aOrganizationalUnit = ToNewUnicode(NS_LITERAL_STRING("")), }*/ } return NS_OK; @@ -924,8 +917,7 @@ nsNSSCertificate::GetSubjectName(PRUnichar **_subjectName) NS_ENSURE_ARG(_subjectName); *_subjectName = nsnull; if (mCert->subjectName) { - nsAutoString sn = NS_ConvertASCIItoUCS2(mCert->subjectName); - *_subjectName = sn.ToNewUnicode(); + *_subjectName = ToNewUnicode(nsDependentCString(mCert->subjectName)); return NS_OK; } return NS_ERROR_FAILURE; @@ -938,8 +930,7 @@ nsNSSCertificate::GetIssuerName(PRUnichar **_issuerName) NS_ENSURE_ARG(_issuerName); *_issuerName = nsnull; if (mCert->issuerName) { - nsAutoString in = NS_ConvertASCIItoUCS2(mCert->issuerName); - *_issuerName = in.ToNewUnicode(); + *_issuerName = ToNewUnicode(nsDependentCString(mCert->issuerName)); return NS_OK; } return NS_ERROR_FAILURE; @@ -951,11 +942,9 @@ nsNSSCertificate::GetSerialNumber(PRUnichar **_serialNumber) { NS_ENSURE_ARG(_serialNumber); *_serialNumber = nsnull; - char *tmpstr = CERT_Hexify(&mCert->serialNumber, 1); - if (tmpstr) { - nsAutoString sn = NS_ConvertASCIItoUCS2(tmpstr); - *_serialNumber = sn.ToNewUnicode(); - PR_Free(tmpstr); + nsXPIDLCString tmpstr; tmpstr.Adopt(CERT_Hexify(&mCert->serialNumber, 1)); + if (tmpstr.get()) { + *_serialNumber = ToNewUnicode(tmpstr); return NS_OK; } return NS_ERROR_FAILURE; @@ -967,12 +956,10 @@ nsNSSCertificate::GetRsaPubModulus(PRUnichar **_rsaPubModulus) { NS_ENSURE_ARG(_rsaPubModulus); *_rsaPubModulus = nsnull; - //char *tmpstr = CERT_Hexify(&mCert->serialNumber, 1); - char *tmpstr = PL_strdup("not yet implemented"); - if (tmpstr) { - nsAutoString rsap = NS_ConvertASCIItoUCS2(tmpstr); - *_rsaPubModulus = rsap.ToNewUnicode(); - PR_Free(tmpstr); + //nsXPIDLCString tmpstr; tmpstr.Adopt(CERT_Hexify(&mCert->serialNumber, 1)); + NS_NAMED_LITERAL_CSTRING(tmpstr, "not yet implemented"); + if (tmpstr.get()) { + *_rsaPubModulus = ToNewUnicode(tmpstr); return NS_OK; } return NS_ERROR_FAILURE; @@ -985,18 +972,15 @@ nsNSSCertificate::GetSha1Fingerprint(PRUnichar **_sha1Fingerprint) NS_ENSURE_ARG(_sha1Fingerprint); *_sha1Fingerprint = nsnull; unsigned char fingerprint[20]; - char *fpStr = NULL; SECItem fpItem; memset(fingerprint, 0, sizeof fingerprint); PK11_HashBuf(SEC_OID_SHA1, fingerprint, mCert->derCert.data, mCert->derCert.len); fpItem.data = fingerprint; fpItem.len = SHA1_LENGTH; - fpStr = CERT_Hexify(&fpItem, 1); - if (fpStr) { - nsAutoString sha1str = NS_ConvertASCIItoUCS2(fpStr); - *_sha1Fingerprint = sha1str.ToNewUnicode(); - PR_Free(fpStr); + nsXPIDLCString fpStr; fpStr.Adopt(CERT_Hexify(&fpItem, 1)); + if (fpStr.get()) { + *_sha1Fingerprint = ToNewUnicode(fpStr); return NS_OK; } return NS_ERROR_FAILURE; @@ -1009,18 +993,15 @@ nsNSSCertificate::GetMd5Fingerprint(PRUnichar **_md5Fingerprint) NS_ENSURE_ARG(_md5Fingerprint); *_md5Fingerprint = nsnull; unsigned char fingerprint[20]; - char *fpStr = NULL; SECItem fpItem; memset(fingerprint, 0, sizeof fingerprint); PK11_HashBuf(SEC_OID_MD5, fingerprint, mCert->derCert.data, mCert->derCert.len); fpItem.data = fingerprint; fpItem.len = MD5_LENGTH; - fpStr = CERT_Hexify(&fpItem, 1); - if (fpStr) { - nsAutoString md5str = NS_ConvertASCIItoUCS2(fpStr); - *_md5Fingerprint = md5str.ToNewUnicode(); - PR_Free(fpStr); + nsXPIDLCString fpStr; fpStr.Adopt(CERT_Hexify(&fpItem, 1)); + if (fpStr.get()) { + *_md5Fingerprint = ToNewUnicode(fpStr); return NS_OK; } return NS_ERROR_FAILURE; @@ -1045,7 +1026,7 @@ nsNSSCertificate::GetIssuedDate(PRUnichar **_issuedDate) nsAutoString date; dateFormatter->FormatPRTime(nsnull, kDateFormatShort, kTimeFormatNone, beforeTime, date); - *_issuedDate = date.ToNewUnicode(); + *_issuedDate = ToNewUnicode(date); return NS_OK; } @@ -1068,7 +1049,7 @@ nsNSSCertificate::GetExpiresDate(PRUnichar **_expiresDate) nsAutoString date; dateFormatter->FormatPRTime(nsnull, kDateFormatShort, kTimeFormatNone, afterTime, date); - *_expiresDate = date.ToNewUnicode(); + *_expiresDate = ToNewUnicode(date); return NS_OK; } @@ -1089,8 +1070,7 @@ nsNSSCertificate::GetTokenName(PRUnichar **aTokenName) if (mCert->slot && !mCert->isperm) { char *token = PK11_GetTokenName(mCert->slot); if (token) { - nsAutoString tok = NS_ConvertASCIItoUCS2(token); - *aTokenName = tok.ToNewUnicode(); + *aTokenName = ToNewUnicode(nsDependentCString(token)); } } else { nsresult rv; @@ -1101,7 +1081,7 @@ nsNSSCertificate::GetTokenName(PRUnichar **aTokenName) rv = nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("InternalToken").get(), tok); if (!NS_FAILED(rv)) - *aTokenName = tok.ToNewUnicode(); + *aTokenName = ToNewUnicode(tok); } } return NS_OK; @@ -1217,114 +1197,114 @@ nsNSSCertificate::GetUsageArray(char *suffix, certUsageSSLClient, NULL) == SECSuccess) { // add client to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifySSLClient").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifySSLClient")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageSSLServer, NULL) == SECSuccess) { // add server to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifySSLServer").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifySSLServer")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageSSLServerWithStepUp, NULL) == SECSuccess) { // add stepup to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifySSLStepUp").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifySSLStepUp")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageEmailSigner, NULL) == SECSuccess) { // add signer to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifyEmailSigner").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifyEmailSigner")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageEmailRecipient, NULL) == SECSuccess) { // add recipient to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifyEmailRecip").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifyEmailRecip")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageObjectSigner, NULL) == SECSuccess) { // add objsigner to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifyObjSign").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifyObjSign")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } #if 0 if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageProtectedObjectSigner, NULL) == SECSuccess) { // add protected objsigner to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifyProtectObjSign").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifyProtectObjSign")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageUserCertImport, NULL) == SECSuccess) { // add user import to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifyUserImport").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifyUserImport")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } #endif if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageSSLCA, NULL) == SECSuccess) { // add SSL CA to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifySSLCA").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifySSLCA")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } #if 0 if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageVerifyCA, NULL) == SECSuccess) { // add verify CA to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifyCAVerifier").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifyCAVerifier")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } #endif if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageStatusResponder, NULL) == SECSuccess) { // add status responder to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifyStatusResponder").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifyStatusResponder")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } #if 0 if (CERT_VerifyCertNow(defaultcertdb, mCert, PR_TRUE, certUsageAnyCA, NULL) == SECSuccess) { // add any CA to usage nsAutoString verifyDesc; - nsAutoString typestr(NS_LITERAL_STRING("VerifyAnyCA").get()); + nsAutoString typestr(NS_LITERAL_STRING("VerifyAnyCA")); typestr.AppendWithConversion(suffix); rv = nssComponent->GetPIPNSSBundleString(typestr.get(), verifyDesc); - tmpUsages[tmpCount++] = verifyDesc.ToNewUnicode(); + tmpUsages[tmpCount++] = ToNewUnicode(verifyDesc); } #endif if (tmpCount == 0) { @@ -1860,7 +1840,7 @@ nsNSSCertificate::GetPurposes(PRUint32 *_verified, nsMemory::Free(tmpUsages[i]); } if (_purposes != NULL) { // skip it for verify-only - *_purposes = porpoises.ToNewUnicode(); + *_purposes = ToNewUnicode(porpoises); } return NS_OK; } @@ -2098,11 +2078,10 @@ ProcessName(CERTName *name, nsINSSComponent *nssComponent, PRUnichar **value) nssComponent->PIPBundleFormatStringFromName(NS_LITERAL_STRING("AVATemplate").get(), params, 2, getter_Copies(temp)); - finalString.Append(temp.get()); - finalString.Append(NS_LITERAL_STRING("\n").get()); + finalString += temp + NS_LITERAL_STRING("\n"); } } - *value = finalString.ToNewUnicode(); + *value = ToNewUnicode(finalString); return NS_OK; } @@ -2822,12 +2801,12 @@ default_nickname(CERTCertificate *cert, nsIInterfaceRequestor* ctx) nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("nick_template").get(), tmpNickFmt); - nickFmt = tmpNickFmt.ToNewUTF8String(); + nickFmt = ToNewUTF8String(tmpNickFmt); nssComponent->GetPIPNSSBundleString( NS_LITERAL_STRING("nick_template_with_num").get(), tmpNickFmtWithNum); - nickFmtWithNum = tmpNickFmtWithNum.ToNewUTF8String(); + nickFmtWithNum = ToNewUTF8String(tmpNickFmtWithNum); nickname = PR_smprintf(nickFmt, username, caname); @@ -3179,7 +3158,7 @@ nsOCSPResponder::~nsOCSPResponder() NS_IMETHODIMP nsOCSPResponder::GetResponseSigner(PRUnichar** aCA) { NS_ENSURE_ARG(aCA); - *aCA = mCA.ToNewUnicode(); + *aCA = ToNewUnicode(mCA); return NS_OK; } @@ -3187,7 +3166,7 @@ NS_IMETHODIMP nsOCSPResponder::GetResponseSigner(PRUnichar** aCA) NS_IMETHODIMP nsOCSPResponder::GetServiceURL(PRUnichar** aURL) { NS_ENSURE_ARG(aURL); - *aURL = mURL.ToNewUnicode(); + *aURL = ToNewUnicode(mURL); return NS_OK; } @@ -3289,11 +3268,11 @@ GetOCSPResponders (CERTCertificate *aCert, // Get the AIA and nickname // serviceURL = CERT_GetOCSPAuthorityInfoAccessLocation(aCert); if (serviceURL) { - url = NS_ConvertASCIItoUCS2(serviceURL).ToNewUnicode(); + url = ToNewUnicode(nsDependentCString(serviceURL)); } nickname = aCert->nickname; - nn = NS_ConvertASCIItoUCS2(nickname).ToNewUnicode(); + nn = ToNewUnicode(nsDependentCString(nickname)); nsCOMPtr new_entry = new nsOCSPResponder(nn, url); @@ -3403,7 +3382,7 @@ nsNSSCertificateDB::getCertNames(CERTCertList *certList, certstr += certname; certstr.AppendWithConversion(DELIM); certstr += keystr; - tmpArray[i++] = certstr.ToNewUnicode(); + tmpArray[i++] = ToNewUnicode(certstr); } } finish: @@ -3560,7 +3539,7 @@ nsCrlEntry::~nsCrlEntry() NS_IMETHODIMP nsCrlEntry::GetOrg(PRUnichar** aOrg) { NS_ENSURE_ARG(aOrg); - *aOrg = mOrg.ToNewUnicode(); + *aOrg = ToNewUnicode(mOrg); return NS_OK; } @@ -3568,7 +3547,7 @@ NS_IMETHODIMP nsCrlEntry::GetOrg(PRUnichar** aOrg) NS_IMETHODIMP nsCrlEntry::GetOrgUnit(PRUnichar** aOrgUnit) { NS_ENSURE_ARG(aOrgUnit); - *aOrgUnit = mOrgUnit.ToNewUnicode(); + *aOrgUnit = ToNewUnicode(mOrgUnit); return NS_OK; } @@ -3576,7 +3555,7 @@ NS_IMETHODIMP nsCrlEntry::GetOrgUnit(PRUnichar** aOrgUnit) NS_IMETHODIMP nsCrlEntry::GetLastUpdate(PRUnichar** aLastUpdate) { NS_ENSURE_ARG(aLastUpdate); - *aLastUpdate = mLastUpdate.ToNewUnicode(); + *aLastUpdate = ToNewUnicode(mLastUpdate); return NS_OK; } @@ -3584,7 +3563,7 @@ NS_IMETHODIMP nsCrlEntry::GetLastUpdate(PRUnichar** aLastUpdate) NS_IMETHODIMP nsCrlEntry::GetNextUpdate(PRUnichar** aNextUpdate) { NS_ENSURE_ARG(aNextUpdate); - *aNextUpdate = mNextUpdate.ToNewUnicode(); + *aNextUpdate = ToNewUnicode(mNextUpdate); return NS_OK; } diff --git a/mozilla/security/manager/ssl/src/nsNSSComponent.cpp b/mozilla/security/manager/ssl/src/nsNSSComponent.cpp index b6c00bcc9c5..543f4ec89e6 100644 --- a/mozilla/security/manager/ssl/src/nsNSSComponent.cpp +++ b/mozilla/security/manager/ssl/src/nsNSSComponent.cpp @@ -49,6 +49,7 @@ #include "nsIPrompt.h" #include "nsProxiedService.h" #include "nsICertificatePrincipal.h" +#include "nsReadableUtils.h" #include "nss.h" #include "pk11func.h" @@ -238,7 +239,7 @@ nsNSSComponent::InstallLoadableRoots() nsMemory::Free(processDir); #endif /* If a module exists with the same name, delete it. */ - char *modNameCString = modName.ToNewCString(); + char *modNameCString = ToNewCString(modName); int modType; SECMOD_DeleteModule(modNameCString, &modType); SECMOD_AddNewModule(modNameCString, fullModuleName, 0, 0); @@ -261,7 +262,7 @@ nsNSSComponent::GetPK11String(const PRUnichar *name, PRUint32 len) str = (char *)PR_Malloc(len+1); rv = GetPIPNSSBundleString(name, nsstr); if (NS_FAILED(rv)) return NULL; - tmpstr = nsstr.ToNewCString(); + tmpstr = ToNewCString(nsstr); if (!tmpstr) return NULL; tmplen = strlen(tmpstr); if (len > tmplen) { diff --git a/mozilla/security/manager/ssl/src/nsNSSIOLayer.cpp b/mozilla/security/manager/ssl/src/nsNSSIOLayer.cpp index e6a3dffc3ee..3e7d549b4e7 100644 --- a/mozilla/security/manager/ssl/src/nsNSSIOLayer.cpp +++ b/mozilla/security/manager/ssl/src/nsNSSIOLayer.cpp @@ -55,6 +55,7 @@ #include "nsDateTimeFormatCID.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsVoidArray.h" #include "nsHashtable.h" @@ -263,7 +264,7 @@ nsNSSSocketInfo::GetShortSecurityDescription(PRUnichar** aText) { if (mShortDesc.IsEmpty()) *aText = nsnull; else - *aText = mShortDesc.ToNewUnicode(); + *aText = ToNewUnicode(mShortDesc); return NS_OK; } @@ -957,18 +958,13 @@ nsContinueDespiteCertError(nsNSSSocketInfo *infoObject, break; case SSL_ERROR_BAD_CERT_DOMAIN: { - char *url = SSL_RevealURL(sslSocket); - NS_ASSERTION(url, "could not find valid URL in ssl socket"); - nsAutoString autoURL = NS_ConvertASCIItoUCS2(url); - PRUnichar *autoUnichar = autoURL.ToNewUnicode(); - NS_ASSERTION(autoUnichar, "Could not allocate new PRUnichar"); - rv = badCertHandler->MismatchDomain(csi, autoUnichar, + nsXPIDLCString url; url.Adopt(SSL_RevealURL(sslSocket)); + NS_ASSERTION(url.get(), "could not find valid URL in ssl socket"); + rv = badCertHandler->MismatchDomain(csi, NS_ConvertASCIItoUCS2(url).get(), callBackCert, &retVal); - Recycle(autoUnichar); if (NS_SUCCEEDED(rv) && retVal) { rv = CERT_AddOKDomainName(peerCert, url); } - PR_Free(url); } break; case SEC_ERROR_EXPIRED_CERTIFICATE: @@ -981,18 +977,13 @@ nsContinueDespiteCertError(nsNSSSocketInfo *infoObject, break; case SEC_ERROR_CRL_EXPIRED: { - char *url = SSL_RevealURL(sslSocket); + nsXPIDLCString url; url.Adopt(SSL_RevealURL(sslSocket)); NS_ASSERTION(url, "could not find valid URL in ssl socket"); - nsAutoString autoURL = NS_ConvertASCIItoUCS2(url); - PRUnichar *autoUnichar = autoURL.ToNewUnicode(); - NS_ASSERTION(autoUnichar, "Could not allocate new PRUnichar"); - rv = badCertHandler->CrlNextupdate(csi, autoUnichar, callBackCert); - Recycle(autoUnichar); + rv = badCertHandler->CrlNextupdate(csi, NS_ConvertASCIItoUCS2(url).get(), callBackCert); if (NS_SUCCEEDED(rv) && retVal) { - rv = CERT_AddOKDomainName(peerCert, url); + rv = CERT_AddOKDomainName(peerCert, url.get()); } retVal = PR_FALSE; - PR_Free(url); } break; default: @@ -1648,9 +1639,6 @@ SECStatus nsNSS_SSLGetClientAuthData(void* arg, PRFileDesc* socket, /* user selects a cert to present */ int i; nsIClientAuthDialogs *dialogs = NULL; - PRUnichar *cn = NULL; - PRUnichar *org = NULL; - PRUnichar *issuer = NULL; PRInt32 selectedIndex = -1; PRUnichar **certNicknameList = NULL; PRUnichar **certDetailsList = NULL; @@ -1721,9 +1709,9 @@ SECStatus nsNSS_SSLGetClientAuthData(void* arg, PRFileDesc* socket, } /* Get CN and O of the subject and O of the issuer */ - cn = NS_ConvertUTF8toUCS2(CERT_GetCommonName(&serverCert->subject)).ToNewUnicode(); - org = NS_ConvertUTF8toUCS2(CERT_GetOrgName(&serverCert->subject)).ToNewUnicode(); - issuer = NS_ConvertUTF8toUCS2(CERT_GetOrgName(&serverCert->issuer)).ToNewUnicode(); + NS_ConvertUTF8toUCS2 cn(CERT_GetCommonName(&serverCert->subject)); + NS_ConvertUTF8toUCS2 org(CERT_GetOrgName(&serverCert->subject)); + NS_ConvertUTF8toUCS2 issuer(CERT_GetOrgName(&serverCert->issuer)); certNicknameList = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * nicknames->numnicknames); certDetailsList = (PRUnichar **)nsMemory::Alloc(sizeof(PRUnichar *) * nicknames->numnicknames); @@ -1873,8 +1861,8 @@ SECStatus nsNSS_SSLGetClientAuthData(void* arg, PRFileDesc* socket, Subject: $issuerName */ - certNicknameList[i] = nickWithSerial.ToNewUnicode(); - certDetailsList[i] = str.ToNewUnicode(); + certNicknameList[i] = ToNewUnicode(nickWithSerial); + certDetailsList[i] = ToNewUnicode(str); } NS_RELEASE(tempCert); @@ -1885,7 +1873,7 @@ SECStatus nsNSS_SSLGetClientAuthData(void* arg, PRFileDesc* socket, if (NS_FAILED(rv)) goto loser; - rv = dialogs->ChooseCertificate(info, cn, org, issuer, + rv = dialogs->ChooseCertificate(info, cn.get(), org.get(), issuer.get(), (const PRUnichar**)certNicknameList, (const PRUnichar**)certDetailsList, nicknames->numnicknames, &selectedIndex, &canceled); diff --git a/mozilla/security/manager/ssl/src/nsPK11TokenDB.cpp b/mozilla/security/manager/ssl/src/nsPK11TokenDB.cpp index bff9d71fa01..48ed665585f 100644 --- a/mozilla/security/manager/ssl/src/nsPK11TokenDB.cpp +++ b/mozilla/security/manager/ssl/src/nsPK11TokenDB.cpp @@ -24,6 +24,7 @@ #include "nsIPK11TokenDB.h" #include "prerror.h" #include "secerr.h" +#include "nsReadableUtils.h" #include "nsPK11TokenDB.h" @@ -81,7 +82,7 @@ nsPK11Token::~nsPK11Token() /* readonly attribute wstring tokenName; */ NS_IMETHODIMP nsPK11Token::GetTokenName(PRUnichar * *aTokenName) { - *aTokenName = mTokenName.ToNewUnicode(); + *aTokenName = ToNewUnicode(mTokenName); if (!*aTokenName) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; @@ -90,7 +91,7 @@ NS_IMETHODIMP nsPK11Token::GetTokenName(PRUnichar * *aTokenName) /* readonly attribute wstring tokenDesc; */ NS_IMETHODIMP nsPK11Token::GetTokenLabel(PRUnichar **aTokLabel) { - *aTokLabel = mTokenLabel.ToNewUnicode(); + *aTokLabel = ToNewUnicode(mTokenLabel); if (!*aTokLabel) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -98,7 +99,7 @@ NS_IMETHODIMP nsPK11Token::GetTokenLabel(PRUnichar **aTokLabel) /* readonly attribute wstring tokenManID; */ NS_IMETHODIMP nsPK11Token::GetTokenManID(PRUnichar **aTokManID) { - *aTokManID = mTokenManID.ToNewUnicode(); + *aTokManID = ToNewUnicode(mTokenManID); if (!*aTokManID) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -106,7 +107,7 @@ NS_IMETHODIMP nsPK11Token::GetTokenManID(PRUnichar **aTokManID) /* readonly attribute wstring tokenHWVersion; */ NS_IMETHODIMP nsPK11Token::GetTokenHWVersion(PRUnichar **aTokHWVersion) { - *aTokHWVersion = mTokenHWVersion.ToNewUnicode(); + *aTokHWVersion = ToNewUnicode(mTokenHWVersion); if (!*aTokHWVersion) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -114,7 +115,7 @@ NS_IMETHODIMP nsPK11Token::GetTokenHWVersion(PRUnichar **aTokHWVersion) /* readonly attribute wstring tokenFWVersion; */ NS_IMETHODIMP nsPK11Token::GetTokenFWVersion(PRUnichar **aTokFWVersion) { - *aTokFWVersion = mTokenFWVersion.ToNewUnicode(); + *aTokFWVersion = ToNewUnicode(mTokenFWVersion); if (!*aTokFWVersion) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -122,7 +123,7 @@ NS_IMETHODIMP nsPK11Token::GetTokenFWVersion(PRUnichar **aTokFWVersion) /* readonly attribute wstring tokenSerialNumber; */ NS_IMETHODIMP nsPK11Token::GetTokenSerialNumber(PRUnichar **aTokSerialNum) { - *aTokSerialNum = mTokenSerialNum.ToNewUnicode(); + *aTokSerialNum = ToNewUnicode(mTokenSerialNum); if (!*aTokSerialNum) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } diff --git a/mozilla/security/manager/ssl/src/nsPKCS11Slot.cpp b/mozilla/security/manager/ssl/src/nsPKCS11Slot.cpp index 9f3cbeffab3..e14721ac8b9 100644 --- a/mozilla/security/manager/ssl/src/nsPKCS11Slot.cpp +++ b/mozilla/security/manager/ssl/src/nsPKCS11Slot.cpp @@ -39,6 +39,7 @@ #include "nsCOMPtr.h" #include "nsISupportsArray.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "secmod.h" @@ -87,18 +88,15 @@ nsPKCS11Slot::GetName(PRUnichar **aName) { char *csn = PK11_GetSlotName(mSlot); if (strlen(csn) > 0) { - nsAutoString sn = NS_ConvertUTF8toUCS2(csn); - *aName = sn.ToNewUnicode(); + *aName = ToNewUnicode(NS_ConvertUTF8toUCS2(csn)); } else if (PK11_HasRootCerts(mSlot)) { // This is a workaround to an NSS bug - the root certs module has // no slot name. Not bothering to localize, because this is a workaround // and for now all the slot names returned by NSS are char * anyway. - nsAutoString sn(NS_LITERAL_STRING("Root Certificates").get()); - *aName = sn.ToNewUnicode(); + *aName = ToNewUnicode(NS_LITERAL_STRING("Root Certificates")); } else { // same as above, this is a catch-all - nsAutoString sn(NS_LITERAL_STRING("Unnamed Slot").get()); - *aName = sn.ToNewUnicode(); + *aName = ToNewUnicode(NS_LITERAL_STRING("Unnamed Slot")); } if (!*aName) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; @@ -108,7 +106,7 @@ nsPKCS11Slot::GetName(PRUnichar **aName) NS_IMETHODIMP nsPKCS11Slot::GetDesc(PRUnichar **aDesc) { - *aDesc = mSlotDesc.ToNewUnicode(); + *aDesc = ToNewUnicode(mSlotDesc); if (!*aDesc) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -117,7 +115,7 @@ nsPKCS11Slot::GetDesc(PRUnichar **aDesc) NS_IMETHODIMP nsPKCS11Slot::GetManID(PRUnichar **aManID) { - *aManID = mSlotManID.ToNewUnicode(); + *aManID = ToNewUnicode(mSlotManID); if (!*aManID) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -126,7 +124,7 @@ nsPKCS11Slot::GetManID(PRUnichar **aManID) NS_IMETHODIMP nsPKCS11Slot::GetHWVersion(PRUnichar **aHWVersion) { - *aHWVersion = mSlotHWVersion.ToNewUnicode(); + *aHWVersion = ToNewUnicode(mSlotHWVersion); if (!*aHWVersion) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -135,7 +133,7 @@ nsPKCS11Slot::GetHWVersion(PRUnichar **aHWVersion) NS_IMETHODIMP nsPKCS11Slot::GetFWVersion(PRUnichar **aFWVersion) { - *aFWVersion = mSlotFWVersion.ToNewUnicode(); + *aFWVersion = ToNewUnicode(mSlotFWVersion); if (!*aFWVersion) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -156,8 +154,7 @@ nsPKCS11Slot::GetToken(nsIPK11Token **_retval) NS_IMETHODIMP nsPKCS11Slot::GetTokenName(PRUnichar **aName) { - nsAutoString tn = NS_ConvertUTF8toUCS2(PK11_GetTokenName(mSlot)); - *aName = tn.ToNewUnicode(); + *aName = ToNewUnicode(NS_ConvertUTF8toUCS2(PK11_GetTokenName(mSlot))); if (!*aName) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -198,8 +195,7 @@ nsPKCS11Module::~nsPKCS11Module() NS_IMETHODIMP nsPKCS11Module::GetName(PRUnichar **aName) { - nsAutoString mn = NS_ConvertUTF8toUCS2(mModule->commonName); - *aName = mn.ToNewUnicode(); + *aName = ToNewUnicode(NS_ConvertUTF8toUCS2(mModule->commonName)); return NS_OK; } @@ -207,8 +203,7 @@ nsPKCS11Module::GetName(PRUnichar **aName) NS_IMETHODIMP nsPKCS11Module::GetLibName(PRUnichar **aName) { - nsAutoString ln = NS_ConvertUTF8toUCS2(mModule->dllName); - *aName = ln.ToNewUnicode(); + *aName = ToNewUnicode(NS_ConvertUTF8toUCS2(mModule->dllName)); return NS_OK; } @@ -218,7 +213,7 @@ nsPKCS11Module::FindSlotByName(const PRUnichar *aName, nsIPKCS11Slot **_retval) { char *asciiname = NULL; - asciiname = NS_ConvertUCS2toUTF8(aName).ToNewCString(); + asciiname = ToNewUTF8String(nsDependentString(aName)); PR_LOG(gPIPNSSLog, PR_LOG_DEBUG, ("Getting \"%s\"\n", asciiname)); PK11SlotInfo *slotinfo = SECMOD_FindSlot(mModule, asciiname); if (!slotinfo) { diff --git a/mozilla/security/manager/ssl/src/nsPKCS12Blob.cpp b/mozilla/security/manager/ssl/src/nsPKCS12Blob.cpp index c69297b885d..e6ff904b38f 100644 --- a/mozilla/security/manager/ssl/src/nsPKCS12Blob.cpp +++ b/mozilla/security/manager/ssl/src/nsPKCS12Blob.cpp @@ -31,7 +31,7 @@ * may use your version of this file under either the MPL or the * GPL. * - * $Id: nsPKCS12Blob.cpp,v 1.19 2001-08-22 04:05:45 javi%netscape.com Exp $ + * $Id: nsPKCS12Blob.cpp,v 1.20 2001-09-29 08:28:00 jaggernaut%netscape.com Exp $ */ #include "prmem.h" @@ -49,6 +49,7 @@ #include "nsNSSHelper.h" #include "nsPKCS12Blob.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsFileStream.h" #include "nsXPIDLString.h" #include "nsDirectoryServiceDefs.h" @@ -148,7 +149,7 @@ nsPKCS12Blob::ImportFromFile(nsILocalFile *file) } mToken->GetTokenName(getter_Copies(tokenName)); - tokenNameCString.Adopt(NS_ConvertUCS2toUTF8(tokenName).ToNewCString()); + tokenNameCString.Adopt(ToNewUTF8String(tokenName)); tokNameRef = tokenNameCString; //I do this here so that the //NS_CONST_CAST below doesn't //break the build on Win32 @@ -587,7 +588,7 @@ nsPKCS12Blob::nickname_collision(SECItem *oldNick, PRBool *cancel, void *wincx) NS_LITERAL_STRING("P12DefaultNickname").get(), nickFromProp); nsXPIDLCString nickFromPropC; - nickFromPropC.Adopt(nickFromProp.ToNewUTF8String()); + nickFromPropC.Adopt(ToNewUTF8String(nickFromProp)); // The user is trying to import a PKCS#12 file that doesn't have the // attribute we use to set the nickname. So in order to reduce the // number of interactions we require with the user, we'll build a nickname diff --git a/mozilla/string/obsolete/nsString.cpp b/mozilla/string/obsolete/nsString.cpp index 86b3c0a34b8..48f36aa6627 100644 --- a/mozilla/string/obsolete/nsString.cpp +++ b/mozilla/string/obsolete/nsString.cpp @@ -42,6 +42,7 @@ #include #include #include "nsString.h" +#include "nsReadableUtils.h" #include "nsDebug.h" #include "nsCRT.h" #include "nsDeque.h" @@ -532,34 +533,6 @@ nsCString* nsCString::ToNewString() const { return new nsCString(*this); } -/** - * Creates an ascii clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update gess 02/24/00 - * @return ptr to new ascii string - */ -char* nsCString::ToNewCString() const { - return nsCRT::strdup(mStr); -} - -/** - * Creates an unicode clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update gess 01/04/99 - * @return ptr to new ascii string - */ -PRUnichar* nsCString::ToNewUnicode() const { - PRUnichar* result = NS_STATIC_CAST(PRUnichar*, nsMemory::Alloc(sizeof(PRUnichar) * (mLength + 1))); - if (result) { - CBufDescriptor desc(result, PR_TRUE, mLength + 1, 0); - nsAutoString temp(desc); - temp.AssignWithConversion(mStr); - } - return result; -} - /** * Copies contents of this string into he given buffer * Note that if you provide me a buffer that is smaller than the length of @@ -1330,7 +1303,7 @@ NS_COM int fputs(const nsCString& aString, FILE* out) char* cp = buf; PRInt32 len = aString.mLength; if (len >= PRInt32(sizeof(buf))) { - cp = aString.ToNewCString(); + cp = ToNewCString(aString); } else { aString.ToCString(cp, len + 1); } @@ -1376,7 +1349,7 @@ NS_ConvertUCS2toUTF8::Append( const PRUnichar* aString, PRUint32 aLength ) if (! aString) return; - // Caculate how many bytes we need + // Calculate how many bytes we need const PRUnichar* p; PRInt32 count, utf8len; for (p = aString, utf8len = 0, count = aLength; 0 != count && 0 != (*p); count--, p++) @@ -1463,6 +1436,20 @@ NS_ConvertUCS2toUTF8::Append( const PRUnichar* aString, PRUint32 aLength ) mLength += utf8len; } +NS_LossyConvertUCS2toASCII::NS_LossyConvertUCS2toASCII( const nsAString& aString ) + { + SetCapacity(aString.Length()); + + nsAString::const_iterator start; aString.BeginReading(start); + nsAString::const_iterator end; aString.EndReading(end); + + while (start != end) { + nsReadableFragment frag(start.fragment()); + AppendWithConversion(frag.mStart, frag.mEnd - frag.mStart); + start.advance(start.size_forward()); + } + } + /*********************************************************************** IMPLEMENTATION NOTES: AUTOSTRING... diff --git a/mozilla/string/obsolete/nsString.h b/mozilla/string/obsolete/nsString.h index afdd33cee90..89e4c027d52 100644 --- a/mozilla/string/obsolete/nsString.h +++ b/mozilla/string/obsolete/nsString.h @@ -260,22 +260,6 @@ public: */ nsCString* ToNewString() const; - /** - * Creates an ISOLatin1 clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new isolatin1 string - */ - char* ToNewCString() const; - - /** - * Creates a unicode clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new unicode string - */ - PRUnichar* ToNewUnicode() const; - /** * Copies data from internal buffer onto given char* buffer * NOTE: This only copies as many chars as will fit in given buffer (clips) @@ -550,6 +534,34 @@ class NS_COM NS_ConvertUCS2toUTF8 operator const char*() const; // use |get()| }; +/** + * A helper class that converts a UCS2 string to ASCII in a lossy manner + */ +class NS_COM NS_LossyConvertUCS2toASCII + : public nsCAutoString + /* + ... + */ + { + public: + explicit + NS_LossyConvertUCS2toASCII( const PRUnichar* aString ) + { + AppendWithConversion( aString, ~PRUint32(0) /* MAXINT */); + } + + NS_LossyConvertUCS2toASCII( const PRUnichar* aString, PRUint32 aLength ) + { + AppendWithConversion( aString, aLength ); + } + + explicit NS_LossyConvertUCS2toASCII( const nsAString& aString ); + + private: + // NOT TO BE IMPLEMENTED + NS_LossyConvertUCS2toASCII( char ); + operator const char*() const; // use |get()| + }; #endif diff --git a/mozilla/string/obsolete/nsString2.cpp b/mozilla/string/obsolete/nsString2.cpp index 8e7d3b5862b..506af5fd55f 100644 --- a/mozilla/string/obsolete/nsString2.cpp +++ b/mozilla/string/obsolete/nsString2.cpp @@ -41,6 +41,7 @@ #include #include #include "nsString.h" +#include "nsReadableUtils.h" #include "nsDebug.h" #include "nsDeque.h" @@ -561,64 +562,6 @@ nsString* nsString::ToNewString() const { return new nsString(*this); } -/** - * Creates an ascii clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update gess 02/24/00 - * @WARNING! Potential i18n issue here, since we're stepping down from 2byte chars to 1byte chars! - * @return ptr to new ascii string - */ -char* nsString::ToNewCString() const { - char* result = NS_STATIC_CAST(char*, nsMemory::Alloc(mLength + 1)); - if (result) { - CBufDescriptor desc(result, PR_TRUE, mLength + 1, 0); - nsCAutoString temp(desc); - temp.AssignWithConversion(*this); - } - return result; -} - -/** - * Creates an UTF8 clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update ftang 09/10/99 - * @return ptr to new UTF8 string - * http://www.cis.ohio-state.edu/htbin/rfc/rfc2279.html - */ -char* nsString::ToNewUTF8String() const { - NS_ConvertUCS2toUTF8 temp(mUStr); - - char* result; - if (temp.mOwnsBuffer) { - // We allocated. Trick the string into not freeing its buffer to - // avoid an extra allocation. - result = temp.mStr; - - temp.mStr=0; - temp.mOwnsBuffer = PR_FALSE; - } - else { - // We didn't allocate a buffer, so we need to copy it out of the - // nsCAutoString's storage. - result = nsCRT::strdup(temp.mStr); - } - - return result; -} - -/** - * Creates an ascii clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update gess 02/24/00 - * @return ptr to new ascii string - */ -PRUnichar* nsString::ToNewUnicode() const { - return nsCRT::strdup(mUStr); -} - /** * Copies contents of this string into he given buffer * Note that if you provide me a buffer that is smaller than the length of @@ -1556,7 +1499,7 @@ NS_COM int fputs(const nsString& aString, FILE* out) char* cp = buf; PRInt32 len = aString.mLength; if (len >= PRInt32(sizeof(buf))) { - cp = aString.ToNewCString(); + cp = ToNewCString(aString); } else { aString.ToCString(cp, len + 1); } diff --git a/mozilla/string/obsolete/nsString2.h b/mozilla/string/obsolete/nsString2.h index 6846389d7ba..510cba022bc 100644 --- a/mozilla/string/obsolete/nsString2.h +++ b/mozilla/string/obsolete/nsString2.h @@ -280,30 +280,6 @@ public: */ nsString* ToNewString() const; - /** - * Creates an ISOLatin1 clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new isolatin1 string - */ - char* ToNewCString() const; - - /** - * Creates an UTF8 clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new null-terminated UTF8 string - */ - char* ToNewUTF8String() const; - - /** - * Creates a unicode clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new unicode string - */ - PRUnichar* ToNewUnicode() const; - /** * Copies data from internal buffer onto given char* buffer * NOTE: This only copies as many chars as will fit in given buffer (clips) diff --git a/mozilla/uriloader/exthandler/mac/nsInternetConfig.cpp b/mozilla/uriloader/exthandler/mac/nsInternetConfig.cpp index b6d178bc21b..39a7e0ff00d 100644 --- a/mozilla/uriloader/exthandler/mac/nsInternetConfig.cpp +++ b/mozilla/uriloader/exthandler/mac/nsInternetConfig.cpp @@ -37,6 +37,7 @@ #include "nsInternetConfig.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsDebug.h" #include @@ -140,7 +141,7 @@ nsresult nsInternetConfig::GetString( unsigned char* inKey, char** outString ) // Buffer is a Pascal string nsCString temp( &buffer[1], buffer[0] ); - *outString = temp.ToNewCString(); + *outString = ToNewCString(temp); result = NS_OK; } } diff --git a/mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp b/mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp index 231378fe1e2..60fb049bc52 100644 --- a/mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp +++ b/mozilla/uriloader/exthandler/mac/nsInternetConfigService.cpp @@ -43,6 +43,7 @@ #include "nsLocalFileMac.h" #include "nsIURL.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMimeTypes.h" #include #include "nsColor.h" @@ -591,7 +592,7 @@ NS_IMETHODIMP nsInternetConfigService::GetString(PRUint32 inKey, char **value) // Buffer is a Pascal string; convert it to a c-string nsCString temp( &buffer[1], buffer[0] ); - *value = temp.ToNewCString(); + *value = ToNewCString(temp); } return result; diff --git a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp index a00fedfbe69..42058b1aec3 100644 --- a/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/nsExternalHelperAppService.cpp @@ -30,6 +30,7 @@ #include "nsIDirectoryService.h" #include "nsAppDirectoryServiceDefs.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMemory.h" #include "nsIStreamListener.h" #include "nsIMIMEService.h" @@ -1469,7 +1470,7 @@ NS_IMETHODIMP nsExternalHelperAppService::GetTypeFromURI(nsIURI *aURI, char **aC if (-1 != extLoc) { specStr.Right(extStr, specStr.Length() - extLoc - 1); - char *ext = extStr.ToNewCString(); + char *ext = ToNewCString(extStr); if (!ext) return NS_ERROR_OUT_OF_MEMORY; rv = GetTypeFromExtension(ext, aContentType); nsMemory::Free(ext); diff --git a/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp b/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp index bb54b764880..c4aa79e0c95 100644 --- a/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp +++ b/mozilla/uriloader/exthandler/nsExternalProtocolHandler.cpp @@ -24,6 +24,7 @@ #include "nsIURL.h" #include "nsExternalProtocolHandler.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsCOMPtr.h" #include "nsIServiceManager.h" #include "nsNetCID.h" @@ -270,7 +271,7 @@ NS_INTERFACE_MAP_END_THREADSAFE NS_IMETHODIMP nsExternalProtocolHandler::GetScheme(char * *aScheme) { - *aScheme = m_schemeName.ToNewCString(); + *aScheme = ToNewCString(m_schemeName); return NS_OK; } diff --git a/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp b/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp index f4692fcc7dd..b9f8a2b238d 100644 --- a/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp +++ b/mozilla/uriloader/exthandler/nsMIMEInfoImpl.cpp @@ -37,6 +37,7 @@ #include "nsMIMEInfoImpl.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPrefService.h" #include "nsIPrefBranch.h" #include "nsEscape.h" @@ -73,7 +74,7 @@ nsMIMEInfoImpl::GetFileExtensions(PRUint32 *elementCount, char ***extensions) { for (PRUint32 i=0; i < count; i++) { nsCString* ext = mExtensions.CStringAt(i); - _retExts[i] = ext->ToNewCString(); + _retExts[i] = ToNewCString(*ext); if (!_retExts[i]) { // clean up all the strings we've allocated while (i-- != 0) nsMemory::Free(_retExts[i]); @@ -114,7 +115,7 @@ nsMIMEInfoImpl::FirstExtension(char **_retval) { PRUint32 extCount = mExtensions.Count(); if (extCount < 1) return NS_ERROR_NOT_INITIALIZED; - *_retval = (mExtensions.CStringAt(0))->ToNewCString(); + *_retval = ToNewCString(*(mExtensions.CStringAt(0))); if (!*_retval) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -132,7 +133,7 @@ nsMIMEInfoImpl::GetMIMEType(char * *aMIMEType) { if (mMIMEType.Length() < 1) return NS_ERROR_NOT_INITIALIZED; - *aMIMEType = mMIMEType.ToNewCString(); + *aMIMEType = ToNewCString(mMIMEType); if (!*aMIMEType) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -149,7 +150,7 @@ NS_IMETHODIMP nsMIMEInfoImpl::GetDescription(PRUnichar * *aDescription) { if (!aDescription) return NS_ERROR_NULL_POINTER; - *aDescription = mDescription.ToNewUnicode(); + *aDescription = ToNewUnicode(mDescription); if (!*aDescription) return NS_ERROR_OUT_OF_MEMORY; return NS_OK; } @@ -221,7 +222,7 @@ NS_IMETHODIMP nsMIMEInfoImpl::SetFileExtensions( const char* aExtensions ) NS_IMETHODIMP nsMIMEInfoImpl::GetApplicationDescription(PRUnichar ** aApplicationDescription) { - *aApplicationDescription = mPreferredAppDescription.ToNewUnicode(); + *aApplicationDescription = ToNewUnicode(mPreferredAppDescription); return NS_OK; } diff --git a/mozilla/uriloader/exthandler/os2/nsOSHelperAppService.cpp b/mozilla/uriloader/exthandler/os2/nsOSHelperAppService.cpp index 6bd9f1adb77..2d89b7b7f7d 100644 --- a/mozilla/uriloader/exthandler/os2/nsOSHelperAppService.cpp +++ b/mozilla/uriloader/exthandler/os2/nsOSHelperAppService.cpp @@ -23,6 +23,7 @@ #include "nsOSHelperAppService.h" #include "nsISupports.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsXPIDLString.h" #include "nsIURL.h" #include "nsIMIMEInfo.h" @@ -85,7 +86,7 @@ nsresult nsOSHelperAppService::FindOSMimeInfoForType(const char * aMimeContentTy { GetFromExtension(fileExtension, aMIMEInfo); // this is the ONLY code path which leads to success where we should set our return variables... - *aFileExtension = fileExtension.ToNewCString(); + *aFileExtension = ToNewCString(fileExtension); } // if we got an entry out of the registry... return rv; diff --git a/mozilla/webshell/embed/xlib/gtk/nsEmbedXlibIntoGtk.cpp b/mozilla/webshell/embed/xlib/gtk/nsEmbedXlibIntoGtk.cpp index 6f43ab6ff47..18eb71bed03 100644 --- a/mozilla/webshell/embed/xlib/gtk/nsEmbedXlibIntoGtk.cpp +++ b/mozilla/webshell/embed/xlib/gtk/nsEmbedXlibIntoGtk.cpp @@ -44,6 +44,7 @@ extern "C" { } #include "nsIServiceManager.h" +#include "nsReadableUtils.h" #include "nsIEventQueueService.h" #include "nsIXlibWindowService.h" #include "nsIUnixToolkitService.h" @@ -265,7 +266,7 @@ int main(int argc, char **argv) char *url = "http://www.mozilla.org/unix/xlib.html"; nsString URL(url); - PRUnichar *u_url = URL.ToNewUnicode(); + PRUnichar *u_url = ToNewUnicode(URL); // XXX fix me - what's the new API? //sgWebShell->LoadURL(u_url); diff --git a/mozilla/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp b/mozilla/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp index 1bc3b1b14b5..e2eda59c446 100644 --- a/mozilla/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp +++ b/mozilla/webshell/embed/xlib/motif/nsEmbedXlibIntoMotif.cpp @@ -6,6 +6,7 @@ #include "EmbedMozilla.h" #include "nsIServiceManager.h" +#include "nsReadableUtils.h" #include "nsIEventQueueService.h" #include "nsIXlibWindowService.h" #include "nsIUnixToolkitService.h" @@ -252,7 +253,7 @@ int main(int argc, char **argv) char *url = "http://www.slashdot.org/"; nsString URL(url); - PRUnichar *u_url = URL.ToNewUnicode(); + PRUnichar *u_url = ToNewUnicode(URL); sgWebShell->LoadURL(u_url); XtPopup(sgTopLevel,XtGrabNone); diff --git a/mozilla/webshell/embed/xlib/qt/QMozillaContainer.cpp b/mozilla/webshell/embed/xlib/qt/QMozillaContainer.cpp index 6a46833e13e..73b552d62bb 100644 --- a/mozilla/webshell/embed/xlib/qt/QMozillaContainer.cpp +++ b/mozilla/webshell/embed/xlib/qt/QMozillaContainer.cpp @@ -24,6 +24,7 @@ #include "QMozillaContainer.h" #include "nsQtEventProcessor.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsIXlibWindowService.h" @@ -167,7 +168,7 @@ void QMozillaContainer::loadURL( const char *url ) if ( m_WebShell ) { nsString URL(url); - PRUnichar *u_url = URL.ToNewUnicode(); + PRUnichar *u_url = ToNewUnicode(URL); m_WebShell->LoadURL(u_url); } } diff --git a/mozilla/webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp b/mozilla/webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp index fbd054a0355..5d2541c21f8 100644 --- a/mozilla/webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp +++ b/mozilla/webshell/embed/xlib/xt/nsEmbedXlibIntoXt.cpp @@ -32,6 +32,7 @@ #include "EmbedMozilla.h" #include "nsIServiceManager.h" +#include "nsReadableUtils.h" #include "nsIEventQueueService.h" #include "nsIXlibWindowService.h" #include "nsIUnixToolkitService.h" @@ -303,7 +304,7 @@ int main(int argc, char **argv) char *url = "http://www.mozilla.org/unix/xlib.html"; nsString URL(url); - PRUnichar *u_url = URL.ToNewUnicode(); + PRUnichar *u_url = ToNewUnicode(URL); sgWebShell->LoadURL(u_url); XtPopup( gTopLevelWidget, XtGrabNone ); diff --git a/mozilla/webshell/src/nsComFactory.cpp b/mozilla/webshell/src/nsComFactory.cpp index 4427015155e..64faa81367d 100644 --- a/mozilla/webshell/src/nsComFactory.cpp +++ b/mozilla/webshell/src/nsComFactory.cpp @@ -54,6 +54,7 @@ #include "nsIFactory.h" #include "nsIWebShell.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "plevent.h" #include "prthread.h" #include "private/pprthred.h" @@ -276,7 +277,7 @@ STDAPI DllRegisterServer(void) StringFromGUID2(WebShellCID, IIDString, sizeof(IIDString)); tmp = IIDString; - WebShellCLSID = tmp.ToNewCString(); + WebShellCLSID = ToNewCString(tmp); // end hack... @@ -351,7 +352,7 @@ STDAPI DllUnregisterServer(void) StringFromGUID2(WebShellCID, IIDString, sizeof(IIDString)); tmp = IIDString; - WebShellCLSID = tmp.ToNewCString(); + WebShellCLSID = ToNewCString(tmp); // end hack... diff --git a/mozilla/webshell/tests/viewer/JSConsole.cpp b/mozilla/webshell/tests/viewer/JSConsole.cpp index d89bc49b29b..6c8162a1a73 100644 --- a/mozilla/webshell/tests/viewer/JSConsole.cpp +++ b/mozilla/webshell/tests/viewer/JSConsole.cpp @@ -45,6 +45,7 @@ #include "nsIScriptContext.h" #include #include "jsapi.h" +#include "nsReadableUtils.h" HINSTANCE JSConsole::sAppInstance = 0; HACCEL JSConsole::sAccelTable = 0; @@ -916,7 +917,7 @@ void JSConsole::EvaluateText(UINT aStartSel, UINT aEndSel) int bDelete = 0; JSContext *cx = (JSContext *)mContext->GetNativeContext(); - char *str = returnValue.ToNewCString(); + char *str = ToNewCString(returnValue); ::printf("The return value is %s\n", str); diff --git a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp index 46c2a9fbc8c..9fc02b02abd 100644 --- a/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsBrowserWindow.cpp @@ -77,6 +77,7 @@ #include "nsIWebBrowserFocus.h" #include "nsIBaseWindow.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIViewManager.h" #include "nsGUIEvent.h" #include "nsIWebProgress.h" @@ -413,7 +414,7 @@ NS_IMETHODIMP nsBrowserWindow::GetTitle(PRUnichar** aTitle) { NS_ENSURE_ARG_POINTER(aTitle); - *aTitle = mTitle.ToNewUnicode(); + *aTitle = ToNewUnicode(mTitle); return NS_OK; } @@ -695,7 +696,7 @@ HandleLocationEvent(nsGUIEvent *aEvent) nsAutoString fileURL; BuildFileURL(ev->mURL, fileURL); nsAutoString fileName(ev->mURL); - char * str = fileName.ToNewCString(); + char * str = ToNewCString(fileName); PRInt32 len = strlen(str); PRInt32 sum = len + sizeof(FILE_PROTOCOL); @@ -3045,7 +3046,7 @@ nsBrowserWindow::SetStringPref(const char * aPrefName, const nsString& aValue) nsCOMPtr prefs(do_GetService(NS_PREF_CONTRACTID)); if (nsnull != prefs && nsnull != aPrefName) { - char * prefStr = aValue.ToNewCString(); + char * prefStr = ToNewCString(aValue); prefs->SetCharPref(aPrefName, prefStr); prefs->SavePrefFile(nsnull); delete [] prefStr; diff --git a/mozilla/webshell/tests/viewer/nsEditorMode.cpp b/mozilla/webshell/tests/viewer/nsEditorMode.cpp index e5a78771f36..cb70d0749af 100644 --- a/mozilla/webshell/tests/viewer/nsEditorMode.cpp +++ b/mozilla/webshell/tests/viewer/nsEditorMode.cpp @@ -40,6 +40,7 @@ #include "nsEditorMode.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsIDOMDocument.h" #include "nsIEditor.h" @@ -128,7 +129,7 @@ static nsresult PrintEditorOutput(nsIEditor* editor, PRInt32 aCommandID) break; } - cString = outString.ToNewCString(); + cString = ToNewCString(outString); printf(cString); delete [] cString; diff --git a/mozilla/webshell/tests/viewer/nsThrobber.cpp b/mozilla/webshell/tests/viewer/nsThrobber.cpp index 17152a975cf..dda386b3562 100644 --- a/mozilla/webshell/tests/viewer/nsThrobber.cpp +++ b/mozilla/webshell/tests/viewer/nsThrobber.cpp @@ -49,6 +49,7 @@ #include "nsIDeviceContext.h" #include "nsGUIEvent.h" #include "nsIImage.h" +#include "nsReadableUtils.h" static NS_DEFINE_IID(kChildCID, NS_CHILD_CID); @@ -365,7 +366,7 @@ nsThrobber::LoadThrobberImages(const nsString& aFileNameMask, PRInt32 aNumImages } mTimer->Init(ThrobTimerCallback, this, 33, NS_PRIORITY_NORMAL, NS_TYPE_REPEATING_SLACK); - char * mask = aFileNameMask.ToNewCString(); + char * mask = ToNewCString(aFileNameMask); for (PRInt32 cnt = 0; cnt < mNumImages; cnt++) { PR_snprintf(url, sizeof(url), mask, cnt); diff --git a/mozilla/webshell/tests/viewer/nsViewerApp.cpp b/mozilla/webshell/tests/viewer/nsViewerApp.cpp index 974326438c6..5de25c5cebe 100644 --- a/mozilla/webshell/tests/viewer/nsViewerApp.cpp +++ b/mozilla/webshell/tests/viewer/nsViewerApp.cpp @@ -41,6 +41,7 @@ #endif #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsXPBaseWindow.h" #include "nsViewerApp.h" #include "nsBrowserWindow.h" @@ -231,8 +232,8 @@ nsTestFormProcessor::ProcessValue(nsIDOMHTMLElement *aElement, nsString& aValue) { #ifdef DEBUG_kmcclusk - char *name = aName.ToNewCString(); - char *value = aValue.ToNewCString(); + char *name = ToNewCString(aName); + char *value = ToNewCString(aValue); printf("ProcessValue: name %s value %s\n", name, value); delete [] name; delete [] value; @@ -865,7 +866,7 @@ nsEventStatus PR_CALLBACK HandleRobotEvent(nsGUIEvent *aEvent) PRUint32 size; mStopAfterTxt->GetText(str, 255, size); - char * cStr = str.ToNewCString(); + char * cStr = ToNewCString(str); sscanf(cStr, "%d", &gDebugRobotLoads); if (gDebugRobotLoads <= 0) { gDebugRobotLoads = 5000; @@ -1295,7 +1296,7 @@ nsEventStatus PR_CALLBACK HandleSiteEvent(nsGUIEvent *aEvent) PRInt32 inx; mSiteIndexTxt->GetText(str, 255, size); - char * cStr = str.ToNewCString(); + char * cStr = ToNewCString(str); sscanf(cStr, "%d", &inx); if (inx >= 0 && inx < gTop100LastPointer) { gTop100Pointer = inx; diff --git a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp index e845e05fb21..d704881b658 100644 --- a/mozilla/webshell/tests/viewer/nsWebCrawler.cpp +++ b/mozilla/webshell/tests/viewer/nsWebCrawler.cpp @@ -51,6 +51,7 @@ #include "plhash.h" #include "nsINameSpaceManager.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" #include "nsIEventQueueService.h" #include "nsIEventQueue.h" @@ -928,7 +929,7 @@ OpenRegressionFile(const nsString& aBaseName, const nsString& aOutputName) a.Append(aBaseName); a.AppendWithConversion("/"); a.Append(aOutputName); - char* fn = a.ToNewCString(); + char* fn = ToNewCString(a); FILE* fp = fopen(fn, "r"); if (!fp) { printf("Unable to open regression data file %s\n", fn); diff --git a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp index b1e6edcea29..8b72aa286df 100644 --- a/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp +++ b/mozilla/webshell/tests/viewer/nsXPBaseWindow.cpp @@ -78,6 +78,7 @@ #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #if defined(WIN32) || defined(XP_OS2_VACPP) @@ -383,7 +384,7 @@ NS_IMETHODIMP nsXPBaseWindow::SetTitle(const PRUnichar* aTitle) //--------------------------------------------------------------- NS_IMETHODIMP nsXPBaseWindow::GetTitle(const PRUnichar** aResult) { - *aResult = mTitle.ToNewUnicode(); + *aResult = ToNewUnicode(mTitle); return NS_OK; } diff --git a/mozilla/widget/src/beos/nsFilePicker.cpp b/mozilla/widget/src/beos/nsFilePicker.cpp index 26f12382c8a..6f1c73245b1 100644 --- a/mozilla/widget/src/beos/nsFilePicker.cpp +++ b/mozilla/widget/src/beos/nsFilePicker.cpp @@ -32,6 +32,7 @@ #include "nsIURL.h" #include "nsIFileChannel.h" #include "nsIStringBundle.h" +#include "nsReadableUtils.h" #include #include @@ -105,14 +106,14 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) // set title if (mTitle.Length() > 0) { - char *title_utf8 = mTitle.ToNewUTF8String(); + char *title_utf8 = ToNewUTF8String(mTitle); ppanel->Window()->SetTitle(title_utf8); Recycle(title_utf8); } // set default text if (mDefault.Length() > 0) { - char *defaultText = mDefault.ToNewCString(); + char *defaultText = ToNewCString(mDefault); ppanel->SetSaveText(defaultText); Recycle(defaultText); } diff --git a/mozilla/widget/src/beos/nsPopUpMenu.cpp b/mozilla/widget/src/beos/nsPopUpMenu.cpp index 3e2a48a2d63..bf82f5554c8 100644 --- a/mozilla/widget/src/beos/nsPopUpMenu.cpp +++ b/mozilla/widget/src/beos/nsPopUpMenu.cpp @@ -42,6 +42,7 @@ #include "nsColor.h" #include "nsGUIEvent.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsIAppShell.h" @@ -112,7 +113,7 @@ NS_METHOD nsPopUpMenu::AddItem(nsIMenuItem * aMenuItem) aMenuItem->GetCommand(command); aMenuItem->GetLabel(name); - char * nameStr = name.ToNewCString(); + char * nameStr = ToNewCString(name); MENUITEMINFO menuInfo; menuInfo.cbSize = sizeof(menuInfo); @@ -135,7 +136,7 @@ NS_METHOD nsPopUpMenu::AddMenu(nsIMenu * aMenu) #if 0 nsString name; aMenu->GetLabel(name); - char * nameStr = name.ToNewCString(); + char * nameStr = ToNewCString(name); HMENU nativeMenuHandle; void * voidData; diff --git a/mozilla/widget/src/beos/nsTextHelper.cpp b/mozilla/widget/src/beos/nsTextHelper.cpp index 3e99812d6f4..f6d7579f847 100644 --- a/mozilla/widget/src/beos/nsTextHelper.cpp +++ b/mozilla/widget/src/beos/nsTextHelper.cpp @@ -40,6 +40,7 @@ #include "nsColor.h" #include "nsGUIEvent.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include @@ -80,7 +81,7 @@ NS_METHOD nsTextHelper::SetText(const nsString &aText, PRUint32& aActualSize) mText = aText; const char *text; - text = aText.ToNewCString(); + text = ToNewCString(aText); if(mTextView && mTextView->LockLooper()) { mTextView->SetText(text); @@ -95,7 +96,7 @@ NS_METHOD nsTextHelper::SetText(const nsString &aText, PRUint32& aActualSize) NS_METHOD nsTextHelper::InsertText(const nsString &aText, PRUint32 aStartPos, PRUint32 aEndPos, PRUint32& aActualSize) { const char *text; - text = aText.ToNewCString(); + text = ToNewCString(aText); if(mTextView) { if(mTextView->LockLooper()) @@ -107,7 +108,7 @@ NS_METHOD nsTextHelper::InsertText(const nsString &aText, PRUint32 aStartPos, P mTextView->Insert(aStartPos, text, aActualSize); } delete [] text; - mText.Insert(aText.ToNewUnicode(), aStartPos, aText.Length()); + mText.Insert(ToNewUnicode(aText), aStartPos, aText.Length()); return NS_OK; } diff --git a/mozilla/widget/src/beos/nsWindow.cpp b/mozilla/widget/src/beos/nsWindow.cpp index 4690b37fea0..067a3e85c05 100644 --- a/mozilla/widget/src/beos/nsWindow.cpp +++ b/mozilla/widget/src/beos/nsWindow.cpp @@ -51,6 +51,7 @@ #include "nsGfxCIID.h" #include "resource.h" #include "prtime.h" +#include "nsReadableUtils.h" #include #include @@ -2622,7 +2623,7 @@ PRBool nsWindow::OnScroll() NS_METHOD nsWindow::SetTitle(const nsString& aTitle) { - const char *text = aTitle.ToNewUTF8String(); + const char *text = ToNewUTF8String(aTitle); if(text && mView->LockLooper()) { mView->Window()->SetTitle(text); diff --git a/mozilla/widget/src/gtk/nsClipboard.cpp b/mozilla/widget/src/gtk/nsClipboard.cpp index 503234e91a6..05d2e62a832 100644 --- a/mozilla/widget/src/gtk/nsClipboard.cpp +++ b/mozilla/widget/src/gtk/nsClipboard.cpp @@ -39,6 +39,7 @@ #include "nsIServiceManager.h" #include "nsWidgetsCID.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsPrimitiveHelpers.h" #include "nsTextFormatter.h" diff --git a/mozilla/widget/src/gtk/nsFilePicker.cpp b/mozilla/widget/src/gtk/nsFilePicker.cpp index 7fc97fd719e..8d6856a3549 100644 --- a/mozilla/widget/src/gtk/nsFilePicker.cpp +++ b/mozilla/widget/src/gtk/nsFilePicker.cpp @@ -22,6 +22,7 @@ */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsIComponentManager.h" #include "nsFilePicker.h" @@ -173,9 +174,9 @@ NS_IMETHODIMP nsFilePicker::SetFilterList(PRUint32 aNumberOfFilters, { // we need *.{htm, html, xul, etc} - char *filters = aFilters[i].ToNewCString(); + char *filters = ToNewCString(aFilters[i]); #ifdef DEBUG - char *foo = aTitles[i].ToNewCString(); + char *foo = ToNewCString(aTitles[i]); printf("%20s %s\n", foo, filters); nsCRT::free(foo); #endif diff --git a/mozilla/widget/src/gtk/nsMenu.cpp b/mozilla/widget/src/gtk/nsMenu.cpp index 4b9ee16029a..3b3fcc49c7d 100644 --- a/mozilla/widget/src/gtk/nsMenu.cpp +++ b/mozilla/widget/src/gtk/nsMenu.cpp @@ -45,6 +45,7 @@ #include "nsIMenuItem.h" #include "nsIMenuListener.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsGtkEventHandler.h" #include "nsCOMPtr.h" #include "nsWidgetsCID.h" @@ -194,7 +195,7 @@ NS_METHOD nsMenu::SetLabel(const nsString &aText) NS_METHOD nsMenu::GetAccessKey(nsString &aText) { aText = mAccessKey; - char *foo = mAccessKey.ToNewCString(); + char *foo = ToNewCString(mAccessKey); #ifdef DEBUG_pavlov g_print("GetAccessKey returns \"%s\"\n", foo); @@ -208,7 +209,7 @@ NS_METHOD nsMenu::GetAccessKey(nsString &aText) NS_METHOD nsMenu::SetAccessKey(const nsString &aText) { mAccessKey = aText; - char *foo = mAccessKey.ToNewCString(); + char *foo = ToNewCString(mAccessKey); #ifdef DEBUG_pavlov g_print("SetAccessKey setting to \"%s\"\n", foo); @@ -760,7 +761,7 @@ void nsMenu::LoadSubMenu(nsIMenu * pParentMenu, { nsString menuName; menuElement->GetAttribute(nsAutoString("label"), menuName); - //printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks + //printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get()); // Create nsMenu nsIMenu * pnsMenu = nsnull; @@ -799,7 +800,7 @@ void nsMenu::LoadSubMenu(nsIMenu * pParentMenu, menuitemElement->GetNodeName(menuitemNodeType); #ifdef DEBUG_saari - printf("Type [%s] %d\n", menuitemNodeType.ToNewCString(), menuitemNodeType.Equals("menuseparator")); + printf("Type [%s] %d\n", NS_LossyConvertUCS2toASCII(menuitemNodeType).get(), menuitemNodeType.Equals("menuseparator")); #endif if (menuitemNodeType.Equals("menuitem")) { diff --git a/mozilla/widget/src/gtk/nsMenuBar.cpp b/mozilla/widget/src/gtk/nsMenuBar.cpp index 43b283d277f..c6167e9058b 100644 --- a/mozilla/widget/src/gtk/nsMenuBar.cpp +++ b/mozilla/widget/src/gtk/nsMenuBar.cpp @@ -46,6 +46,7 @@ #include "nsIWidget.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsGtkEventHandler.h" @@ -173,7 +174,7 @@ NS_METHOD nsMenuBar::AddMenu(nsIMenu * aMenu) Label.Insert("_", offset); } - char *foo = Label.ToNewCString(); + char *foo = ToNewCString(Label); #ifdef DEBUG g_print("%s\n", foo); #endif diff --git a/mozilla/widget/src/mac/nsFilePicker.cpp b/mozilla/widget/src/mac/nsFilePicker.cpp index 648639d70d8..2f10f9db7f7 100644 --- a/mozilla/widget/src/mac/nsFilePicker.cpp +++ b/mozilla/widget/src/mac/nsFilePicker.cpp @@ -22,6 +22,7 @@ */ #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsIComponentManager.h" #include "nsILocalFile.h" @@ -126,7 +127,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) *retval = returnCancel; nsString filterList; - char *filterBuffer = filterList.ToNewCString(); + char *filterBuffer = ToNewCString(filterList); Str255 title; Str255 defaultName; @@ -536,7 +537,7 @@ nsFilePicker :: MapFilterToFileTypes ( ) for (PRUint32 loop1 = 0; loop1 < mFilters.Count(); loop1++) { const nsString& filterWide = *mFilters[loop1]; - char* filter = filterWide.ToNewCString(); + char* filter = ToNewCString(filterWide); NS_ASSERTION ( filterWide.Length(), "Oops. filepicker.properties not correctly installed"); if ( filterWide.Length() && filter ) diff --git a/mozilla/widget/src/mac/nsMenu.cpp b/mozilla/widget/src/mac/nsMenu.cpp index 42d3de2e8e5..278b8a18ea1 100644 --- a/mozilla/widget/src/mac/nsMenu.cpp +++ b/mozilla/widget/src/mac/nsMenu.cpp @@ -54,6 +54,7 @@ #include "nsGUIEvent.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsINameSpaceManager.h" @@ -338,7 +339,7 @@ NS_METHOD nsMenu::AddMenuItem(nsIMenuItem * aMenuItem) nsAutoString label; aMenuItem->GetLabel(label); - //printf("%s \n", label.ToNewCString()); + //printf("%s \n", NS_LossyConvertUCS2toASCII(label).get()); //printf("%d = mMacMenuID\n", mMacMenuID); ::InsertMenuItem(mMacMenuHandle, "\p(Blank menu item", currItemIndex); MenuHelpers::SetMenuItemText(mMacMenuHandle, currItemIndex, label, mUnicodeTextRunConverter); @@ -407,7 +408,7 @@ NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu) // We have to add it as a menu item and then associate it with the item nsAutoString label; aMenu->GetLabel(label); - //printf("AddMenu %s \n", label.ToNewCString()); + //printf("AddMenu %s \n", NS_LossyConvertUCS2toASCII(label).get()); ::InsertMenuItem(mMacMenuHandle, "\p(Blank Menu", currItemIndex); MenuHelpers::SetMenuItemText(mMacMenuHandle, currItemIndex, label, mUnicodeTextRunConverter); @@ -696,7 +697,7 @@ nsEventStatus nsMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent) // nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent) { - //printf("MenuSelected called for %s \n", mLabel.ToNewCString()); + //printf("MenuSelected called for %s \n", NS_LossyConvertUCS2toASCII(mLabel).get()); nsEventStatus eventStatus = nsEventStatus_eIgnore; // Determine if this is the correct menu to handle the event @@ -764,7 +765,7 @@ nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent) //------------------------------------------------------------------------- nsEventStatus nsMenu::MenuDeselected(const nsMenuEvent & aMenuEvent) { - //printf("MenuDeselect called for %s\n", mLabel.ToNewCString()); + //printf("MenuDeselect called for %s\n", NS_LossyConvertUCS2toASCII(mLabel).get()); // Destroy the menu if(mConstructed) { MenuDestruct(aMenuEvent); @@ -787,7 +788,7 @@ nsEventStatus nsMenu::MenuConstruct( // reset destroy handler flag so that we'll know to fire it next time this menu goes away. mDestroyHandlerCalled = PR_FALSE; - //printf("nsMenu::MenuConstruct called for %s = %d \n", mLabel.ToNewCString(), mMacMenuHandle); + //printf("nsMenu::MenuConstruct called for %s = %d \n", NS_LossyConvertUCS2toASCII(mLabel).get(), mMacMenuHandle); // Begin menuitem inner loop @@ -832,7 +833,7 @@ nsEventStatus nsMenu::HelpMenuConstruct( const nsMenuEvent & aMenuEvent, nsIWidget* aParentWindow, void* /* unused */, void* aWebShell) { - //printf("nsMenu::MenuConstruct called for %s = %d \n", mLabel.ToNewCString(), mMacMenuHandle); + //printf("nsMenu::MenuConstruct called for %s = %d \n", NS_LossyConvertUCS2toASCII(mLabel).get(), mMacMenuHandle); int numHelpItems = ::CountMenuItems(mMacMenuHandle); for (int i=0; i < numHelpItems; ++i) { @@ -877,7 +878,7 @@ nsMenu::HelpMenuConstruct( const nsMenuEvent & aMenuEvent, nsIWidget* aParentWin //------------------------------------------------------------------------- nsEventStatus nsMenu::MenuDestruct(const nsMenuEvent & aMenuEvent) { - //printf("nsMenu::MenuDestruct() called for %s \n", mLabel.ToNewCString()); + //printf("nsMenu::MenuDestruct() called for %s \n", NS_LossyConvertUCS2toASCII(mLabel).get()); // Fire our ondestroy handler. If we're told to stop, don't destroy the menu PRBool keepProcessing = OnDestroy(); @@ -1038,7 +1039,7 @@ nsMenu::LoadMenuItem( nsIMenu* inParentMenu, nsIContent* inMenuItemContent ) inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::label, menuitemName); inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::command, menuitemCmd); - //printf("menuitem %s \n", menuitemName.ToNewCString()); + //printf("menuitem %s \n", NS_LossyConvertUCS2toASCII(menuitemName).get()); PRBool enabled = ! (disabled == NS_LITERAL_STRING("true")); @@ -1085,7 +1086,7 @@ nsMenu::LoadMenuItem( nsIMenu* inParentMenu, nsIContent* inMenuItemContent ) PRUint8 modifiers = knsMenuItemNoModifier; nsAutoString modifiersStr; keyContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::modifiers, modifiersStr); - char* str = modifiersStr.ToNewCString(); + char* str = ToNewCString(modifiersStr); char* newStr; char* token = nsCRT::strtok( str, ", ", &newStr ); while( token != NULL ) { @@ -1130,7 +1131,7 @@ nsMenu::LoadSubMenu( nsIMenu * pParentMenu, nsIContent* inMenuItemContent ) nsAutoString menuName; inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::label, menuName); - //printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks + //printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get()); // Create nsMenu nsCOMPtr pnsMenu ( do_CreateInstance(kMenuCID) ); diff --git a/mozilla/widget/src/mac/nsMenuX.cpp b/mozilla/widget/src/mac/nsMenuX.cpp index ba898d39c77..ba0df51d4c8 100644 --- a/mozilla/widget/src/mac/nsMenuX.cpp +++ b/mozilla/widget/src/mac/nsMenuX.cpp @@ -54,6 +54,7 @@ #include "nsIPresContext.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsINameSpaceManager.h" @@ -331,7 +332,7 @@ NS_METHOD nsMenuX::AddMenu(nsIMenu * aMenu) // We have to add it as a menu item and then associate it with the item nsAutoString label; aMenu->GetLabel(label); - //printf("AddMenu %s \n", label.ToNewCString()); + //printf("AddMenu %s \n", NS_LossyConvertUCS2toASCII(label).get()); CFStringRef labelRef = ::CFStringCreateWithCharacters(kCFAllocatorDefault, (UniChar*)label.get(), label.Length()); ::InsertMenuItemTextWithCFString(mMacMenuHandle, labelRef, currItemIndex, 0, 0); @@ -546,7 +547,7 @@ nsEventStatus nsMenuX::MenuItemSelected(const nsMenuEvent & aMenuEvent) //------------------------------------------------------------------------- nsEventStatus nsMenuX::MenuSelected(const nsMenuEvent & aMenuEvent) { - //printf("MenuSelected called for %s \n", mLabel.ToNewCString()); + //printf("MenuSelected called for %s \n", NS_LossyConvertUCS2toASCII(mLabel).get()); nsEventStatus eventStatus = nsEventStatus_eIgnore; // Determine if this is the correct menu to handle the event @@ -634,7 +635,7 @@ nsEventStatus nsMenuX::MenuConstruct( // reset destroy handler flag so that we'll know to fire it next time this menu goes away. mDestroyHandlerCalled = PR_FALSE; - //printf("nsMenuX::MenuConstruct called for %s = %d \n", mLabel.ToNewCString(), mMacMenuHandle); + //printf("nsMenuX::MenuConstruct called for %s = %d \n", NS_LossyConvertUCS2toASCII(mLabel).get(), mMacMenuHandle); // Begin menuitem inner loop // Retrieve our menupopup. @@ -676,7 +677,7 @@ nsEventStatus nsMenuX::HelpMenuConstruct( void * /* menuNode */, void * aWebShell) { - //printf("nsMenuX::MenuConstruct called for %s = %d \n", mLabel.ToNewCString(), mMacMenuHandle); + //printf("nsMenuX::MenuConstruct called for %s = %d \n", NS_LossyConvertUCS2toASCII(mLabel).get(), mMacMenuHandle); int numHelpItems = ::CountMenuItems(mMacMenuHandle); for (int i=0; i < numHelpItems; ++i) { @@ -716,7 +717,7 @@ nsEventStatus nsMenuX::HelpMenuConstruct( //------------------------------------------------------------------------- nsEventStatus nsMenuX::MenuDestruct(const nsMenuEvent & aMenuEvent) { - //printf("nsMenuX::MenuDestruct() called for %s \n", mLabel.ToNewCString()); + //printf("nsMenuX::MenuDestruct() called for %s \n", NS_LossyConvertUCS2toASCII(mLabel).get()); // Fire our ondestroy handler. If we're told to stop, don't destroy the menu PRBool keepProcessing = OnDestroy(); @@ -914,7 +915,7 @@ void nsMenuX::LoadMenuItem( nsIMenu* inParentMenu, nsIContent* inMenuItemContent inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::label, menuitemName); inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::command, menuitemCmd); - //printf("menuitem %s \n", menuitemName.ToNewCString()); + //printf("menuitem %s \n", NS_LossyConvertUCS2toASCII(menuitemName).get()); PRBool enabled = ! (disabled == NS_LITERAL_STRING("true")); @@ -961,7 +962,7 @@ void nsMenuX::LoadMenuItem( nsIMenu* inParentMenu, nsIContent* inMenuItemContent PRUint8 modifiers = knsMenuItemNoModifier; nsAutoString modifiersStr; keyContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::modifiers, modifiersStr); - char* str = modifiersStr.ToNewCString(); + char* str = ToNewCString(modifiersStr); char* newStr; char* token = nsCRT::strtok( str, ", ", &newStr ); while( token != NULL ) { @@ -1005,7 +1006,7 @@ nsMenuX::LoadSubMenu( nsIMenu * pParentMenu, nsIContent* inMenuItemContent ) nsAutoString menuName; inMenuItemContent->GetAttr(kNameSpaceID_None, nsWidgetAtoms::label, menuName); - //printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks + //printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get()); // Create nsMenu nsCOMPtr pnsMenu ( do_CreateInstance(kMenuCID) ); diff --git a/mozilla/widget/src/mac/nsMimeMapper.cpp b/mozilla/widget/src/mac/nsMimeMapper.cpp index 65fb12c97ef..b8168e44366 100644 --- a/mozilla/widget/src/mac/nsMimeMapper.cpp +++ b/mozilla/widget/src/mac/nsMimeMapper.cpp @@ -45,6 +45,7 @@ #include "nsMimeMapper.h" #include "nsITransferable.h" #include "nsString.h" +#include "nsReadableUtils.h" #include #include @@ -226,7 +227,7 @@ nsMimeMapperMac :: ExportMapping ( short * outLength ) const // for each pair, write out flavor and mime types for ( MimeMapConstIterator it = mMappings.begin(); it != mMappings.end(); ++it ) { - const char* mimeType = it->second.ToNewCString(); + const char* mimeType = ToNewCString(it->second); ostr << it->first << ' ' << mimeType << ' '; delete [] mimeType; } @@ -257,7 +258,7 @@ nsMimeMapperMac :: ExportMapping ( short * outLength ) const // create a buffer for this mapping, fill it in, and append it to our // ongoing result buffer, |exportBuffer|. char* currMapping = new char[10 + 2 + it->second.Length() + 1]; // same computation as above, plus NULL - char* mimeType = it->second.ToNewCString(); + char* mimeType = ToNewCString(it->second); if ( currMapping && mimeType ) { sprintf(currMapping, "%ld %s ", it->first, mimeType); strcat(posInString, currMapping); diff --git a/mozilla/widget/src/mac/nsTextHelper.cpp b/mozilla/widget/src/mac/nsTextHelper.cpp index 9e356cf44f6..dfa13ddc3f9 100644 --- a/mozilla/widget/src/mac/nsTextHelper.cpp +++ b/mozilla/widget/src/mac/nsTextHelper.cpp @@ -43,6 +43,7 @@ #include "nsColor.h" #include "nsGUIEvent.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #define DBG 0 @@ -123,7 +124,7 @@ PRUint32 nsTextHelper::SetText(const nsString& aText) char * buf = new char[aText.Length()+1]; memset(buf, '*', aText.Length()); buf[aText.Length()] = 0; - //printf("SetText [%s] [%s]\n", data->mPassword.ToNewCString(), buf); + //printf("SetText [%s] [%s]\n", NS_LossyConvertUCS2toASCII(data->mPassword).get(), buf); //XmTextSetString(mWidget, buf); data->mIgnore = PR_FALSE; } @@ -150,7 +151,7 @@ PRUint32 nsTextHelper::InsertText(const nsString &aText, PRUint32 aStartPos, PR char * buf = new char[data->mPassword.Length()+1]; memset(buf, '*', data->mPassword.Length()); buf[data->mPassword.Length()] = 0; - //printf("SetText [%s] [%s]\n", data->mPassword.ToNewCString(), buf); + //printf("SetText [%s] [%s]\n", NS_LossyConvertUCS2toASCII(data->mPassword).get(), buf); //XmTextInsert(mWidget, aStartPos, buf); data->mIgnore = PR_FALSE; } diff --git a/mozilla/widget/src/motif/nsMenu.cpp b/mozilla/widget/src/motif/nsMenu.cpp index cbbdfc606da..2642b5d264a 100644 --- a/mozilla/widget/src/motif/nsMenu.cpp +++ b/mozilla/widget/src/motif/nsMenu.cpp @@ -46,6 +46,7 @@ #include "nsIMenuListener.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsCOMPtr.h" @@ -164,7 +165,7 @@ NS_METHOD nsMenu::Create(nsISupports * aParent, const nsString &aLabel) mLabel = aLabel; - char * labelStr = mLabel.ToNewCString(); + char * labelStr = ToNewCString(mLabel); char wName[512]; @@ -373,7 +374,7 @@ void nsMenu::LoadSubMenu(nsIMenu * pParentMenu, { nsString menuName; menuElement->GetAttribute(nsAutoString("label"), menuName); - //printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks + //printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get()); // Create nsMenu nsIMenu * pnsMenu = nsnull; @@ -412,7 +413,7 @@ void nsMenu::LoadSubMenu(nsIMenu * pParentMenu, menuitemElement->GetNodeName(menuitemNodeType); #ifdef DEBUG_saari - printf("Type [%s] %d\n", menuitemNodeType.ToNewCString(), menuitemNodeType.Equals("menuseparator")); + printf("Type [%s] %d\n", NS_LossyConvertUCS2toASCII(menuitemNodeType).get(), menuitemNodeType.Equals("menuseparator")); #endif if (menuitemNodeType.Equals("menuitem")) { diff --git a/mozilla/widget/src/motif/nsMenuItem.cpp b/mozilla/widget/src/motif/nsMenuItem.cpp index a7656621d9b..d97c20bb76f 100644 --- a/mozilla/widget/src/motif/nsMenuItem.cpp +++ b/mozilla/widget/src/motif/nsMenuItem.cpp @@ -48,6 +48,7 @@ #include "nsIPopUpMenu.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIContent.h" #include "nsIContentViewer.h" #include "nsIDOMElement.h" @@ -301,7 +302,7 @@ NS_METHOD nsMenuItem::Create(nsISupports *aParent, if(mIsSeparator) { mMenuItem = nsnull; } else { - char * nameStr = mLabel.ToNewCString(); + char * nameStr = ToNewCString(mLabel); Widget parentMenuHandle = GetNativeParent(); mMenuItem = XtVaCreateManagedWidget(nameStr, xmCascadeButtonGadgetClass, parentMenuHandle, diff --git a/mozilla/widget/src/motif/nsWindow.cpp b/mozilla/widget/src/motif/nsWindow.cpp index cec3e945caf..66cf4544c81 100644 --- a/mozilla/widget/src/motif/nsWindow.cpp +++ b/mozilla/widget/src/motif/nsWindow.cpp @@ -59,6 +59,7 @@ #include "nsXtEventHandler.h" #include "nsXtManageWidget.h" #include "nsAppShell.h" +#include "nsReadableUtils.h" #include "stdio.h" @@ -1157,7 +1158,7 @@ NS_METHOD nsWindow::SetTitle(const nsString& aTitle) if(!mBaseWindow) return NS_ERROR_FAILURE; - const char *text = aTitle.ToNewCString(); + const char *text = ToNewCString(aTitle); XStoreName(gDisplay, mBaseWindow, text); delete [] text; */ diff --git a/mozilla/widget/src/motif/nsXtEventHandler.cpp b/mozilla/widget/src/motif/nsXtEventHandler.cpp index 1c2b92e50c2..e749034cc25 100644 --- a/mozilla/widget/src/motif/nsXtEventHandler.cpp +++ b/mozilla/widget/src/motif/nsXtEventHandler.cpp @@ -45,6 +45,7 @@ #include "nsCheckButton.h" #include "nsGUIEvent.h" #include "nsIMenuItem.h" +#include "nsReadableUtils.h" #include "stdio.h" @@ -419,7 +420,7 @@ void nsXtWidget_Text_Callback(Widget w, XtPointer p, XtPointer call_data) } if (cbs->reason == XmCR_ACTIVATE) { - char* password = data->mPassword.ToNewCString(); + char* password = ToNewCString(data->mPassword); printf ("Password: %s\n", password); delete[] password; return; diff --git a/mozilla/widget/src/os2/nsFilePicker.cpp b/mozilla/widget/src/os2/nsFilePicker.cpp index c2b4e3950e6..0c4c3a5b0d4 100644 --- a/mozilla/widget/src/os2/nsFilePicker.cpp +++ b/mozilla/widget/src/os2/nsFilePicker.cpp @@ -27,6 +27,7 @@ #endif #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsIServiceManager.h" #define NS_IMPL_IDS @@ -92,7 +93,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) char *title = ConvertToFileSystemCharset(mTitle.get()); if (nsnull == title) - title = mTitle.ToNewCString(); + title = ToNewCString(mTitle); char *initialDir; mDisplayDirectory->GetPath(&initialDir); diff --git a/mozilla/widget/src/photon/nsMenu.cpp b/mozilla/widget/src/photon/nsMenu.cpp index 0b6b9b4a0a2..27d14dcc18a 100644 --- a/mozilla/widget/src/photon/nsMenu.cpp +++ b/mozilla/widget/src/photon/nsMenu.cpp @@ -47,6 +47,7 @@ #include "nsColor.h" #include "nsGUIEvent.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsIAppShell.h" @@ -135,7 +136,7 @@ nsMenu::nsMenu() : nsIMenu() //------------------------------------------------------------------------- nsMenu::~nsMenu() { - char *str=mLabel.ToNewCString(); + char *str = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::~nsMenu Destructor called for <%s>\n", str)); delete [] str; @@ -157,7 +158,7 @@ nsMenu::~nsMenu() //------------------------------------------------------------------------- NS_METHOD nsMenu::Create(nsISupports * aParent, const nsString &aLabel) { - char *str=aLabel.ToNewCString(); + char *str = ToNewCString(aLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::Create with nsISupports aLabel=<%s> this=<%p>\n", str, this)); delete [] str; @@ -170,7 +171,7 @@ NS_METHOD nsMenu::Create(nsISupports * aParent, const nsString &aLabel) mLabel = aLabel; /* Create a Char * string from a nsString */ - char *labelStr = mLabel.ToNewCString(); + char *labelStr = ToNewCString(mLabel); if(aParent) { @@ -280,7 +281,7 @@ NS_METHOD nsMenu::GetParent(nsISupports*& aParent) NS_METHOD nsMenu::GetLabel(nsString &aText) { #if 1 - char *str = mLabel.ToNewCString(); + char *str = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::GetLabel mLabel=<%s>\n", str)); delete [] str; #endif @@ -295,7 +296,7 @@ NS_METHOD nsMenu::SetLabel(const nsString &aText) mLabel = aText; #if 1 - char * labelStr = mLabel.ToNewCString(); + char * labelStr = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::SetLabel to this=<%p> <%s>\n", this, labelStr)); delete [] labelStr; #endif @@ -374,7 +375,7 @@ NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu) nsString Label; aMenu->GetLabel(Label); - char *labelStr = Label.ToNewCString(); + char *labelStr = ToNewCString(Label); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::AddMenu this=<%p> aMenu=<%p> label=<%s>\n", this, aMenu, labelStr)); delete[] labelStr; #endif @@ -530,7 +531,7 @@ NS_METHOD nsMenu::RemoveMenuListener(nsIMenuListener * aMenuListener) //------------------------------------------------------------------------- nsEventStatus nsMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent) { - char *labelStr = mLabel.ToNewCString(); + char *labelStr = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::MenuItemSelected mLabel=<%s>\n", labelStr)); delete [] labelStr; @@ -544,7 +545,7 @@ nsEventStatus nsMenu::MenuItemSelected(const nsMenuEvent & aMenuEvent) nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent) { - char *labelStr = mLabel.ToNewCString(); + char *labelStr = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::MenuSelected mLabel=<%s> mConstruct=<%d>\n", labelStr, mConstruct)); delete [] labelStr; @@ -572,7 +573,7 @@ nsEventStatus nsMenu::MenuSelected(const nsMenuEvent & aMenuEvent) //------------------------------------------------------------------------- nsEventStatus nsMenu::MenuDeselected(const nsMenuEvent & aMenuEvent) { - char *str=mLabel.ToNewCString(); + char *str = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::MenuDeSelected for <%s> - Not Implemented\n", str)); delete [] str; @@ -591,7 +592,7 @@ nsEventStatus nsMenu::MenuConstruct( void * menuNode, void * aWebShell) { - char *str=mLabel.ToNewCString(); + char *str = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::MenuConstruct for <%s>\n", str)); delete [] str; @@ -662,7 +663,7 @@ nsEventStatus nsMenu::MenuConstruct( //------------------------------------------------------------------------- nsEventStatus nsMenu::MenuDestruct(const nsMenuEvent & aMenuEvent) { - char *str=mLabel.ToNewCString(); + char *str = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::MenuDestruct called for <%s> mRefCnt=<%d>\n", str, this->mRefCnt)); delete [] str; @@ -748,7 +749,7 @@ void nsMenu::LoadMenuItem( menuitemElement->GetAttribute(nsAutoString("cmd"), menuitemCmd); #if 1 - char *str = menuitemName.ToNewCString(); + char *str = ToNewCString(menuitemName); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::LoadMenuItem -1- Label=<%s> mRefCnt=<%d> this=<%p>\n",str, mRefCnt, this)); delete [] str; #endif @@ -805,7 +806,7 @@ void nsMenu::LoadSubMenu( nsString menuName; menuElement->GetAttribute(nsAutoString("value"), menuName); - PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::LoadSubMenu <%s>\n", menuName.ToNewCString())); + PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::LoadSubMenu <%s>\n", NS_LossyConvertUCS2toASCII(menuName).get())); // Create nsMenu nsIMenu * pnsMenu = nsnull; @@ -845,7 +846,7 @@ int nsMenu::TopLevelMenuItemArmCb (PtWidget_t *widget, void *aNSMenu, PtCallback if ((aMenu) && aMenu->mMenu) { - char *labelStr = aMenu->mLabel.ToNewCString(); + char *labelStr = ToNewCString(aMenu->mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::TopLevelMenuItemArmCb - mLabel=<%s>\n", labelStr)); delete [] labelStr; } @@ -889,7 +890,7 @@ int nsMenu::SubMenuMenuItemArmCb (PtWidget_t *widget, void *aNSMenu, PtCallbackI PtArg_t arg[5]; nsMenu *aMenu = (nsMenu *) aNSMenu; - char *labelStr = aMenu->mLabel.ToNewCString(); + char *labelStr = ToNewCString(aMenu->mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::SubMenuMenuItemArmCb - mLabel=<%s> mRefCnt=<%d> aMenu->mMenu=<%p> Reason=<%d>\n", labelStr, aMenu->mRefCnt, aMenu->mMenu, cbinfo->reason)); delete [] labelStr; @@ -962,7 +963,7 @@ int nsMenu::MenuRealizedCb (PtWidget_t *widget, void *aNSMenu, PtCallbackInfo_t if ((aMenu) && aMenu->mMenu) { - char *labelStr = aMenu->mLabel.ToNewCString(); + char *labelStr = ToNewCString(aMenu->mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::MenuRealizedCb - mLabel=<%s>\n", labelStr)); delete [] labelStr; } @@ -977,7 +978,7 @@ int nsMenu::MenuUnRealizedCb (PtWidget_t *widget, void *aNSMenu, PtCallbackInfo_ if ((aMenu) && aMenu->mMenu) { - char *labelStr = aMenu->mLabel.ToNewCString(); + char *labelStr = ToNewCString(aMenu->mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::MenuUnRealizedCb - mLabel=<%s>\n", labelStr)); delete [] labelStr; } @@ -1014,7 +1015,7 @@ int nsMenu::SubMenuMenuItemMenuCb (PtWidget_t *widget, void *aNSMenu, PtCallback nsMenu *aMenu = (nsMenu *) aNSMenu; if ((aMenu) && aMenu->mMenu) { - char *labelStr = aMenu->mLabel.ToNewCString(); + char *labelStr = ToNewCString(aMenu->mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenu::SubMenuMenuItemMenuCb - mLabel=<%s>\n", labelStr)); delete [] labelStr; } diff --git a/mozilla/widget/src/photon/nsMenuItem.cpp b/mozilla/widget/src/photon/nsMenuItem.cpp index e26109cdca1..73924269999 100644 --- a/mozilla/widget/src/photon/nsMenuItem.cpp +++ b/mozilla/widget/src/photon/nsMenuItem.cpp @@ -47,6 +47,7 @@ #include "nsIPopUpMenu.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIContentViewer.h" #include "nsIDocumentViewer.h" #include "nsIPresContext.h" @@ -122,7 +123,7 @@ nsMenuItem::nsMenuItem() : nsIMenuItem() //------------------------------------------------------------------------- nsMenuItem::~nsMenuItem() { - char *str=mLabel.ToNewCString(); + char *str = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuItem::~nsMenuItem Destructor called for <%s>\n", str)); delete [] str; @@ -150,7 +151,7 @@ void nsMenuItem::Create(nsIWidget *aMBParent, return; } - char * nameStr = mLabel.ToNewCString(); + char * nameStr = ToNewCString(mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuItem::nsMenuItem Create with MenuBar parent this=<%p> aMBParent=<%p> aParent=<%p> label=<%s>\n", this, aMBParent,aParent, nameStr)); @@ -284,7 +285,7 @@ NS_METHOD nsMenuItem::Create(nsISupports *aParent, const nsString &aLabel, PRBool aIsSeparator) { - char *str=aLabel.ToNewCString(); + char *str = ToNewCString(aLabel); PR_LOG(PhWidLog, PR_LOG_ERROR,("nsMenuItem::Create with nsIMenu this=<%p>, aParent=<%p> aLabel=<%s> aIsSep=<%d>\n",this, aParent, str, aIsSeparator)); delete [] str; @@ -494,7 +495,7 @@ nsEventStatus nsMenuItem::MenuDestruct(const nsMenuEvent & aMenuEvent) */ NS_METHOD nsMenuItem::SetCommand(const nsString & aStrCmd) { - char *str = aStrCmd.ToNewCString(); + char *str = ToNewCString(aStrCmd); PR_LOG(PhWidLog, PR_LOG_ERROR,("nsMenuItem::SetCommand mCommandStr=<%s>\n", str)); delete [] str; @@ -672,7 +673,7 @@ int nsMenuItem::MenuItemArmCb (PtWidget_t *widget, void *nsClassPtr, PtCallbackI nsEventStatus status; nsMenuItem *aMenuItem = (nsMenuItem *) nsClassPtr; - char *str = aMenuItem->mLabel.ToNewCString(); + char *str = ToNewCString(aMenuItem->mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuItem::MenuItemArmCB Callback for <%s>\n", str)); delete [] str; @@ -685,7 +686,7 @@ int nsMenuItem::MenuItemDisarmCb (PtWidget_t *widget, void *nsClassPtr, PtCallba nsEventStatus status; nsMenuItem *aMenuItem = (nsMenuItem *) nsClassPtr; - char *str = aMenuItem->mLabel.ToNewCString(); + char *str = ToNewCString(aMenuItem->mLabel); PR_LOG(PhWidLog, PR_LOG_DEBUG, ("nsMenuItem::MenuItemDisarmCB Callback for <%s>\n", str)); delete [] str; diff --git a/mozilla/widget/src/photon/nsPopUpMenu.cpp b/mozilla/widget/src/photon/nsPopUpMenu.cpp index 0e783179a03..de271a35cd9 100644 --- a/mozilla/widget/src/photon/nsPopUpMenu.cpp +++ b/mozilla/widget/src/photon/nsPopUpMenu.cpp @@ -40,6 +40,7 @@ #include "nsIWidget.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsPhWidgetLog.h" @@ -87,7 +88,7 @@ NS_METHOD nsPopUpMenu::Create(nsIWidget *aParent) //------------------------------------------------------------------------- NS_METHOD nsPopUpMenu::AddItem(const nsString &aText) { - char * labelStr = mLabel.ToNewCString(); + char * labelStr = ToNewCString(mLabel); delete[] labelStr; return NS_OK; @@ -109,7 +110,7 @@ NS_METHOD nsPopUpMenu::AddMenu(nsIMenu * aMenu) aMenu->GetLabel(Label); - labelStr = Label.ToNewCString(); + labelStr = ToNewCString(Label); GetNativeData(voidData); // parentmenu = GTK_WIDGET(voidData); diff --git a/mozilla/widget/src/photon/nsStringUtil.h b/mozilla/widget/src/photon/nsStringUtil.h index 6427ccf313c..ee1b8e49eb3 100644 --- a/mozilla/widget/src/photon/nsStringUtil.h +++ b/mozilla/widget/src/photon/nsStringUtil.h @@ -37,6 +37,7 @@ // Convience macros for converting nsString's to chars + // creating temporary char[] bufs. +#include "nsReadableUtils.h" #ifndef NS_STR_UTIL_H #define NS_STR_UTIL_H @@ -61,7 +62,7 @@ varName = _ns_smallBuffer; \ } \ else { \ - varName = strName.ToNewCString(); \ + varName = ToNewCString(strName); \ } #define NS_FREE_STR_BUF(varName) \ diff --git a/mozilla/widget/src/photon/nsWidget.cpp b/mozilla/widget/src/photon/nsWidget.cpp index a74ee525f3e..638f66868b9 100644 --- a/mozilla/widget/src/photon/nsWidget.cpp +++ b/mozilla/widget/src/photon/nsWidget.cpp @@ -54,6 +54,7 @@ #include "nsIRollupListener.h" #include "nsIServiceManager.h" #include "nsWindow.h" +#include "nsReadableUtils.h" #include "nsIPref.h" #include "nsPhWidgetLog.h" @@ -564,7 +565,7 @@ NS_METHOD nsWidget::SetFont( const nsFont &aFont ) { mFontMetrics->GetFontHandle(aFontHandle); nsString *aString; aString = (nsString *) aFontHandle; - char *str = aString->ToNewCString(); + char *str = ToNewCString(*aString); PtSetArg( &arg, Pt_ARG_TEXT_FONT, str, 0 ); PtSetResources( mWidget, 1, &arg ); diff --git a/mozilla/widget/src/photon/nsWindow.cpp b/mozilla/widget/src/photon/nsWindow.cpp index 3bfa45a6697..25c605d0249 100644 --- a/mozilla/widget/src/photon/nsWindow.cpp +++ b/mozilla/widget/src/photon/nsWindow.cpp @@ -68,6 +68,7 @@ #include "nsIDocShellTreeItem.h" #include "nsIWindowMediator.h" #include "nsIPresShell.h" +#include "nsReadableUtils.h" PRBool nsWindow::mResizeQueueInited = PR_FALSE; @@ -610,7 +611,7 @@ NS_IMETHODIMP nsWindow::ScrollRect( nsRect &aSrcRect, PRInt32 aDx, PRInt32 aDy ) NS_METHOD nsWindow::SetTitle( const nsString& aTitle ) { nsresult res = NS_ERROR_FAILURE; - char * title = aTitle.ToNewUTF8String(); + char * title = ToNewUTF8String(aTitle); if( mWidget ) { PtSetResource( mWidget, Pt_ARG_WINDOW_TITLE, title, 0 ); diff --git a/mozilla/widget/src/qt/nsMenu.cpp b/mozilla/widget/src/qt/nsMenu.cpp index 0f0a3fa4773..48ccc419ce7 100644 --- a/mozilla/widget/src/qt/nsMenu.cpp +++ b/mozilla/widget/src/qt/nsMenu.cpp @@ -41,6 +41,7 @@ #include "nsIMenuItem.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsIMenuListener.h" #include "nsQEventHandler.h" @@ -219,7 +220,7 @@ NS_METHOD nsMenu::SetLabel(const nsString &aText) NS_METHOD nsMenu::GetAccessKey(nsString &aText) { aText = mAccessKey; - char *foo = mAccessKey.ToNewCString(); + char *foo = ToNewCString(mAccessKey); PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsMenu::GetAccessKey returns \"%s\"\n", foo)); delete [] foo; @@ -230,7 +231,7 @@ NS_METHOD nsMenu::GetAccessKey(nsString &aText) NS_METHOD nsMenu::SetAccessKey(const nsString &aText) { mAccessKey = aText; - char *foo = mAccessKey.ToNewCString(); + char *foo = ToNewCString(mAccessKey); PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsMenu::SetAccessKey to \"%s\"\n", foo)); delete [] foo; @@ -291,7 +292,7 @@ NS_METHOD nsMenu::AddMenu(nsIMenu * aMenu) aMenu->GetLabel(Label); - labelStr = Label.ToNewCString(); + labelStr = ToNewCString(Label); QString string = labelStr; diff --git a/mozilla/widget/src/qt/nsMenuBar.cpp b/mozilla/widget/src/qt/nsMenuBar.cpp index 3a4163f9156..b1443e80b83 100644 --- a/mozilla/widget/src/qt/nsMenuBar.cpp +++ b/mozilla/widget/src/qt/nsMenuBar.cpp @@ -40,6 +40,7 @@ #include "nsIWidget.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsQEventHandler.h" @@ -160,7 +161,7 @@ NS_METHOD nsMenuBar::AddMenu(nsIMenu * aMenu) aMenu->GetLabel(Label); - labelStr = Label.ToNewCString(); + labelStr = ToNewCString(Label); QString string = labelStr; diff --git a/mozilla/widget/src/qt/nsMenuItem.cpp b/mozilla/widget/src/qt/nsMenuItem.cpp index 5d0d467ab93..004ed206b15 100644 --- a/mozilla/widget/src/qt/nsMenuItem.cpp +++ b/mozilla/widget/src/qt/nsMenuItem.cpp @@ -44,6 +44,7 @@ #include "nsIPopUpMenu.h" #include "nsQEventHandler.h" #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsIContent.h" #include "nsIContentViewer.h" #include "nsIDOMElement.h" @@ -137,7 +138,7 @@ void nsMenuItem::Create(nsIWidget * aMBParent, return; } - char * nameStr = mLabel.ToNewCString(); + char * nameStr = ToNewCString(mLabel); mMenuItem = new QString(nameStr); diff --git a/mozilla/widget/src/qt/nsPopUpMenu.cpp b/mozilla/widget/src/qt/nsPopUpMenu.cpp index 9578e7cbc88..cd4811a162d 100644 --- a/mozilla/widget/src/qt/nsPopUpMenu.cpp +++ b/mozilla/widget/src/qt/nsPopUpMenu.cpp @@ -40,6 +40,7 @@ #include "nsIWidget.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsQEventHandler.h" @@ -101,7 +102,7 @@ NS_METHOD nsPopUpMenu::Create(nsIWidget *aParent) NS_METHOD nsPopUpMenu::AddItem(const nsString &aText) { PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsPopUpMenu::AddItem()\n")); - char * labelStr = mLabel.ToNewCString(); + char * labelStr = ToNewCString(mLabel); mMenu->insertItem(labelStr); @@ -137,7 +138,7 @@ NS_METHOD nsPopUpMenu::AddMenu(nsIMenu * aMenu) aMenu->GetLabel(Label); - labelStr = Label.ToNewCString(); + labelStr = ToNewCString(Label); aMenu->GetNativeData(&voidData); newmenu = (QPopupMenu *) voidData; diff --git a/mozilla/widget/src/qt/nsTextHelper.cpp b/mozilla/widget/src/qt/nsTextHelper.cpp index a64c90d1d36..76f1bf224a2 100644 --- a/mozilla/widget/src/qt/nsTextHelper.cpp +++ b/mozilla/widget/src/qt/nsTextHelper.cpp @@ -41,6 +41,7 @@ #include "nsColor.h" #include "nsGUIEvent.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include "nsWindow.h" @@ -135,7 +136,7 @@ NS_METHOD nsTextHelper::GetText(nsString& aTextBuffer, //------------------------------------------------------------------------- NS_METHOD nsTextHelper::SetText(const nsString& aText, PRUint32& aActualSize) { - char *buf = aText.ToNewCString(); + char *buf = ToNewCString(aText); PR_LOG(QtWidgetsLM, PR_LOG_DEBUG, ("nsTextHelper::SetText to \"%s\"\n", buf)); diff --git a/mozilla/widget/src/qt/nsWidget.cpp b/mozilla/widget/src/qt/nsWidget.cpp index 69be8293e8f..6c9727fe8a9 100644 --- a/mozilla/widget/src/qt/nsWidget.cpp +++ b/mozilla/widget/src/qt/nsWidget.cpp @@ -43,6 +43,7 @@ #include "nsIComponentManager.h" #include "nsIMenuRollup.h" #include "nsFontMetricsQT.h" +#include "nsReadableUtils.h" #include @@ -582,7 +583,7 @@ NS_METHOD nsWidget::SetPreferredSize(PRInt32 aWidth,PRInt32 aHeight) NS_METHOD nsWidget::SetTitle(const nsString &aTitle) { if (mWidget) { - const char *title = aTitle.ToNewCString(); + const char *title = ToNewCString(aTitle); mWidget->SetTitle(title); delete [] title; diff --git a/mozilla/widget/src/windows/nsClipboard.cpp b/mozilla/widget/src/windows/nsClipboard.cpp index 44e3b0d9654..4bd772c9ee5 100644 --- a/mozilla/widget/src/windows/nsClipboard.cpp +++ b/mozilla/widget/src/windows/nsClipboard.cpp @@ -51,6 +51,7 @@ #include "nsCOMPtr.h" #include "nsISupportsPrimitives.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsPrimitiveHelpers.h" #include "nsIURL.h" #include "nsImageClipboard.h" @@ -662,7 +663,7 @@ nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, v nsMemory::Free(*outData); nsAutoString urlUnicode; urlUnicode.AssignWithConversion( buffer ); - *outData = urlUnicode.ToNewUnicode(); + *outData = ToNewUnicode(urlUnicode); *outDataLen = strlen(buffer) * sizeof(PRUnichar); nsMemory::Free(buffer); @@ -680,7 +681,7 @@ nsClipboard :: FindURLFromLocalFile ( IDataObject* inDataObject, UINT inIndex, v nsMemory::Free(*outData); nsAutoString urlSpecUnicode; urlSpecUnicode.AssignWithConversion( urlSpec ); - *outData = urlSpecUnicode.ToNewUnicode(); + *outData = ToNewUnicode(urlSpecUnicode); *outDataLen = strlen(urlSpec.get()) * sizeof(PRUnichar); dataFound = PR_TRUE; diff --git a/mozilla/widget/src/windows/nsDataObj.cpp b/mozilla/widget/src/windows/nsDataObj.cpp index 82f0e2d0d65..123b041c466 100644 --- a/mozilla/widget/src/windows/nsDataObj.cpp +++ b/mozilla/widget/src/windows/nsDataObj.cpp @@ -38,6 +38,7 @@ #include "nsDataObj.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsVoidArray.h" #include "nsITransferable.h" #include "nsISupportsPrimitives.h" @@ -462,7 +463,7 @@ nsDataObj :: GetFileDescriptorInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG nsAutoString title; if ( NS_FAILED(ExtractShortcutTitle(title)) ) return E_OUTOFMEMORY; - char* titleStr = title.ToNewCString(); // XXX what about unicode urls?!?! + char* titleStr = ToNewCString(title); // XXX what about unicode urls?!?! if ( !titleStr ) return E_OUTOFMEMORY; @@ -508,7 +509,7 @@ nsDataObj :: GetFileContentsInternetShortcut ( FORMATETC& aFE, STGMEDIUM& aSTG ) nsAutoString url; if ( NS_FAILED(ExtractShortcutURL(url)) ) return E_OUTOFMEMORY; - char* urlStr = url.ToNewCString(); // XXX what about unicode urls?!?! + char* urlStr = ToNewCString(url); // XXX what about unicode urls?!?! if ( !urlStr ) return E_OUTOFMEMORY; diff --git a/mozilla/widget/src/windows/nsFilePicker.cpp b/mozilla/widget/src/windows/nsFilePicker.cpp index 4f2d33cfdc7..a09bc5acac3 100644 --- a/mozilla/widget/src/windows/nsFilePicker.cpp +++ b/mozilla/widget/src/windows/nsFilePicker.cpp @@ -27,6 +27,7 @@ #endif #include "nsCOMPtr.h" +#include "nsReadableUtils.h" #include "nsNetUtil.h" #include "nsIServiceManager.h" #define NS_IMPL_IDS @@ -93,7 +94,7 @@ NS_IMETHODIMP nsFilePicker::Show(PRInt16 *retval) char *title = ConvertToFileSystemCharset(mTitle.get()); if (nsnull == title) - title = mTitle.ToNewCString(); + title = ToNewCString(mTitle); char *initialDir; mDisplayDirectory->GetPath(&initialDir); diff --git a/mozilla/widget/src/windows/nsPopUpMenu.cpp b/mozilla/widget/src/windows/nsPopUpMenu.cpp index 95a386858d9..abdcc2f08f8 100644 --- a/mozilla/widget/src/windows/nsPopUpMenu.cpp +++ b/mozilla/widget/src/windows/nsPopUpMenu.cpp @@ -42,6 +42,7 @@ #include "nsColor.h" #include "nsGUIEvent.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsStringUtil.h" #include @@ -111,7 +112,7 @@ NS_METHOD nsPopUpMenu::AddItem(nsIMenuItem * aMenuItem) aMenuItem->GetCommand(command); aMenuItem->GetLabel(name); - char * nameStr = name.ToNewCString(); + char * nameStr = ToNewCString(name); MENUITEMINFO menuInfo; menuInfo.cbSize = sizeof(menuInfo); @@ -133,7 +134,7 @@ NS_METHOD nsPopUpMenu::AddMenu(nsIMenu * aMenu) { nsString name; aMenu->GetLabel(name); - char * nameStr = name.ToNewCString(); + char * nameStr = ToNewCString(name); HMENU nativeMenuHandle; void * voidData; diff --git a/mozilla/widget/src/xpwidgets/nsDataFlavor.cpp b/mozilla/widget/src/xpwidgets/nsDataFlavor.cpp index 3f287eefe76..88925595ccb 100644 --- a/mozilla/widget/src/xpwidgets/nsDataFlavor.cpp +++ b/mozilla/widget/src/xpwidgets/nsDataFlavor.cpp @@ -36,6 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsDataFlavor.h" +#include "nsReadableUtils.h" static NS_DEFINE_IID(kIDataFlavor, NS_IDATAFLAVOR_IID); @@ -94,7 +95,7 @@ NS_METHOD nsDataFlavor::Init(const nsString & aMimeType, const nsString & aHuman mMimeType = aMimeType; mHumanPresentableName = aHumanPresentableName; - char * str = mMimeType.ToNewCString(); + char * str = ToNewCString(mMimeType); delete[] str; diff --git a/mozilla/widget/src/xpwidgets/nsTransferable.cpp b/mozilla/widget/src/xpwidgets/nsTransferable.cpp index 0f4ea694aca..05a7c840ddc 100644 --- a/mozilla/widget/src/xpwidgets/nsTransferable.cpp +++ b/mozilla/widget/src/xpwidgets/nsTransferable.cpp @@ -49,6 +49,7 @@ Notes to self: #include "nsTransferable.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsVoidArray.h" #include "nsIFormatConverter.h" #include "nsVoidArray.h" @@ -402,7 +403,7 @@ nsTransferable::GetAnyTransferData(char **aFlavor, nsISupports **aData, PRUint32 for ( PRInt32 i=0; i < mDataArray->Count(); ++i ) { DataStruct * data = (DataStruct *)mDataArray->ElementAt(i); if (data->IsDataAvilable()) { - *aFlavor = data->GetFlavor().ToNewCString(); + *aFlavor = ToNewCString(data->GetFlavor()); data->GetData(aData, aDataLen); return NS_OK; } diff --git a/mozilla/xpcom/appshell/eventloop/xp/nsCBaseLoop.cpp b/mozilla/xpcom/appshell/eventloop/xp/nsCBaseLoop.cpp index 223b4b70363..893b4daf3de 100644 --- a/mozilla/xpcom/appshell/eventloop/xp/nsCBaseLoop.cpp +++ b/mozilla/xpcom/appshell/eventloop/xp/nsCBaseLoop.cpp @@ -25,6 +25,7 @@ #include "nsCBaseLoop.h" #include "nsCEvent.h" #include "nsCEventFilter.h" +#include "nsReadableUtils.h" //***************************************************************************** //*** nsCBaseLoop: Object Management @@ -232,7 +233,7 @@ NS_IMETHODIMP nsCBaseLoop::GetEventLoopName(PRUnichar** pName) { NS_ENSURE_ARG_POINTER(pName); - *pName = m_LoopName.ToNewUnicode(); + *pName = ToNewUnicode(m_LoopName); return *pName ? NS_OK : NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/xpcom/base/nsConsoleMessage.cpp b/mozilla/xpcom/base/nsConsoleMessage.cpp index 4a818e2660b..30f4966abf7 100644 --- a/mozilla/xpcom/base/nsConsoleMessage.cpp +++ b/mozilla/xpcom/base/nsConsoleMessage.cpp @@ -40,6 +40,7 @@ */ #include "nsConsoleMessage.h" +#include "nsReadableUtils.h" NS_IMPL_THREADSAFE_ISUPPORTS1(nsConsoleMessage, nsIConsoleMessage); @@ -58,7 +59,7 @@ nsConsoleMessage::~nsConsoleMessage() {}; NS_IMETHODIMP nsConsoleMessage::GetMessage(PRUnichar **result) { - *result = mMessage.ToNewUnicode(); + *result = ToNewUnicode(mMessage); return NS_OK; } @@ -66,7 +67,7 @@ nsConsoleMessage::GetMessage(PRUnichar **result) { // NS_IMETHODIMP // nsConsoleMessage::Init(const PRUnichar *message) { // nsAutoString newMessage(message); -// mMessage = newMessage.ToNewUnicode(); +// mMessage = ToNewUnicode(newMessage); // return NS_OK; // } diff --git a/mozilla/xpcom/ds/nsPersistentProperties.cpp b/mozilla/xpcom/ds/nsPersistentProperties.cpp index 7aae637931e..aa04da629c2 100644 --- a/mozilla/xpcom/ds/nsPersistentProperties.cpp +++ b/mozilla/xpcom/ds/nsPersistentProperties.cpp @@ -41,6 +41,7 @@ #include "nsPersistentProperties.h" #include "nsID.h" #include "nsCRT.h" +#include "nsReadableUtils.h" #include "nsIInputStream.h" #include "nsIProperties.h" #include "nsIUnicharInputStream.h" @@ -228,10 +229,8 @@ NS_IMETHODIMP nsPersistentProperties::SetStringProperty(const nsString& aKey, nsString& aNewValue, nsString& aOldValue) { - // XXX The ToNewCString() calls allocate memory using "new" so this code - // causes a memory leak... #if 0 - cout << "will add " << aKey.ToNewCString() << "=" << aNewValue.ToNewCString() << endl; + cout << "will add " << NS_LossyConvertUCS2toASCII(aKey).get() << "=" << NS_LossyConvertUCS2ToASCII(aNewValue).get() << endl; #endif if (!mTable) { return NS_ERROR_FAILURE; @@ -251,8 +250,8 @@ nsPersistentProperties::SetStringProperty(const nsString& aKey, nsString& aNewVa #endif return NS_OK; } - PL_HashTableRawAdd(mTable, hep, hashValue, aKey.ToNewUnicode(), - aNewValue.ToNewUnicode()); + PL_HashTableRawAdd(mTable, hep, hashValue, ToNewUnicode(aKey), + ToNewUnicode(aNewValue)); return NS_OK; } @@ -484,7 +483,7 @@ nsPropertyElement::GetKey(PRUnichar **aReturnKey) { if (aReturnKey) { - *aReturnKey = (PRUnichar *) mKey->ToNewUnicode(); + *aReturnKey = ToNewUnicode(*mKey); return NS_OK; } @@ -496,7 +495,7 @@ nsPropertyElement::GetValue(PRUnichar **aReturnValue) { if (aReturnValue) { - *aReturnValue = (PRUnichar *) mValue->ToNewUnicode(); + *aReturnValue = ToNewUnicode(*mValue); return NS_OK; } diff --git a/mozilla/xpcom/ds/nsTextFormatter.cpp b/mozilla/xpcom/ds/nsTextFormatter.cpp index 11188ccf456..d15938bfc8c 100644 --- a/mozilla/xpcom/ds/nsTextFormatter.cpp +++ b/mozilla/xpcom/ds/nsTextFormatter.cpp @@ -35,6 +35,7 @@ #include "nsCRT.h" #include "nsTextFormatter.h" #include "nsString.h" +#include "nsReadableUtils.h" /* @@ -1414,7 +1415,7 @@ PRBool nsTextFormatter::SelfTest() ret = nsTextFormatter::snprintf(buf, 256, fmt.get(), d, 333, utf8, ucs2); printf("ret = %d\n", ret); nsAutoString out(buf); - printf("%s \n",out.ToNewCString()); + printf("%s \n", NS_LossyConvertUCS2toASCII(out).get()); const PRUnichar *uout = out.get(); for(PRUint32 i=0;i #include #include "nsString.h" +#include "nsReadableUtils.h" #include "nsDebug.h" #include "nsCRT.h" #include "nsDeque.h" @@ -532,34 +533,6 @@ nsCString* nsCString::ToNewString() const { return new nsCString(*this); } -/** - * Creates an ascii clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update gess 02/24/00 - * @return ptr to new ascii string - */ -char* nsCString::ToNewCString() const { - return nsCRT::strdup(mStr); -} - -/** - * Creates an unicode clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update gess 01/04/99 - * @return ptr to new ascii string - */ -PRUnichar* nsCString::ToNewUnicode() const { - PRUnichar* result = NS_STATIC_CAST(PRUnichar*, nsMemory::Alloc(sizeof(PRUnichar) * (mLength + 1))); - if (result) { - CBufDescriptor desc(result, PR_TRUE, mLength + 1, 0); - nsAutoString temp(desc); - temp.AssignWithConversion(mStr); - } - return result; -} - /** * Copies contents of this string into he given buffer * Note that if you provide me a buffer that is smaller than the length of @@ -1330,7 +1303,7 @@ NS_COM int fputs(const nsCString& aString, FILE* out) char* cp = buf; PRInt32 len = aString.mLength; if (len >= PRInt32(sizeof(buf))) { - cp = aString.ToNewCString(); + cp = ToNewCString(aString); } else { aString.ToCString(cp, len + 1); } @@ -1376,7 +1349,7 @@ NS_ConvertUCS2toUTF8::Append( const PRUnichar* aString, PRUint32 aLength ) if (! aString) return; - // Caculate how many bytes we need + // Calculate how many bytes we need const PRUnichar* p; PRInt32 count, utf8len; for (p = aString, utf8len = 0, count = aLength; 0 != count && 0 != (*p); count--, p++) @@ -1463,6 +1436,20 @@ NS_ConvertUCS2toUTF8::Append( const PRUnichar* aString, PRUint32 aLength ) mLength += utf8len; } +NS_LossyConvertUCS2toASCII::NS_LossyConvertUCS2toASCII( const nsAString& aString ) + { + SetCapacity(aString.Length()); + + nsAString::const_iterator start; aString.BeginReading(start); + nsAString::const_iterator end; aString.EndReading(end); + + while (start != end) { + nsReadableFragment frag(start.fragment()); + AppendWithConversion(frag.mStart, frag.mEnd - frag.mStart); + start.advance(start.size_forward()); + } + } + /*********************************************************************** IMPLEMENTATION NOTES: AUTOSTRING... diff --git a/mozilla/xpcom/string/obsolete/nsString.h b/mozilla/xpcom/string/obsolete/nsString.h index afdd33cee90..89e4c027d52 100644 --- a/mozilla/xpcom/string/obsolete/nsString.h +++ b/mozilla/xpcom/string/obsolete/nsString.h @@ -260,22 +260,6 @@ public: */ nsCString* ToNewString() const; - /** - * Creates an ISOLatin1 clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new isolatin1 string - */ - char* ToNewCString() const; - - /** - * Creates a unicode clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new unicode string - */ - PRUnichar* ToNewUnicode() const; - /** * Copies data from internal buffer onto given char* buffer * NOTE: This only copies as many chars as will fit in given buffer (clips) @@ -550,6 +534,34 @@ class NS_COM NS_ConvertUCS2toUTF8 operator const char*() const; // use |get()| }; +/** + * A helper class that converts a UCS2 string to ASCII in a lossy manner + */ +class NS_COM NS_LossyConvertUCS2toASCII + : public nsCAutoString + /* + ... + */ + { + public: + explicit + NS_LossyConvertUCS2toASCII( const PRUnichar* aString ) + { + AppendWithConversion( aString, ~PRUint32(0) /* MAXINT */); + } + + NS_LossyConvertUCS2toASCII( const PRUnichar* aString, PRUint32 aLength ) + { + AppendWithConversion( aString, aLength ); + } + + explicit NS_LossyConvertUCS2toASCII( const nsAString& aString ); + + private: + // NOT TO BE IMPLEMENTED + NS_LossyConvertUCS2toASCII( char ); + operator const char*() const; // use |get()| + }; #endif diff --git a/mozilla/xpcom/string/obsolete/nsString2.cpp b/mozilla/xpcom/string/obsolete/nsString2.cpp index 8e7d3b5862b..506af5fd55f 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.cpp +++ b/mozilla/xpcom/string/obsolete/nsString2.cpp @@ -41,6 +41,7 @@ #include #include #include "nsString.h" +#include "nsReadableUtils.h" #include "nsDebug.h" #include "nsDeque.h" @@ -561,64 +562,6 @@ nsString* nsString::ToNewString() const { return new nsString(*this); } -/** - * Creates an ascii clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update gess 02/24/00 - * @WARNING! Potential i18n issue here, since we're stepping down from 2byte chars to 1byte chars! - * @return ptr to new ascii string - */ -char* nsString::ToNewCString() const { - char* result = NS_STATIC_CAST(char*, nsMemory::Alloc(mLength + 1)); - if (result) { - CBufDescriptor desc(result, PR_TRUE, mLength + 1, 0); - nsCAutoString temp(desc); - temp.AssignWithConversion(*this); - } - return result; -} - -/** - * Creates an UTF8 clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update ftang 09/10/99 - * @return ptr to new UTF8 string - * http://www.cis.ohio-state.edu/htbin/rfc/rfc2279.html - */ -char* nsString::ToNewUTF8String() const { - NS_ConvertUCS2toUTF8 temp(mUStr); - - char* result; - if (temp.mOwnsBuffer) { - // We allocated. Trick the string into not freeing its buffer to - // avoid an extra allocation. - result = temp.mStr; - - temp.mStr=0; - temp.mOwnsBuffer = PR_FALSE; - } - else { - // We didn't allocate a buffer, so we need to copy it out of the - // nsCAutoString's storage. - result = nsCRT::strdup(temp.mStr); - } - - return result; -} - -/** - * Creates an ascii clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @update gess 02/24/00 - * @return ptr to new ascii string - */ -PRUnichar* nsString::ToNewUnicode() const { - return nsCRT::strdup(mUStr); -} - /** * Copies contents of this string into he given buffer * Note that if you provide me a buffer that is smaller than the length of @@ -1556,7 +1499,7 @@ NS_COM int fputs(const nsString& aString, FILE* out) char* cp = buf; PRInt32 len = aString.mLength; if (len >= PRInt32(sizeof(buf))) { - cp = aString.ToNewCString(); + cp = ToNewCString(aString); } else { aString.ToCString(cp, len + 1); } diff --git a/mozilla/xpcom/string/obsolete/nsString2.h b/mozilla/xpcom/string/obsolete/nsString2.h index 6846389d7ba..510cba022bc 100644 --- a/mozilla/xpcom/string/obsolete/nsString2.h +++ b/mozilla/xpcom/string/obsolete/nsString2.h @@ -280,30 +280,6 @@ public: */ nsString* ToNewString() const; - /** - * Creates an ISOLatin1 clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new isolatin1 string - */ - char* ToNewCString() const; - - /** - * Creates an UTF8 clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new null-terminated UTF8 string - */ - char* ToNewUTF8String() const; - - /** - * Creates a unicode clone of this string - * Note that calls to this method should be matched with calls to - * |nsMemory::Free|. - * @return ptr to new unicode string - */ - PRUnichar* ToNewUnicode() const; - /** * Copies data from internal buffer onto given char* buffer * NOTE: This only copies as many chars as will fit in given buffer (clips) diff --git a/mozilla/xpcom/tests/PropertiesTest.cpp b/mozilla/xpcom/tests/PropertiesTest.cpp index c119f27ce73..ad56e1bf1be 100644 --- a/mozilla/xpcom/tests/PropertiesTest.cpp +++ b/mozilla/xpcom/tests/PropertiesTest.cpp @@ -49,6 +49,7 @@ #include "nsIComponentManager.h" #include "nsIEnumerator.h" #include //BAD DOG -- no biscuit! +#include "nsReadableUtils.h" #include "nsSpecialSystemDirectory.h" @@ -161,7 +162,7 @@ main(int argc, char* argv[]) if (NS_FAILED(ret) || (!v.Length())) { break; } - char* value = v.ToNewCString(); + char* value = ToNewCString(v); if (value) { cout << "\"" << i << "\"=\"" << value << "\"" << endl; delete[] value; @@ -213,8 +214,8 @@ main(int argc, char* argv[]) nsAutoString keyAdjustedLengthBuff(pKey); nsAutoString valAdjustedLengthBuff(pVal); - char* keyCStr = keyAdjustedLengthBuff.ToNewCString(); - char* valCStr = valAdjustedLengthBuff.ToNewCString(); + char* keyCStr = ToNewCString(keyAdjustedLengthBuff); + char* valCStr = ToNewCString(valAdjustedLengthBuff); if (keyCStr && valCStr) cout << keyCStr << "\t" << valCStr << endl; delete[] keyCStr; diff --git a/mozilla/xpcom/tests/TestAtoms.cpp b/mozilla/xpcom/tests/TestAtoms.cpp index 474df9a18b1..ce3090296d8 100644 --- a/mozilla/xpcom/tests/TestAtoms.cpp +++ b/mozilla/xpcom/tests/TestAtoms.cpp @@ -36,6 +36,7 @@ * ***** END LICENSE BLOCK ***** */ #include "nsIAtom.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prprf.h" #include "prtime.h" #include @@ -64,9 +65,9 @@ int main(int argc, char** argv) } nsAutoString sb; sb.AssignWithConversion(buf); - strings[count++] = sb.ToNewUnicode(); + strings[count++] = ToNewUnicode(sb); sb.ToUpperCase(); - strings[count++] = sb.ToNewUnicode(); + strings[count++] = ToNewUnicode(sb); } PRTime end0 = PR_Now(); @@ -87,7 +88,7 @@ int main(int argc, char** argv) id->ToString(s1); ids[i]->ToString(s2); printf("find failed: id='%s' ids[%d]='%s'\n", - s1.ToNewCString(), i, s2.ToNewCString()); + NS_LossyConvertUCS2toASCII(s1).get(), i, NS_LossyConvertUCS2toASCII(s2).get()); return -1; } NS_RELEASE(id); diff --git a/mozilla/xpcom/tests/TestObserverService.cpp b/mozilla/xpcom/tests/TestObserverService.cpp index 8556d46673a..82eee6b2e80 100644 --- a/mozilla/xpcom/tests/TestObserverService.cpp +++ b/mozilla/xpcom/tests/TestObserverService.cpp @@ -42,6 +42,7 @@ #include "nsIObserverService.h" #include "nsIObserver.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "prprf.h" #include #include // needed for libstdc++-v3 @@ -59,7 +60,7 @@ static void testResult( nsresult rv ) { } extern ostream &operator<<( ostream &s, nsString &str ) { - const char *cstr = str.ToNewCString(); + const char *cstr = ToNewCString(str); s << cstr; delete [] (char*)cstr; return s; diff --git a/mozilla/xpcom/tests/windows/nsStringTest.cpp b/mozilla/xpcom/tests/windows/nsStringTest.cpp index 3a156b3fa99..6719ed38abf 100644 --- a/mozilla/xpcom/tests/windows/nsStringTest.cpp +++ b/mozilla/xpcom/tests/windows/nsStringTest.cpp @@ -3,6 +3,7 @@ #include "nsStr.h" #include "nsStringTest2.h" #include "nsString.h" +#include "nsReadableUtils.h" int main(){ @@ -13,11 +14,11 @@ int main(){ temp1.CompressSet("\t\n\r ",' ',false,false); nsString temp3(""); - char* s=temp3.ToNewCString(); + char* s = ToNewCString(temp3); delete s; - char* f=nsAutoString("").ToNewCString(); - char* f1=nsCAutoString("").ToNewCString(); + char* f = ToNewCString(nsAutoString("")); + char* f1 = ToNewCString(nsCAutoString("")); delete f; delete f1; diff --git a/mozilla/xpcom/tests/windows/nsStringTest.h b/mozilla/xpcom/tests/windows/nsStringTest.h index f600a4fb1f4..b5ac0f65296 100644 --- a/mozilla/xpcom/tests/windows/nsStringTest.h +++ b/mozilla/xpcom/tests/windows/nsStringTest.h @@ -19,6 +19,7 @@ #include "nsString.h" +#include "nsReadableUtils.h" #include #define USE_STL @@ -939,7 +940,7 @@ int CStringTester::TestCreators(){ /* NOT WORKING YET { nsString theString5(""); - char* str0=theString5.ToNewCString(); + char* str0 = ToNewCString(theString5); Recycle(str0); theString5+="hello rick"; @@ -947,11 +948,11 @@ int CStringTester::TestCreators(){ delete theString6; nsString theString1("hello again"); - PRUnichar* thePBuf=theString1.ToNewUnicode(); + PRUnichar* thePBuf=ToNewUnicode(theString1); if(thePBuf) Recycle(thePBuf); - char* str=theString5.ToNewCString(); + char* str = ToNewCString(theString5); if(str) Recycle(str); @@ -965,11 +966,11 @@ int CStringTester::TestCreators(){ nsCString* theString6=theString5.ToNewString(); delete theString6; - PRUnichar* thePBuf=theString5.ToNewUnicode(); + PRUnichar* thePBuf=ToNewUnicode(theString5); if(thePBuf) Recycle(thePBuf); - char* str=theString5.ToNewCString(); + char* str = ToNewCString(theString5); if(str) Recycle(str); diff --git a/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl b/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl index a351552e2a8..ee9f7768a3e 100644 --- a/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl +++ b/mozilla/xpfe/appshell/public/nsICmdLineHandler.idl @@ -49,6 +49,7 @@ #include "nsICategoryManager.h" #include "nsIFileSpec.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" struct nsModuleComponentInfo; // forward declaration @@ -61,7 +62,7 @@ static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, c NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \ { \ if (!aDefaultArgs) return NS_ERROR_FAILURE; \ - *aDefaultArgs = NS_ConvertASCIItoUCS2(macro_default_args).ToNewUnicode(); \ + *aDefaultArgs = ToNewUnicode(nsDependentCString(macro_default_args)); \ return NS_OK; \ } diff --git a/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp b/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp index 95d4c102e3e..dc47c908e48 100644 --- a/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp +++ b/mozilla/xpfe/appshell/src/nsCommandLineServiceMac.cpp @@ -59,6 +59,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "nsISupportsPrimitives.h" #include "nsIWindowWatcher.h" #include "jsapi.h" +#include "nsReadableUtils.h" #include "nsAEEventHandling.h" @@ -144,7 +145,7 @@ nsresult nsMacCommandLine::Initialize(int& argc, char**& argv) // of the buffer, which is never freed until the command line handler // goes way (and, since it's static, that is at library unload time). - mArgsBuffer = mTempArgsString.ToNewCString(); + mArgsBuffer = ToNewCString(mTempArgsString); mTempArgsString.Truncate(); // it's job is done // Parse the buffer. diff --git a/mozilla/xpfe/appshell/src/nsInternetConfig.cpp b/mozilla/xpfe/appshell/src/nsInternetConfig.cpp index b6d178bc21b..39a7e0ff00d 100644 --- a/mozilla/xpfe/appshell/src/nsInternetConfig.cpp +++ b/mozilla/xpfe/appshell/src/nsInternetConfig.cpp @@ -37,6 +37,7 @@ #include "nsInternetConfig.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsDebug.h" #include @@ -140,7 +141,7 @@ nsresult nsInternetConfig::GetString( unsigned char* inKey, char** outString ) // Buffer is a Pascal string nsCString temp( &buffer[1], buffer[0] ); - *outString = temp.ToNewCString(); + *outString = ToNewCString(temp); result = NS_OK; } } diff --git a/mozilla/xpfe/appshell/src/nsInternetConfigService.cpp b/mozilla/xpfe/appshell/src/nsInternetConfigService.cpp index 231378fe1e2..60fb049bc52 100644 --- a/mozilla/xpfe/appshell/src/nsInternetConfigService.cpp +++ b/mozilla/xpfe/appshell/src/nsInternetConfigService.cpp @@ -43,6 +43,7 @@ #include "nsLocalFileMac.h" #include "nsIURL.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsMimeTypes.h" #include #include "nsColor.h" @@ -591,7 +592,7 @@ NS_IMETHODIMP nsInternetConfigService::GetString(PRUint32 inKey, char **value) // Buffer is a Pascal string; convert it to a c-string nsCString temp( &buffer[1], buffer[0] ); - *value = temp.ToNewCString(); + *value = ToNewCString(temp); } return result; diff --git a/mozilla/xpfe/appshell/src/nsUserInfoMac.cpp b/mozilla/xpfe/appshell/src/nsUserInfoMac.cpp index 264004ecc9d..c06d23c769f 100644 --- a/mozilla/xpfe/appshell/src/nsUserInfoMac.cpp +++ b/mozilla/xpfe/appshell/src/nsUserInfoMac.cpp @@ -38,6 +38,7 @@ #include "nsUserInfo.h" #include "nsInternetConfig.h" #include "nsString.h" +#include "nsReadableUtils.h" nsUserInfo::nsUserInfo() { @@ -61,7 +62,7 @@ nsUserInfo::GetFullname(PRUnichar **aFullname) nsString fullName; fullName.AssignWithConversion( cName ); nsMemory::Free( cName ); - *aFullname = fullName.ToNewUnicode(); + *aFullname = ToNewUnicode(fullName); } return result; } @@ -90,7 +91,7 @@ nsUserInfo::GetUsername(char * *aUsername) if (atOffset != kNotFound) tempString.Truncate(atOffset); - *aUsername = tempString.ToNewCString(); + *aUsername = ToNewCString(tempString); return NS_OK; } @@ -110,7 +111,7 @@ nsUserInfo::GetDomain(char * *aDomain) { nsCAutoString domainString; tempString.Right(domainString, tempString.Length() - (atOffset + 1)); - *aDomain = domainString.ToNewCString(); + *aDomain = ToNewCString(domainString); return NS_OK; } diff --git a/mozilla/xpfe/appshell/src/nsUserInfoUnix.cpp b/mozilla/xpfe/appshell/src/nsUserInfoUnix.cpp index d8148778395..898b7f0f152 100644 --- a/mozilla/xpfe/appshell/src/nsUserInfoUnix.cpp +++ b/mozilla/xpfe/appshell/src/nsUserInfoUnix.cpp @@ -46,6 +46,7 @@ #include "nsString.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" /* Some UNIXy platforms don't have pw_gecos. In this case we use pw_name */ #if defined(NO_PW_GECOS) @@ -99,7 +100,7 @@ nsUserInfo::GetFullname(PRUnichar **aFullname) fullname.ReplaceSubstring("&", (const char *) username); } - *aFullname = fullname.ToNewUnicode(); + *aFullname = ToNewUnicode(fullname); if (*aFullname) return NS_OK; diff --git a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp index 3c0474fce31..1c1f58e2bb2 100644 --- a/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp +++ b/mozilla/xpfe/appshell/src/nsWebShellWindow.cpp @@ -52,6 +52,7 @@ #include "nsNetCID.h" #include "nsIStringBundle.h" #include "nsIPref.h" +#include "nsReadableUtils.h" #include "nsINameSpaceManager.h" #include "nsEscape.h" @@ -745,13 +746,13 @@ NS_IMETHODIMP nsWebShellWindow::LoadMenuItem( pnsMenuItem->AddMenuListener(listener); #ifdef DEBUG_MENUSDEL - printf("Adding menu listener to [%s]\n", menuitemName.ToNewCString()); + printf("Adding menu listener to [%s]\n", NS_LossyConvertUCS2toASCII(menuitemName).get()); #endif } #ifdef DEBUG_MENUSDEL else { - printf("*** NOT Adding menu listener to [%s]\n", menuitemName.ToNewCString()); + printf("*** NOT Adding menu listener to [%s]\n", NS_LossyConvertUCS2toASCII(menuitemName).get()); } #endif NS_RELEASE(icmd); @@ -771,7 +772,7 @@ void nsWebShellWindow::LoadSubMenu( { nsString menuName; menuElement->GetAttribute(NS_ConvertASCIItoUCS2("label"), menuName); - //printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks + //printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get()); // Create nsMenu nsIMenu * pnsMenu = nsnull; @@ -825,7 +826,7 @@ void nsWebShellWindow::LoadSubMenu( menuitemElement->GetNodeName(menuitemNodeType); #ifdef DEBUG_saari - printf("Type [%s] %d\n", menuitemNodeType.ToNewCString(), menuitemNodeType.Equals("menuseparator")); + printf("Type [%s] %d\n", NS_LossyConvertUCS2toASCII(menuitemNodeType).get(), menuitemNodeType.Equals("menuseparator")); #endif if (menuitemNodeType.EqualsWithConversion("menuitem")) { @@ -972,7 +973,7 @@ void nsWebShellWindow::LoadMenus(nsIDOMDocument * aDOMDoc, nsIWidget * aParentWi menuElement->GetAttribute(NS_ConvertASCIItoUCS2("label"), menuName); #ifdef DEBUG_rods - printf("Creating Menu [%s] \n", menuName.ToNewCString()); // this leaks + printf("Creating Menu [%s] \n", NS_LossyConvertUCS2toASCII(menuName).get()); #endif CreateMenu(pnsMenuBar, menuNode, menuName); } @@ -1296,7 +1297,7 @@ nsCOMPtr nsWebShellWindow::FindNamedDOMNode(const nsString &aName, n while (node) { nsString name; node->GetNodeName(name); - //printf("FindNamedDOMNode[%s]==[%s] %d == %d\n", aName.ToNewCString(), name.ToNewCString(), aCount+1, aEndCount); //this leaks + //printf("FindNamedDOMNode[%s]==[%s] %d == %d\n", NS_LossyConvertUCS2toASCII(aName).get(), NS_LossyConvertUCS2toASCII(name).get(), aCount+1, aEndCount); if (name.Equals(aName)) { aCount++; if (aCount == aEndCount) @@ -1418,7 +1419,7 @@ void nsWebShellWindow::LoadContentAreas() { // see if we have a webshell with a matching contentAreaID rv = GetContentShellById(contentAreaID, &contentShell); if (NS_SUCCEEDED(rv)) { - urlChar = contentURL.ToNewCString(); + urlChar = ToNewCString(contentURL); if (urlChar) { nsUnescape(urlChar); contentURL.AssignWithConversion(urlChar); diff --git a/mozilla/xpfe/appshell/src/nsWindowMediator.cpp b/mozilla/xpfe/appshell/src/nsWindowMediator.cpp index bd3cb52b158..2980af83e75 100644 --- a/mozilla/xpfe/appshell/src/nsWindowMediator.cpp +++ b/mozilla/xpfe/appshell/src/nsWindowMediator.cpp @@ -39,6 +39,7 @@ #include "nsCOMPtr.h" #include "nsAutoLock.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsVoidArray.h" #include "rdf.h" #include "nsIBaseWindow.h" @@ -753,7 +754,7 @@ NS_IMETHODIMP nsWindowMediator::GetWindowForResource( const PRUnichar* inResour // Find the window //nsresult result = NS_ERROR_FAILURE; nsAutoString temp( inResource ); - char* resourceString = temp.ToNewCString(); + char* resourceString = ToNewCString(temp); nsWindowInfo *info, *listEnd; diff --git a/mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp b/mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp index b7e6693dab6..a2507eda808 100644 --- a/mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp +++ b/mozilla/xpfe/bootstrap/nsDocLoadObserver.cpp @@ -41,6 +41,7 @@ #include "nsIObserverService.h" #include "nsIServiceManager.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsAEUtils.h" #include "nsAESpyglassSuiteHandler.h" @@ -128,7 +129,7 @@ NS_IMETHODIMP nsDocLoadObserver::Observe(nsISupports* /*aSubject*/, // create the descriptor for the URL nsString urlText(someData); - char* urlString = urlText.ToNewCString(); + char* urlString = ToNewCString(urlText); StAEDesc url; OSErr err = ::AECreateDesc(typeChar, urlString, urlText.Length(), &url); diff --git a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp index a390182abae..91873e83be5 100644 --- a/mozilla/xpfe/browser/src/nsBrowserInstance.cpp +++ b/mozilla/xpfe/browser/src/nsBrowserInstance.cpp @@ -77,6 +77,7 @@ #include "nsIWindowWatcher.h" #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIPref.h" #include "nsIServiceManager.h" @@ -286,7 +287,7 @@ public: nsresult rv = NS_OK; nsString data(someData); if (data.Find(mLastRequest) == 0) { - char* dataStr = data.ToNewCString(); + char* dataStr = ToNewCString(data); printf("########## PageCycler loaded (%d ms): %s\n", PR_IntervalToMilliseconds(PR_IntervalNow() - mIntervalTime), dataStr); @@ -336,7 +337,7 @@ public: } } else { - char* dataStr = data.ToNewCString(); + char* dataStr = ToNewCString(data); printf("########## PageCycler possible failure for: %s\n", dataStr); nsCRT::free(dataStr); } @@ -993,7 +994,7 @@ NS_IMETHODIMP nsBrowserContentHandler::GetDefaultArgs(PRUnichar **aDefaultArgs) } } - *aDefaultArgs = args.ToNewUnicode(); + *aDefaultArgs = ToNewUnicode(args); return NS_OK; } diff --git a/mozilla/xpfe/components/autocomplete/src/nsAutoComplete.cpp b/mozilla/xpfe/components/autocomplete/src/nsAutoComplete.cpp index 57bf4c7bc40..b4126f4582e 100644 --- a/mozilla/xpfe/components/autocomplete/src/nsAutoComplete.cpp +++ b/mozilla/xpfe/components/autocomplete/src/nsAutoComplete.cpp @@ -39,6 +39,7 @@ #include "nsCOMPtr.h" #include "prtypes.h" #include "nsAutoComplete.h" +#include "nsReadableUtils.h" /****************************************************************************** * nsAutoCompleteItem @@ -70,7 +71,7 @@ NS_IMETHODIMP nsAutoCompleteItem::SetValue(const nsAReadableString& aValue) NS_IMETHODIMP nsAutoCompleteItem::GetComment(PRUnichar * *aComment) { if (!aComment) return NS_ERROR_NULL_POINTER; - *aComment = mComment.ToNewUnicode(); + *aComment = ToNewUnicode(mComment); return NS_OK; } NS_IMETHODIMP nsAutoCompleteItem::SetComment(const PRUnichar * aComment) @@ -83,7 +84,7 @@ NS_IMETHODIMP nsAutoCompleteItem::SetComment(const PRUnichar * aComment) NS_IMETHODIMP nsAutoCompleteItem::GetClassName(char * *aClassName) { if (!aClassName) return NS_ERROR_NULL_POINTER; - *aClassName = mClassName.ToNewCString(); + *aClassName = ToNewCString(mClassName); return NS_OK; } NS_IMETHODIMP nsAutoCompleteItem::SetClassName(const char * aClassName) @@ -126,7 +127,7 @@ nsAutoCompleteResults::~nsAutoCompleteResults() NS_IMETHODIMP nsAutoCompleteResults::GetSearchString(PRUnichar * *aSearchString) { if (!aSearchString) return NS_ERROR_NULL_POINTER; - *aSearchString = mSearchString.ToNewUnicode(); + *aSearchString = ToNewUnicode(mSearchString); return NS_OK; } diff --git a/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.cpp b/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.cpp index bd4d49569e5..08de57b2495 100644 --- a/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.cpp +++ b/mozilla/xpfe/components/autocomplete/src/nsLDAPAutoCompleteSession.cpp @@ -38,6 +38,7 @@ #include "nsILDAPURL.h" #include "nsILDAPService.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nspr.h" #include "nsLDAP.h" @@ -1170,7 +1171,7 @@ nsLDAPAutoCompleteSession::GetFilterTemplate(PRUnichar * *aFilterTemplate) return NS_ERROR_NULL_POINTER; } - *aFilterTemplate = mFilterTemplate.ToNewUnicode(); + *aFilterTemplate = ToNewUnicode(mFilterTemplate); if (!*aFilterTemplate) { return NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp index 12f6b54fd47..9857847da71 100644 --- a/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp +++ b/mozilla/xpfe/components/bookmarks/src/nsBookmarksService.cpp @@ -72,6 +72,7 @@ #include "nsIAtom.h" #include "nsIDirectoryService.h" #include "nsAppDirectoryServiceDefs.h" +#include "nsReadableUtils.h" #include "nsISound.h" #include "nsIPrompt.h" @@ -1862,7 +1863,7 @@ nsBookmarksService::ExamineBookmarkSchedule(nsIRDFResource *theBookmark, PRBool #ifdef DEBUG_BOOKMARK_PING_OUTPUT - char *methodStr = notificationMethod.ToNewCString(); + char *methodStr = ToNewCString(notificationMethod); if (methodStr) { printf("Start Hour: %d End Hour: %d Duration: %d mins Method: '%s'\n", @@ -4345,7 +4346,7 @@ nsBookmarksService::WriteBookmarksContainer(nsIRDFDataSource *ds, nsOutputFileSt nsAutoString indentationString; // STRING USE WARNING: converting in a loop. Probably not a good idea for (PRInt32 loop=0; loopGetValueConst(&title))) { nameString = title; - name = nameString.ToNewUTF8String(); + name = ToNewUTF8String(nameString); } } } @@ -4629,7 +4630,7 @@ nsBookmarksService::WriteBookmarkProperties(nsIRDFDataSource *ds, nsOutputFileSt nsAutoString literalString; if (NS_SUCCEEDED(rv = GetTextForNode(node, literalString))) { - char *attribute = literalString.ToNewUTF8String(); + char *attribute = ToNewUTF8String(literalString); if (nsnull != attribute) { if (isFirst == PR_FALSE) diff --git a/mozilla/xpfe/components/find/src/nsFindComponent.cpp b/mozilla/xpfe/components/find/src/nsFindComponent.cpp index cc7d02dbc0e..1736d60ae32 100644 --- a/mozilla/xpfe/components/find/src/nsFindComponent.cpp +++ b/mozilla/xpfe/components/find/src/nsFindComponent.cpp @@ -40,6 +40,7 @@ #include "nsCOMPtr.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "pratom.h" #include "prio.h" #include "prprf.h" @@ -311,7 +312,7 @@ NS_IMETHODIMP nsFindComponent::Context::GetSearchString(PRUnichar * *aSearchString) { nsresult rv = NS_OK; if ( aSearchString ) { - *aSearchString = mSearchString.ToNewUnicode(); + *aSearchString = ToNewUnicode(mSearchString); if ( !*aSearchString ) { rv = NS_ERROR_OUT_OF_MEMORY; } @@ -332,7 +333,7 @@ NS_IMETHODIMP nsFindComponent::Context::GetReplaceString(PRUnichar * *aReplaceString) { nsresult rv = NS_OK; if ( aReplaceString ) { - *aReplaceString = mReplaceString.ToNewUnicode(); + *aReplaceString = ToNewUnicode(mReplaceString); if ( !*aReplaceString ) { rv = NS_ERROR_OUT_OF_MEMORY; } diff --git a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp index 3b9dafe844e..dc5d37cbc4e 100644 --- a/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp +++ b/mozilla/xpfe/components/history/src/nsGlobalHistory.cpp @@ -1265,7 +1265,7 @@ nsGlobalHistory::GetSources(nsIRDFResource* aProperty, rv = PRInt64ToChars(n, valueStr); if (NS_FAILED(rv)) return rv; - value = (void *)valueStr.ToNewCString(); + value = (void *)ToNewCString(valueStr); if (aProperty == kNC_Date) col = kToken_LastVisitDateColumn; else @@ -1281,8 +1281,8 @@ nsGlobalHistory::GetSources(nsIRDFResource* aProperty, if (NS_FAILED(rv)) return rv; nsAutoString valueStr; valueStr.AppendInt(intValue); - value = valueStr.ToNewUnicode(); - len = nsCRT::strlen((PRUnichar*)value); + value = ToNewUnicode(valueStr); + len = valueStr.Length() * sizeof(PRUnichar); col = kToken_VisitCountColumn; } diff --git a/mozilla/xpfe/components/related/src/nsRelatedLinksHandler.cpp b/mozilla/xpfe/components/related/src/nsRelatedLinksHandler.cpp index 84171b111f2..39e18b3c4d6 100644 --- a/mozilla/xpfe/components/related/src/nsRelatedLinksHandler.cpp +++ b/mozilla/xpfe/components/related/src/nsRelatedLinksHandler.cpp @@ -58,6 +58,7 @@ #include "nsRDFCID.h" #include "nsVoidArray.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nscore.h" #include "plhash.h" #include "plstr.h" @@ -382,7 +383,7 @@ RelatedLinksStreamListener::OnDataAvailable(nsIRequest *request, nsISupports *ct if (oneLiner.Length() < 1) break; #if 0 - printf("RL: '%s'\n", oneLiner.ToNewCString()); + printf("RL: '%s'\n", NS_LossyConvertUCS2toASCII(oneLiner).get()); #endif // yes, very primitive RDF parsing follows @@ -495,7 +496,7 @@ RelatedLinksStreamListener::OnDataAvailable(nsIRequest *request, nsISupports *ct { #if 0 - printf("RL: '%s' - '%s'\n", title.ToNewCString(), child.ToNewCString()); + printf("RL: '%s' - '%s'\n", NS_LossyConvertUCS2toASCII(title).get(), NS_LossyConvertUCS2toASCII(child).get()); #endif const PRUnichar *url = child.get(); if (nsnull != url) diff --git a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp index 7468e688f41..e7c9e2fa78b 100755 --- a/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp +++ b/mozilla/xpfe/components/search/src/nsInternetSearchService.cpp @@ -77,6 +77,7 @@ #include "nsIStringBundle.h" #include "nsIObserverService.h" #include "nsIURL.h" +#include "nsReadableUtils.h" #ifdef XP_MAC #include @@ -1806,7 +1807,7 @@ InternetSearchDataSource::getSearchURI(nsIRDFResource *src) if (uriUni) { nsAutoString uriString(uriUni); - uri = uriString.ToNewUTF8String(); + uri = ToNewUTF8String(uriString); } } } @@ -2434,7 +2435,7 @@ InternetSearchDataSource::GetInternetSearchURL(const char *searchEngineURI, // convert from escaped-UTF_8, to unicode, and then to // the charset indicated by the dataset in question - char *utf8data = text.ToNewUTF8String(); + char *utf8data = ToNewUTF8String(text); if (utf8data) { nsCOMPtr textToSubURI = @@ -2472,7 +2473,7 @@ InternetSearchDataSource::GetInternetSearchURL(const char *searchEngineURI, action += input; // return a copy of the resulting search URL - *resultURL = action.ToNewCString(); + *resultURL = ToNewCString(action); return(NS_OK); } @@ -2668,7 +2669,7 @@ InternetSearchDataSource::FindInternetSearchResults(const char *url, PRBool *sea engineURI += searchText; #ifdef DEBUG_SEARCH_OUTPUT - char *engineMatch = searchText.ToNewCString(); + char *engineMatch = ToNewCString(searchText); if (engineMatch) { printf("FindInternetSearchResults: search for: '%s'\n\n", @@ -2953,7 +2954,7 @@ InternetSearchDataSource::BeginSearchRequest(nsIRDFResource *source, PRBool doNe if ((value.Find(kEngineProtocol) == 0) || (value.Find(kURINC_SearchCategoryEnginePrefix) == 0)) { - char *val = value.ToNewCString(); + char *val = ToNewCString(value); if (val) { engineArray->AppendElement(val); @@ -3062,7 +3063,7 @@ InternetSearchDataSource::FindData(nsIRDFResource *engine, nsIRDFLiteral **dataL if (engineStr.Find(kEngineProtocol) != 0) return(rv); engineStr.Cut(0, sizeof(kEngineProtocol) - 1); - char *baseFilename = engineStr.ToNewCString(); + char *baseFilename = ToNewCString(engineStr); if (!baseFilename) return(rv); baseFilename = nsUnescape(baseFilename); @@ -3543,7 +3544,7 @@ InternetSearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engin // convert from escaped-UTF_8, to unicode, and then to // the charset indicated by the dataset in question - char *utf8data = textTemp.ToNewUTF8String(); + char *utf8data = ToNewUTF8String(textTemp); if (utf8data) { nsCOMPtr textToSubURI = @@ -4971,7 +4972,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRD htmlResults.Cut(0, resultItemEnd); #ifdef DEBUG_SEARCH_OUTPUT - char *results = resultItem.ToNewCString(); + char *results = ToNewCString(resultItem); if (results) { printf("\n----- Search result: '%s'\n\n", results); @@ -5076,7 +5077,7 @@ InternetSearchDataSource::ParseHTML(nsIURI *aURL, nsIRDFResource *mParent, nsIRD nsAutoString site(hrefStr); #ifdef DEBUG_SEARCH_OUTPUT - char *hrefCStr = hrefStr.ToNewCString(); + char *hrefCStr = ToNewCString(hrefStr); if (hrefCStr) { printf("HREF: '%s'\n", hrefCStr); diff --git a/mozilla/xpfe/components/shistory/src/nsSHEntry.cpp b/mozilla/xpfe/components/shistory/src/nsSHEntry.cpp index fbe7a4637d8..aab01808c47 100644 --- a/mozilla/xpfe/components/shistory/src/nsSHEntry.cpp +++ b/mozilla/xpfe/components/shistory/src/nsSHEntry.cpp @@ -23,6 +23,7 @@ // Local Includes #include "nsSHEntry.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIDocShellLoadInfo.h" PRUint32 gEntryID=0; @@ -126,7 +127,7 @@ NS_IMETHODIMP nsSHEntry::GetTitle(PRUnichar** aTitle) } } - *aTitle = mTitle.ToNewUnicode(); + *aTitle = ToNewUnicode(mTitle); return NS_OK; } diff --git a/mozilla/xpfe/components/shistory/src/nsSHistory.cpp b/mozilla/xpfe/components/shistory/src/nsSHistory.cpp index 258720333ec..6ff71e62232 100644 --- a/mozilla/xpfe/components/shistory/src/nsSHistory.cpp +++ b/mozilla/xpfe/components/shistory/src/nsSHistory.cpp @@ -25,11 +25,11 @@ // Helper Classes #include "nsXPIDLString.h" +#include "nsReadableUtils.h" // Interfaces Needed #include "nsILayoutHistoryState.h" #include "nsIDocShellLoadInfo.h" -#include "nsXPIDLString.h" #include "nsISHContainer.h" #include "nsIDocShellTreeItem.h" #include "nsIDocShellTreeNode.h" @@ -297,7 +297,7 @@ nsSHistory::PrintHistory() char * titleCStr=nsnull; nsString titlestr(title); - titleCStr = titlestr.ToNewCString(); + titleCStr = ToNewCString(titlestr); printf("**** SH Transaction #%d, Entry = %x\n", index, entry.get()); printf("\t\t URL = %s\n", url); printf("\t\t Title = %s\n", titleCStr); diff --git a/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl b/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl index a351552e2a8..ee9f7768a3e 100644 --- a/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl +++ b/mozilla/xpfe/components/startup/public/nsICmdLineHandler.idl @@ -49,6 +49,7 @@ #include "nsICategoryManager.h" #include "nsIFileSpec.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsIServiceManager.h" struct nsModuleComponentInfo; // forward declaration @@ -61,7 +62,7 @@ static NS_METHOD UnregisterProc(nsIComponentManager *aCompMgr, nsIFile *aPath, c NS_IMETHODIMP macro_class::GetDefaultArgs(PRUnichar **aDefaultArgs) \ { \ if (!aDefaultArgs) return NS_ERROR_FAILURE; \ - *aDefaultArgs = NS_ConvertASCIItoUCS2(macro_default_args).ToNewUnicode(); \ + *aDefaultArgs = ToNewUnicode(nsDependentCString(macro_default_args)); \ return NS_OK; \ } diff --git a/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp b/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp index 95d4c102e3e..dc47c908e48 100644 --- a/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp +++ b/mozilla/xpfe/components/startup/src/nsCommandLineServiceMac.cpp @@ -59,6 +59,7 @@ static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID); #include "nsISupportsPrimitives.h" #include "nsIWindowWatcher.h" #include "jsapi.h" +#include "nsReadableUtils.h" #include "nsAEEventHandling.h" @@ -144,7 +145,7 @@ nsresult nsMacCommandLine::Initialize(int& argc, char**& argv) // of the buffer, which is never freed until the command line handler // goes way (and, since it's static, that is at library unload time). - mArgsBuffer = mTempArgsString.ToNewCString(); + mArgsBuffer = ToNewCString(mTempArgsString); mTempArgsString.Truncate(); // it's job is done // Parse the buffer. diff --git a/mozilla/xpfe/components/startup/src/nsUserInfoMac.cpp b/mozilla/xpfe/components/startup/src/nsUserInfoMac.cpp index 264004ecc9d..c06d23c769f 100644 --- a/mozilla/xpfe/components/startup/src/nsUserInfoMac.cpp +++ b/mozilla/xpfe/components/startup/src/nsUserInfoMac.cpp @@ -38,6 +38,7 @@ #include "nsUserInfo.h" #include "nsInternetConfig.h" #include "nsString.h" +#include "nsReadableUtils.h" nsUserInfo::nsUserInfo() { @@ -61,7 +62,7 @@ nsUserInfo::GetFullname(PRUnichar **aFullname) nsString fullName; fullName.AssignWithConversion( cName ); nsMemory::Free( cName ); - *aFullname = fullName.ToNewUnicode(); + *aFullname = ToNewUnicode(fullName); } return result; } @@ -90,7 +91,7 @@ nsUserInfo::GetUsername(char * *aUsername) if (atOffset != kNotFound) tempString.Truncate(atOffset); - *aUsername = tempString.ToNewCString(); + *aUsername = ToNewCString(tempString); return NS_OK; } @@ -110,7 +111,7 @@ nsUserInfo::GetDomain(char * *aDomain) { nsCAutoString domainString; tempString.Right(domainString, tempString.Length() - (atOffset + 1)); - *aDomain = domainString.ToNewCString(); + *aDomain = ToNewCString(domainString); return NS_OK; } diff --git a/mozilla/xpfe/components/startup/src/nsUserInfoUnix.cpp b/mozilla/xpfe/components/startup/src/nsUserInfoUnix.cpp index d8148778395..898b7f0f152 100644 --- a/mozilla/xpfe/components/startup/src/nsUserInfoUnix.cpp +++ b/mozilla/xpfe/components/startup/src/nsUserInfoUnix.cpp @@ -46,6 +46,7 @@ #include "nsString.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" /* Some UNIXy platforms don't have pw_gecos. In this case we use pw_name */ #if defined(NO_PW_GECOS) @@ -99,7 +100,7 @@ nsUserInfo::GetFullname(PRUnichar **aFullname) fullname.ReplaceSubstring("&", (const char *) username); } - *aFullname = fullname.ToNewUnicode(); + *aFullname = ToNewUnicode(fullname); if (*aFullname) return NS_OK; diff --git a/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp b/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp index a17cb01a0f6..65bf83bf9f4 100644 --- a/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp +++ b/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.cpp @@ -23,6 +23,7 @@ // Local Includes #include "nsString.h" +#include "nsReadableUtils.h" #include "nsUrlbarHistory.h" // Helper Classes @@ -210,7 +211,7 @@ nsUrlbarHistory::PrintHistory() entry = (nsString *) mArray.ElementAt(i); NS_ENSURE_TRUE(entry, NS_ERROR_FAILURE); char * cEntry; - cEntry = entry->ToNewCString(); + cEntry = ToNewCString(*entry); printf("Entry at index %d is %s\n", i, cEntry); Recycle(cEntry); } @@ -399,7 +400,10 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults* // There was no protocol in the search string. searchPath = searchAutoStr; } - //printf("Search String is %s path = %s protocol = %s \n", searchAutoStr.ToNewCString(), searchPath.ToNewCString(), searchProtocol.ToNewCString()); + //printf("Search String is %s path = %s protocol = %s \n", + // NS_LossyConvertUCS2toASCII(searchAutoStr).get(), + // NS_LossyConvertUCS2toASCII(searchPath).get(), + // NS_LossyConvertUCS2toASCII(searchProtocol).get()); if (!gRDFCUtils || !kNC_URLBARHISTORY) return NS_ERROR_FAILURE; @@ -427,7 +431,7 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults* nsAutoString rdfAutoStr; nsAutoString rdfProtocol, rdfPath; PRInt32 rdfLength, rdfPathIndex, index = -1; - PRUnichar * match = nsnull; + const PRUnichar * match = nsnull; const PRUnichar * rdfValue = nsnull; rv = entries->GetNext(getter_AddRefs(entry)); @@ -453,7 +457,10 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults* // There was no protocol. rdfPath = rdfAutoStr; } - //printf("RDFString is %s path = %s protocol = %s\n", rdfAutoStr.ToNewCString(), rdfPath.ToNewCString(), rdfProtocol.ToNewCString()); + //printf("RDFString is %s path = %s protocol = %s\n", + // NS_LossyConvertUCS2toASCII(rdfAutoStr).get(), + // NS_LossyConvertUCS2toASCII(rdfPath).get(), + // NS_LossyConvertUCS2toASCII(rdfProtocol).get()); // We have all the data we need. Let's do the comparison // We compare the path first and compare the protocol next index = rdfPath.Find(searchPath, PR_TRUE); @@ -464,7 +471,7 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults* protocolIndex = rdfProtocol.Find(searchProtocol); if (protocolIndex == 0) { // Both protocols match. We found a result item - match = rdfAutoStr.ToNewUnicode(); + match = rdfAutoStr.get(); } } else if (searchProtocol.Length() && (rdfProtocol.Length() <= 0)) { @@ -477,7 +484,7 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults* // all urls to be char * if ((searchProtocol.Find("http://", PR_TRUE)) == 0) { resultAutoStr = searchProtocol + rdfPath; - match = resultAutoStr.ToNewUnicode(); + match = resultAutoStr.get(); } } else if ((searchProtocol.Length() <=0) && rdfProtocol.Length() || @@ -487,7 +494,7 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults* * a) searchString has no protocol but rdfString has protocol * b) Both searchString and rdfString don't have a protocol */ - match = rdfPath.ToNewUnicode(); + match = rdfPath.get(); } } // (index == 0) @@ -506,21 +513,20 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults* PRBool itemPresent = PR_FALSE; rv = CheckItemAvailability(match, results, &itemPresent); if (itemPresent) { - Recycle (match); continue; } //Create an AutoComplete Item - nsCOMPtr newItem(do_CreateInstance(NS_AUTOCOMPLETEITEM_CONTRACTID)); - NS_ENSURE_TRUE(newItem, NS_ERROR_FAILURE); + nsCOMPtr newItem(do_CreateInstance(NS_AUTOCOMPLETEITEM_CONTRACTID)); + NS_ENSURE_TRUE(newItem, NS_ERROR_FAILURE); newItem->SetValue(nsDependentString(match)); nsCOMPtr array; rv = results->GetItems(getter_AddRefs(array)); if (NS_SUCCEEDED(rv)) - { - // printf("Appending element %s to the results array\n", item->ToNewCString()); - array->AppendElement((nsISupports*)newItem); - } + { + // printf("Appending element %s to the results array\n", ToNewCString(*item)); // leaks + array->AppendElement((nsISupports*)newItem); + } /* The result may be much more than what was asked for. For example * the user types http://www.moz and we had http://www.mozilla.org/sidebar * as an entry in the history. This will match our selection criteria above @@ -530,10 +536,8 @@ nsUrlbarHistory::SearchCache(const PRUnichar* searchStr, nsIAutoCompleteResults* * as a result option(probably the default result). */ rv = VerifyAndCreateEntry(searchStr, match, results); - } + } - if (match) - Recycle(match); } // while return rv; } @@ -625,7 +629,7 @@ nsUrlbarHistory::CheckItemAvailability(const PRUnichar * aItem, nsIAutoCompleteR } NS_IMETHODIMP -nsUrlbarHistory::VerifyAndCreateEntry(const PRUnichar * aSearchItem, PRUnichar * aMatchStr, nsIAutoCompleteResults * aResultArray) +nsUrlbarHistory::VerifyAndCreateEntry(const PRUnichar * aSearchItem, const PRUnichar * aMatchStr, nsIAutoCompleteResults * aResultArray) { if (!aSearchItem || !aMatchStr || !aResultArray) return NS_ERROR_FAILURE; @@ -660,7 +664,7 @@ nsUrlbarHistory::VerifyAndCreateEntry(const PRUnichar * aSearchItem, PRUnichar * // Extract the host name nsAutoString hostName; matchAutoStr.Left(hostName, slashIndex); - //printf("#### Host Name is %s\n", hostName.ToNewCString()); + //printf("#### Host Name is %s\n", NS_LossyConvertUCS2toASCII(hostName).get()); // Check if this host is already present in the result array // If not add it to the result array PRBool itemAvailable = PR_TRUE; diff --git a/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.h b/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.h index 2e872af5af8..ea3aca6edaa 100644 --- a/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.h +++ b/mozilla/xpfe/components/urlbarhistory/src/nsUrlbarHistory.h @@ -51,7 +51,7 @@ protected: NS_IMETHOD SearchCache(const PRUnichar *, nsIAutoCompleteResults *); NS_IMETHOD GetHostIndex(const PRUnichar * aPath, PRInt32 * aReturn); NS_IMETHOD CheckItemAvailability(const PRUnichar * aItem, nsIAutoCompleteResults * aArray, PRBool * aResult); - NS_IMETHOD VerifyAndCreateEntry(const PRUnichar * aItem, PRUnichar * aMatchItem, nsIAutoCompleteResults * aArray); + NS_IMETHOD VerifyAndCreateEntry(const PRUnichar * aItem, const PRUnichar * aMatchItem, nsIAutoCompleteResults * aArray); private: nsVoidArray mArray; diff --git a/mozilla/xpfe/components/xremote/src/XRemoteService.cpp b/mozilla/xpfe/components/xremote/src/XRemoteService.cpp index a9cc379fff9..40b181d2c3d 100644 --- a/mozilla/xpfe/components/xremote/src/XRemoteService.cpp +++ b/mozilla/xpfe/components/xremote/src/XRemoteService.cpp @@ -492,7 +492,7 @@ XRemoteService::BuildResponse(const char *aError, const char *aMessage) retvalString.Append(" "); retvalString.Append(aMessage); - retval = retvalString.ToNewCString(); + retval = ToNewCString(retvalString); return retval; } diff --git a/mozilla/xpinstall/src/nsInstall.cpp b/mozilla/xpinstall/src/nsInstall.cpp index f89c4b9e731..7ed80969483 100644 --- a/mozilla/xpinstall/src/nsInstall.cpp +++ b/mozilla/xpinstall/src/nsInstall.cpp @@ -29,6 +29,7 @@ #include "nscore.h" #include "nsIFactory.h" #include "nsISupports.h" +#include "nsReadableUtils.h" #include "nsIComponentManager.h" #include "nsIServiceManager.h" @@ -1236,33 +1237,25 @@ nsInstall::LoadResources(JSContext* cx, const nsString& aBaseName, jsval* aRetur if (NS_FAILED(ret)) goto cleanup; - PRUnichar *pKey = nsnull; - PRUnichar *pVal = nsnull; + nsXPIDLString pKey; + nsXPIDLString pVal; - ret = propElem->GetKey(&pKey); + ret = propElem->GetKey(getter_Copies(pKey)); if (NS_FAILED(ret)) goto cleanup; - ret = propElem->GetValue(&pVal); + ret = propElem->GetValue(getter_Copies(pVal)); if (NS_FAILED(ret)) goto cleanup; - nsAutoString keyAdjustedLengthBuff(pKey); - nsAutoString valAdjustedLengthBuff(pVal); + nsXPIDLCString keyCStr; + keyCStr.Adopt(ToNewCString(pKey)); - char* keyCStr = keyAdjustedLengthBuff.ToNewCString(); - PRUnichar* valCStr = valAdjustedLengthBuff.ToNewUnicode(); - if (keyCStr && valCStr) + if (keyCStr.get() && pVal.get()) { - JSString* propValJSStr = JS_NewUCStringCopyZ(cx, (jschar*) valCStr); + JSString* propValJSStr = JS_NewUCStringCopyZ(cx, NS_REINTERPRET_CAST(const jschar*, pVal.get())); jsval propValJSVal = STRING_TO_JSVAL(propValJSStr); - JS_SetProperty(cx, res, keyCStr, &propValJSVal); - delete[] keyCStr; - delete[] valCStr; + JS_SetProperty(cx, res, keyCStr.get(), &propValJSVal); } - if (pKey) - delete[] pKey; - if (pVal) - delete[] pVal; ret = propEnum->Next(); } @@ -2710,7 +2703,7 @@ nsInstall::GetResourcedString(const nsString& aResName) rscdStr.AssignWithConversion(nsInstallResources::GetDefaultVal(temp)); } - return rscdStr.ToNewCString(); + return ToNewCString(rscdStr); } diff --git a/mozilla/xpinstall/src/nsInstallExecute.cpp b/mozilla/xpinstall/src/nsInstallExecute.cpp index 82064871869..3ac5dbffd5a 100644 --- a/mozilla/xpinstall/src/nsInstallExecute.cpp +++ b/mozilla/xpinstall/src/nsInstallExecute.cpp @@ -37,6 +37,7 @@ #include "nsInstall.h" #include "nsIDOMInstallVersion.h" #include "nsProcess.h" +#include "nsReadableUtils.h" static NS_DEFINE_CID(kIProcessCID, NS_PROCESS_CID); @@ -93,7 +94,7 @@ PRInt32 nsInstallExecute::Complete() nsCOMPtr process = do_CreateInstance(kIProcessCID); - cArgs[0] = mArgs.ToNewCString(); + cArgs[0] = ToNewCString(mArgs); if(cArgs[0] == nsnull) return nsInstall::OUT_OF_MEMORY; @@ -148,7 +149,7 @@ char* nsInstallExecute::toString() if (mExecutableFile == nsnull) { - char *tempString = mJarLocation.ToNewCString(); + char *tempString = ToNewCString(mJarLocation); rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("Execute")); if (rsrcVal) diff --git a/mozilla/xpinstall/src/nsInstallFile.cpp b/mozilla/xpinstall/src/nsInstallFile.cpp index 10ba7055289..5925bd64cc8 100644 --- a/mozilla/xpinstall/src/nsInstallFile.cpp +++ b/mozilla/xpinstall/src/nsInstallFile.cpp @@ -34,6 +34,7 @@ #include "nsInstallLogComment.h" #include "nsInstallBitwise.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" /* Public Methods */ @@ -354,7 +355,7 @@ char* nsInstallFile::toString() interimStr.AssignWithConversion("(*dnu*) "); interimStr.AppendWithConversion(rsrcVal); - interimCStr = interimStr.ToNewCString(); + interimCStr = ToNewCString(interimStr); if(interimCStr) { diff --git a/mozilla/xpinstall/src/nsInstallFileOpItem.cpp b/mozilla/xpinstall/src/nsInstallFileOpItem.cpp index 5a08b625e9a..cb5a6afce40 100644 --- a/mozilla/xpinstall/src/nsInstallFileOpItem.cpp +++ b/mozilla/xpinstall/src/nsInstallFileOpItem.cpp @@ -41,6 +41,7 @@ #include "nsInstallFileOpItem.h" #include "ScheduledTasks.h" #include "nsProcess.h" +#include "nsReadableUtils.h" #ifdef _WINDOWS #include @@ -335,7 +336,7 @@ char* nsInstallFileOpItem::toString() mTarget->GetPath(&dstPath); - temp = mParams->ToNewCString(); + temp = ToNewCString(*mParams); if((temp != nsnull) && (*temp != '\0')) { rsrcVal = mInstall->GetResourcedString(NS_ConvertASCIItoUCS2("ExecuteWithArgs")); @@ -415,7 +416,7 @@ char* nsInstallFileOpItem::toString() result.AssignWithConversion(temp); result.AppendWithConversion("\\"); result.Append(*mDescription); - dstPath = result.ToNewCString(); + dstPath = ToNewCString(result); if(dstPath != nsnull) { PR_snprintf(resultCString, RESBUFSIZE, rsrcVal, dstPath ); @@ -973,7 +974,7 @@ nsInstallFileOpItem::NativeFileOpFileExecuteComplete() nsCOMPtr process = do_CreateInstance(kIProcessCID); cParams[0] = nsnull; - cParams[0] = mParams->ToNewCString(); + cParams[0] = ToNewCString(*mParams); if(cParams[0] == nsnull) return nsInstall::OUT_OF_MEMORY; @@ -1277,9 +1278,9 @@ nsInstallFileOpItem::NativeFileOpWindowsShortcutComplete() char *iconNativePathStr = nsnull; if(mDescription) - cDescription = mDescription->ToNewCString(); + cDescription = ToNewCString(*mDescription); if(mParams) - cParams = mParams->ToNewCString(); + cParams = ToNewCString(*mParams); if((cDescription == nsnull) || (cParams == nsnull)) ret = nsInstall::OUT_OF_MEMORY; diff --git a/mozilla/xpinstall/src/nsInstallLogComment.cpp b/mozilla/xpinstall/src/nsInstallLogComment.cpp index e321e30a994..bfcdafeff07 100644 --- a/mozilla/xpinstall/src/nsInstallLogComment.cpp +++ b/mozilla/xpinstall/src/nsInstallLogComment.cpp @@ -36,6 +36,7 @@ #include "nsInstall.h" #include "nsIDOMInstallVersion.h" +#include "nsReadableUtils.h" MOZ_DECL_CTOR_COUNTER(nsInstallLogComment) @@ -89,8 +90,8 @@ char* nsInstallLogComment::toString() if (buffer == nsnull || !mInstall) return nsnull; - char* cstrFileOpCommand = mFileOpCommand.ToNewCString(); - char* cstrComment = mComment.ToNewCString(); + char* cstrFileOpCommand = ToNewCString(mFileOpCommand); + char* cstrComment = ToNewCString(mComment); if((cstrFileOpCommand == nsnull) || (cstrComment == nsnull)) return nsnull; diff --git a/mozilla/xpinstall/src/nsInstallUninstall.cpp b/mozilla/xpinstall/src/nsInstallUninstall.cpp index d10a9afc4e3..43c35f39359 100644 --- a/mozilla/xpinstall/src/nsInstallUninstall.cpp +++ b/mozilla/xpinstall/src/nsInstallUninstall.cpp @@ -30,6 +30,7 @@ #include "prmem.h" #include "nsFileSpec.h" #include "ScheduledTasks.h" +#include "nsReadableUtils.h" extern "C" NS_EXPORT PRInt32 SU_Uninstall(char *regPackageName); REGERR su_UninstallProcessItem(char *component_path); @@ -104,7 +105,7 @@ char* nsInstallUninstall::toString() if (buffer == nsnull || !mInstall) return buffer; - char* temp = mUIName.ToNewCString(); + char* temp = ToNewCString(mUIName); if (temp) { diff --git a/mozilla/xpinstall/src/nsJSInstall.cpp b/mozilla/xpinstall/src/nsJSInstall.cpp index 338867c5510..ed67e7a16f6 100644 --- a/mozilla/xpinstall/src/nsJSInstall.cpp +++ b/mozilla/xpinstall/src/nsJSInstall.cpp @@ -42,6 +42,7 @@ #include "nsBuildID.h" #include "nsString.h" +#include "nsReadableUtils.h" #include "nsInstall.h" #include "nsInstallFile.h" #include "nsInstallTrigger.h" @@ -1595,7 +1596,7 @@ InstallTRACE(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) ConvertJSValToStr(b0, cx, argv[0]); char *tempStr; - tempStr = b0.ToNewCString(); + tempStr = ToNewCString(b0); printf("Install:\t%s\n", tempStr); Recycle(tempStr); diff --git a/mozilla/xpinstall/src/nsRegisterItem.cpp b/mozilla/xpinstall/src/nsRegisterItem.cpp index b894c2224bd..ce4087f7eb5 100644 --- a/mozilla/xpinstall/src/nsRegisterItem.cpp +++ b/mozilla/xpinstall/src/nsRegisterItem.cpp @@ -28,6 +28,7 @@ #include "nsNetUtil.h" #include "nsIFileChannel.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsInstallTrigger.h" #include "nsIChromeRegistry.h" #include "nsIDirectoryService.h" @@ -115,7 +116,7 @@ hack_nsIFile2URL(nsIFile* file, char * *aURL) // make sure we have a trailing slash escPath += "/"; } - *aURL = escPath.ToNewCString(); + *aURL = ToNewCString(escPath); if (*aURL == nsnull) { nsMemory::Free(ePath); return NS_ERROR_OUT_OF_MEMORY; diff --git a/mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp b/mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp index afdd88a8797..c4b91311dd1 100644 --- a/mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp +++ b/mozilla/xpinstall/src/nsSoftwareUpdateRun.cpp @@ -48,6 +48,7 @@ #include "nsIJSRuntimeService.h" #include "nsCOMPtr.h" #include "nsXPIDLString.h" +#include "nsReadableUtils.h" #include "nsILocalFile.h" #include "nsIChromeRegistry.h" #include "nsInstallTrigger.h" @@ -98,17 +99,14 @@ XPInstallErrorReporter(JSContext *cx, const char *message, JSErrorReport *report * Got an error object; prepare appropriate-width versions of * various arguments to it. */ - nsAutoString fileUni; - fileUni.AssignWithConversion(report->filename); - const PRUnichar *newFileUni = fileUni.ToNewUnicode(); - PRUint32 column = report->uctokenptr - report->uclinebuf; - rv = errorObject->Init(NS_REINTERPRET_CAST(const PRUnichar*, report->ucmessage), newFileUni, NS_REINTERPRET_CAST(const PRUnichar*, report->uclinebuf), + rv = errorObject->Init(NS_REINTERPRET_CAST(const PRUnichar*, report->ucmessage), + NS_ConvertASCIItoUCS2(report->filename).get(), + NS_REINTERPRET_CAST(const PRUnichar*, report->uclinebuf), report->lineno, column, report->flags, "XPInstall JavaScript"); - nsMemory::Free((void *)newFileUni); if (NS_SUCCEEDED(rv)) { rv = consoleService->LogMessage(errorObject); if (NS_SUCCEEDED(rv)) { diff --git a/mozilla/xpinstall/src/nsWinProfile.cpp b/mozilla/xpinstall/src/nsWinProfile.cpp index 08415304496..a0beb4bc11d 100644 --- a/mozilla/xpinstall/src/nsWinProfile.cpp +++ b/mozilla/xpinstall/src/nsWinProfile.cpp @@ -39,6 +39,7 @@ #include "nsWinProfileItem.h" #include "nspr.h" #include +#include "nsReadableUtils.h" /* Public Methods */ @@ -138,9 +139,9 @@ nsWinProfile::NativeGetString(nsString section, nsString key, nsString* aReturn /* make sure conversions worked */ if(section.First() != '\0' && key.First() != '\0' && mFilename->First() != '\0') { - sectionCString = section.ToNewCString(); - keyCString = key.ToNewCString(); - filenameCString = mFilename->ToNewCString(); + sectionCString = ToNewCString(section); + keyCString = ToNewCString(key); + filenameCString = ToNewCString(*mFilename); numChars = GetPrivateProfileString(sectionCString, keyCString, "", valbuf, STRBUFLEN, filenameCString); @@ -166,10 +167,10 @@ nsWinProfile::NativeWriteString( nsString section, nsString key, nsString value /* make sure conversions worked */ if(section.First() != '\0' && key.First() != '\0' && mFilename->First() != '\0') { - sectionCString = section.ToNewCString(); - keyCString = key.ToNewCString(); - valueCString = value.ToNewCString(); - filenameCString = mFilename->ToNewCString(); + sectionCString = ToNewCString(section); + keyCString = ToNewCString(key); + valueCString = ToNewCString(value); + filenameCString = ToNewCString(*mFilename); success = WritePrivateProfileString( sectionCString, keyCString, valueCString, filenameCString ); diff --git a/mozilla/xpinstall/src/nsWinReg.cpp b/mozilla/xpinstall/src/nsWinReg.cpp index 8ab0c2ec30a..b78cd8b2f7c 100644 --- a/mozilla/xpinstall/src/nsWinReg.cpp +++ b/mozilla/xpinstall/src/nsWinReg.cpp @@ -38,6 +38,7 @@ #include "nsWinReg.h" #include "nsWinRegItem.h" #include /* is this needed? */ +#include "nsReadableUtils.h" /* Public Methods */ @@ -411,7 +412,7 @@ nsWinReg::NativeKeyExists(const nsString& subkey) HKEY root, newkey; LONG result; PRInt32 keyExists = PR_FALSE; - char* subkeyCString = subkey.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); #ifdef WIN32 root = (HKEY)mRootKey; @@ -444,8 +445,8 @@ nsWinReg::NativeValueExists(const nsString& subkey, const nsString& valname) PRInt32 valueExists = PR_FALSE; DWORD length = _MAXKEYVALUE_; unsigned char valbuf[_MAXKEYVALUE_]; - char* subkeyCString = subkey.ToNewCString(); - char* valnameCString = valname.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* valnameCString = ToNewCString(valname); #ifdef WIN32 root = (HKEY) mRootKey; @@ -521,7 +522,7 @@ nsWinReg::NativeIsKeyWritable(const nsString& subkey) if(rv) { rv = PR_FALSE; - subkeyCString = subkeyParent.ToNewCString(); + subkeyCString = ToNewCString(subkeyParent); if(!subkeyCString) result = nsInstall::OUT_OF_MEMORY; else @@ -554,8 +555,8 @@ nsWinReg::NativeCreateKey(const nsString& subkey, const nsString& classname) HKEY root, newkey; LONG result; ULONG disposition; - char* subkeyCString = subkey.ToNewCString(); - char* classnameCString = classname.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* classnameCString = ToNewCString(classname); #ifdef WIN32 root = (HKEY)mRootKey; @@ -578,7 +579,7 @@ nsWinReg::NativeDeleteKey(const nsString& subkey) { HKEY root; LONG result; - char* subkeyCString = subkey.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); #ifdef WIN32 root = (HKEY) mRootKey; @@ -596,8 +597,8 @@ nsWinReg::NativeDeleteValue(const nsString& subkey, const nsString& valname) #if defined (WIN32) || defined (XP_OS2) HKEY root, newkey; LONG result; - char* subkeyCString = subkey.ToNewCString(); - char* valnameCString = valname.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* valnameCString = ToNewCString(valname); root = (HKEY) mRootKey; result = RegOpenKeyEx( root, subkeyCString, 0, KEY_WRITE, &newkey); @@ -625,9 +626,9 @@ nsWinReg::NativeSetValueString(const nsString& subkey, const nsString& valname, LONG result; DWORD length; - char* subkeyCString = subkey.ToNewCString(); - char* valnameCString = valname.ToNewCString(); - char* valueCString = value.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* valnameCString = ToNewCString(valname); + char* valueCString = ToNewCString(value); length = value.Length(); @@ -658,8 +659,8 @@ nsWinReg::NativeGetValueString(const nsString& subkey, const nsString& valname, LONG result; DWORD type = REG_SZ; DWORD length = _MAXKEYVALUE_; - char* subkeyCString = subkey.ToNewCString(); - char* valnameCString = valname.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* valnameCString = ToNewCString(valname); root = (HKEY) mRootKey; result = RegOpenKeyEx( root, subkeyCString, 0, KEY_READ, &newkey ); @@ -687,8 +688,8 @@ nsWinReg::NativeSetValueNumber(const nsString& subkey, const nsString& valname, HKEY newkey; LONG result; - char* subkeyCString = subkey.ToNewCString(); - char* valnameCString = valname.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* valnameCString = ToNewCString(valname); root = (HKEY) mRootKey; result = RegOpenKeyEx( root, subkeyCString, 0, KEY_WRITE, &newkey); @@ -715,8 +716,8 @@ nsWinReg::NativeGetValueNumber(const nsString& subkey, const nsString& valname, LONG result; DWORD type = REG_DWORD; DWORD length = _MAXKEYVALUE_; - char* subkeyCString = subkey.ToNewCString(); - char* valnameCString = valname.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* valnameCString = ToNewCString(valname); valbuflen = sizeof(PRInt32); root = (HKEY) mRootKey; @@ -748,8 +749,8 @@ nsWinReg::NativeSetValue(const nsString& subkey, const nsString& valname, nsWinR DWORD length; DWORD type; unsigned char* data; - char* subkeyCString = subkey.ToNewCString(); - char* valnameCString = valname.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* valnameCString = ToNewCString(valname); root = (HKEY) mRootKey; @@ -786,8 +787,8 @@ nsWinReg::NativeGetValue(const nsString& subkey, const nsString& valname) DWORD type; nsString* data; nsWinRegValue* value = nsnull; - char* subkeyCString = subkey.ToNewCString(); - char* valnameCString = valname.ToNewCString(); + char* subkeyCString = ToNewCString(subkey); + char* valnameCString = ToNewCString(valname); root = (HKEY) mRootKey; result = RegOpenKeyEx( root, subkeyCString, 0, KEY_READ, &newkey ); diff --git a/mozilla/xpinstall/src/nsXPInstallManager.cpp b/mozilla/xpinstall/src/nsXPInstallManager.cpp index b0275427883..72a0fc90f41 100644 --- a/mozilla/xpinstall/src/nsXPInstallManager.cpp +++ b/mozilla/xpinstall/src/nsXPInstallManager.cpp @@ -57,6 +57,7 @@ #include "nsDirectoryServiceDefs.h" #include "nsAppDirectoryServiceDefs.h" +#include "nsReadableUtils.h" #include "nsProxiedService.h" #include "nsIPromptService.h" #include "nsIScriptGlobalObject.h" @@ -580,14 +581,14 @@ void nsXPInstallManager::LoadDialogWithNames(nsIDialogParamBlock* ioParamBlock) //Check to see if this trigger item has a pretty name if(!(moduleName = triggerItem->mName).IsEmpty()) { - ioParamBlock->SetString(paramIndex, moduleName.ToNewUnicode()); + ioParamBlock->SetString(paramIndex, moduleName.get()); paramIndex++; URL = triggerItem->mURL; offset = URL.RFind("/"); if (offset != -1) { URL.Cut(offset + 1, URL.Length() - 1); - ioParamBlock->SetString(paramIndex, URL.ToNewUnicode()); + ioParamBlock->SetString(paramIndex, URL.get()); } paramIndex++; } @@ -601,10 +602,10 @@ void nsXPInstallManager::LoadDialogWithNames(nsIDialogParamBlock* ioParamBlock) if (offset != -1) { moduleName.Cut(0, offset + 1); - ioParamBlock->SetString(paramIndex, moduleName.ToNewUnicode()); + ioParamBlock->SetString(paramIndex, moduleName.get()); paramIndex++; URL.Cut(offset + 1, URL.Length() - 1); - ioParamBlock->SetString(paramIndex, URL.ToNewUnicode()); + ioParamBlock->SetString(paramIndex, URL.get()); } paramIndex++; }