From dd2b4f8ffbb2ede93d3798f264278c85fa1dee93 Mon Sep 17 00:00:00 2001 From: "scc%netscape.com" Date: Mon, 3 Apr 2000 08:09:23 +0000 Subject: [PATCH] making string conversions explict git-svn-id: svn://10.0.0.236/trunk@65023 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/nsLoggingSink.cpp | 10 ++-- mozilla/htmlparser/src/nsParser.cpp | 51 ++++++++-------- mozilla/htmlparser/src/nsParserModule.cpp | 2 +- mozilla/htmlparser/src/nsParserNode.cpp | 2 +- mozilla/htmlparser/src/nsScanner.cpp | 21 +++---- mozilla/htmlparser/src/nsTagHandler.h | 2 +- mozilla/htmlparser/src/nsToken.cpp | 5 +- mozilla/htmlparser/src/nsViewSourceHTML.cpp | 47 +++++++++------ mozilla/htmlparser/src/nsWellFormedDTD.cpp | 10 ++-- mozilla/htmlparser/src/nsXIFDTD.cpp | 58 +++++++++---------- mozilla/htmlparser/src/nsXMLTokenizer.cpp | 2 +- .../parser/htmlparser/src/nsLoggingSink.cpp | 10 ++-- mozilla/parser/htmlparser/src/nsParser.cpp | 51 ++++++++-------- .../parser/htmlparser/src/nsParserModule.cpp | 2 +- .../parser/htmlparser/src/nsParserNode.cpp | 2 +- mozilla/parser/htmlparser/src/nsScanner.cpp | 21 +++---- mozilla/parser/htmlparser/src/nsTagHandler.h | 2 +- mozilla/parser/htmlparser/src/nsToken.cpp | 5 +- .../htmlparser/src/nsViewSourceHTML.cpp | 47 +++++++++------ .../parser/htmlparser/src/nsWellFormedDTD.cpp | 10 ++-- mozilla/parser/htmlparser/src/nsXIFDTD.cpp | 58 +++++++++---------- .../parser/htmlparser/src/nsXMLTokenizer.cpp | 2 +- 22 files changed, 216 insertions(+), 204 deletions(-) diff --git a/mozilla/htmlparser/src/nsLoggingSink.cpp b/mozilla/htmlparser/src/nsLoggingSink.cpp index a8d5ca86c9b..2803f6474ef 100644 --- a/mozilla/htmlparser/src/nsLoggingSink.cpp +++ b/mozilla/htmlparser/src/nsLoggingSink.cpp @@ -510,15 +510,15 @@ nsLoggingSink::QuoteText(const nsString& aValue, nsString& aResult) while (cp < end) { PRUnichar ch = *cp++; if (ch == '"') { - aResult.Append("""); + aResult.AppendWithConversion("""); } else if (ch == '&') { - aResult.Append("&"); + aResult.AppendWithConversion("&"); } else if ((ch < 32) || (ch >= 127)) { - aResult.Append("&#"); - aResult.Append(PRInt32(ch), 10); - aResult.Append(';'); + aResult.AppendWithConversion("&#"); + aResult.AppendWithConversion(PRInt32(ch), 10); + aResult.AppendWithConversion(';'); } else { aResult.Append(ch); diff --git a/mozilla/htmlparser/src/nsParser.cpp b/mozilla/htmlparser/src/nsParser.cpp index 1f987bba792..e68f2867e98 100644 --- a/mozilla/htmlparser/src/nsParser.cpp +++ b/mozilla/htmlparser/src/nsParser.cpp @@ -194,8 +194,9 @@ void nsParser::FreeSharedObjects(void) { * @param * @return */ -nsParser::nsParser(nsITokenObserver* anObserver) : mUnusedInput("") , mCharset("ISO-8859-1") { +nsParser::nsParser(nsITokenObserver* anObserver) { NS_INIT_REFCNT(); + mCharset.AssignWithConversion("ISO-8859-1"); mParserFilter = 0; mObserver = 0; mProgressEventSink = nsnull; @@ -311,7 +312,7 @@ nsIParserFilter * nsParser::SetParserFilter(nsIParserFilter * aFilter) * @return ptr to previously set contentsink (usually null) */ void nsParser::SetCommand(const char* aCommand){ - nsAutoString theCommand(aCommand); + nsCAutoString theCommand(aCommand); if(theCommand.Equals(kViewSourceCommand)) mCommand=eViewSource; else mCommand=eViewNormal; @@ -872,7 +873,7 @@ nsresult nsParser::Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aVerif if (rv != NS_OK) { return rv; } - nsAutoString theName(spec); + nsAutoString theName; theName.AssignWithConversion(spec); nsCRT::free(spec); nsScanner* theScanner=new nsScanner(theName,PR_FALSE,mCharset,mCharsetSource); @@ -903,7 +904,7 @@ nsresult nsParser::Parse(nsIInputStream& aStream,const nsString& aMimeType,PRBoo nsresult result=NS_ERROR_OUT_OF_MEMORY; //ok, time to create our tokenizer and begin the process - nsAutoString theUnknownFilename("unknown"); + nsAutoString theUnknownFilename; theUnknownFilename.AssignWithConversion("unknown"); nsInputStream input(&aStream); @@ -1035,11 +1036,11 @@ PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aSta PRUint32 theCount=aStack.GetSize(); PRUint32 theIndex=0; while(theIndex++"); + theContext.AppendWithConversion(">"); } - theContext.Append(""); //XXXHack! I'll make this better later. + theContext.AppendWithConversion(""); //XXXHack! I'll make this better later. nsAutoString theBuffer(theContext); theBuffer.Append(aSourceBuffer); @@ -1047,7 +1048,7 @@ PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aSta if(theBuffer.Length()){ //now it's time to try to build the model from this fragment - nsString theOutput(""); + nsString theOutput; nsIHTMLContentSink* theSink=0; nsresult theResult=NS_New_HTML_ContentSinkStream(&theSink,&theOutput,0); SetContentSink(theSink); @@ -1078,11 +1079,11 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag PRUint32 theCount=aStack.GetSize(); PRUint32 theIndex=0; while(theIndex++"); + theContext.AppendWithConversion(">"); } - theContext.Append(""); //XXXHack! I'll make this better later. + theContext.AppendWithConversion(""); //XXXHack! I'll make this better later. nsAutoString theBuffer(theContext); #if 0 @@ -1386,7 +1387,7 @@ nsresult nsParser::OnStartRequest(nsIChannel* channel, nsISupports* aContext) rv = channel->GetContentType(&contentType); if (NS_SUCCEEDED(rv)) { - mParserContext->SetMimeType(contentType); + mParserContext->SetMimeType( NS_ConvertToString(contentType) ); nsCRT::free(contentType); } else @@ -1409,7 +1410,7 @@ nsresult nsParser::OnStartRequest(nsIChannel* channel, nsISupports* aContext) static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsString& oCharset, nsCharsetSource& oCharsetSource) { oCharsetSource= kCharsetFromAutoDetection; - oCharset = ""; + oCharset.SetLength(0); // see http://www.w3.org/TR/1998/REC-xml-19980210#sec-oCharseting // for details switch(aBytes[0]) @@ -1419,19 +1420,19 @@ static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS // 00 00 if((0x00==aBytes[2]) && (0x3C==aBytes[3])) { // 00 00 00 3C UCS-4, big-endian machine (1234 order) - oCharset = UCS4_BE; + oCharset.AssignWithConversion(UCS4_BE); } else if((0x3C==aBytes[2]) && (0x00==aBytes[3])) { // 00 00 3C 00 UCS-4, unusual octet order (2143) - oCharset = UCS4_2143; + oCharset.AssignWithConversion(UCS4_2143); } } else if(0x3C==aBytes[1]) { // 00 3C if((0x00==aBytes[2]) && (0x00==aBytes[3])) { // 00 3C 00 00 UCS-4, unusual octet order (3412) - oCharset = UCS4_3412; + oCharset.AssignWithConversion(UCS4_3412); } else if((0x3C==aBytes[2]) && (0x3F==aBytes[3])) { // 00 3C 00 3F UTF-16, big-endian, no Byte Order Mark - oCharset = UCS2_BE; // should change to UTF-16BE + oCharset.AssignWithConversion(UCS2_BE); // should change to UTF-16BE } } break; @@ -1440,17 +1441,17 @@ static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS // 3C 00 if((0x00==aBytes[2]) && (0x00==aBytes[3])) { // 3C 00 00 00 UCS-4, little-endian machine (4321 order) - oCharset = UCS4_LE; + oCharset.AssignWithConversion(UCS4_LE); } else if((0x3F==aBytes[2]) && (0x00==aBytes[3])) { // 3C 00 3F 00 UTF-16, little-endian, no Byte Order Mark - oCharset = UCS2_LE; // should change to UTF-16LE + oCharset.AssignWithConversion(UCS2_LE); // should change to UTF-16LE } } else if((0x3C==aBytes[0]) && (0x3F==aBytes[1]) && (0x78==aBytes[2]) && (0x6D==aBytes[3]) && (0 == PL_strncmp(" XMLENCODING_PEEKBYTES)? XMLENCODING_PEEKBYTES: aLen)); @@ -1481,7 +1482,7 @@ static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS if(0xFF==aBytes[1]) { // FE FF // UTF-16, big-endian - oCharset = UCS2_BE; // should change to UTF-16BE + oCharset.AssignWithConversion(UCS2_BE); // should change to UTF-16BE oCharsetSource= kCharsetFromByteOrderMark; } break; @@ -1489,7 +1490,7 @@ static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS if(0xFE==aBytes[1]) { // FF FE // UTF-16, little-endian - oCharset = UCS2_LE; // should change to UTF-16LE + oCharset.AssignWithConversion(UCS2_LE); // should change to UTF-16LE oCharsetSource= kCharsetFromByteOrderMark; } break; @@ -1565,7 +1566,7 @@ theContext->mTransferBufferSize; if(NS_SUCCEEDED(result) && (theNumRead>0)) { if(needCheckFirst4Bytes && (theNumRead >= 4)) { nsCharsetSource guessSource; - nsAutoString guess(""); + nsAutoString guess; needCheckFirst4Bytes = PR_FALSE; if(detectByteOrderMark((const unsigned char*)theContext->mTransferBuffer, @@ -1639,7 +1640,7 @@ nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext, //If you're here, then OnDataAvailable() never got called. //Prior to necko, we never dealt with this case, but the problem may have existed. //What we'll do (for now at least) is construct a blank HTML document. - nsAutoString temp(""); + nsAutoString temp; temp.AssignWithConversion(""); mParserContext->mScanner->Append(temp); result=ResumeParse(PR_TRUE,PR_TRUE); } diff --git a/mozilla/htmlparser/src/nsParserModule.cpp b/mozilla/htmlparser/src/nsParserModule.cpp index 73e4f21a4de..5812d390f8d 100644 --- a/mozilla/htmlparser/src/nsParserModule.cpp +++ b/mozilla/htmlparser/src/nsParserModule.cpp @@ -78,7 +78,7 @@ nsParserService::HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const NS_IMETHODIMP nsParserService::HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const { - aTag = nsHTMLTags::GetStringValue((nsHTMLTag)aId); + aTag.AssignWithConversion( nsHTMLTags::GetStringValue((nsHTMLTag)aId) ); return NS_OK; } diff --git a/mozilla/htmlparser/src/nsParserNode.cpp b/mozilla/htmlparser/src/nsParserNode.cpp index b92349e5a3f..747bcf36809 100644 --- a/mozilla/htmlparser/src/nsParserNode.cpp +++ b/mozilla/htmlparser/src/nsParserNode.cpp @@ -35,7 +35,7 @@ static NS_DEFINE_IID(kIParserNodeIID, NS_IPARSER_NODE_IID); nsString& GetEmptyString() { static nsString* gEmptyStr=0; if(!gEmptyStr) - gEmptyStr=new nsString(""); + gEmptyStr=new nsString; return *gEmptyStr; } diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp index 34ac6a43252..04b48fc9d54 100644 --- a/mozilla/htmlparser/src/nsScanner.cpp +++ b/mozilla/htmlparser/src/nsScanner.cpp @@ -53,7 +53,7 @@ MOZ_DECL_CTOR_COUNTER(nsScanner); * @return */ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharsetSource aSource) : - mBuffer(anHTMLString), mFilename(""), mUnicodeXferBuf("") + mBuffer(anHTMLString) { MOZ_COUNT_CTOR(nsScanner); @@ -64,7 +64,6 @@ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharset mMarkPos=0; mInputStream=0; mUnicodeDecoder = 0; - mCharset = ""; mCharsetSource = kCharsetUninitialized; SetDocumentCharset(aCharset, aSource); mNewlinesSkipped=0; @@ -80,7 +79,7 @@ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharset * @return */ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& aCharset, nsCharsetSource aSource) : - mBuffer(""), mFilename(aFilename), mUnicodeXferBuf("") + mFilename(aFilename) { MOZ_COUNT_CTOR(nsScanner); @@ -94,7 +93,6 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a mInputStream = new nsInputFileStream(nsFileSpec(aFilename)); } //if mUnicodeDecoder = 0; - mCharset = ""; mCharsetSource = kCharsetUninitialized; SetDocumentCharset(aCharset, aSource); mNewlinesSkipped=0; @@ -110,7 +108,7 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a * @return */ nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& aCharset, nsCharsetSource aSource) : - mBuffer(""), mFilename(aFilename) , mUnicodeXferBuf("") + mFilename(aFilename) { MOZ_COUNT_CTOR(nsScanner); @@ -121,7 +119,6 @@ nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& mOwnsStream=PR_FALSE; mInputStream=&aStream; mUnicodeDecoder = 0; - mCharset = ""; mCharsetSource = kCharsetUninitialized; SetDocumentCharset(aCharset, aSource); mNewlinesSkipped=0; @@ -152,7 +149,7 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc if(NS_FAILED(res) && (kCharsetUninitialized == mCharsetSource) ) { // failed - unknown alias , fallback to ISO-8859-1 - charsetName = "ISO-8859-1"; + charsetName.AssignWithConversion("ISO-8859-1"); } mCharset = charsetName; mCharsetSource = aSource; @@ -241,10 +238,8 @@ PRUint32 nsScanner::Mark(PRInt32 anIndex){ */ PRBool nsScanner::Insert(const nsString& aBuffer) { - PRInt32 theLen=aBuffer.Length(); - - mBuffer.Insert(aBuffer,mOffset,theLen); - mTotalRead+=theLen; + mBuffer.Insert(aBuffer,mOffset); + mTotalRead+=aBuffer.Length(); return PR_TRUE; } @@ -317,7 +312,7 @@ PRBool nsScanner::Append(const char* aBuffer, PRUint32 aLen){ // delete[] unichars; } else { - mBuffer.Append(aBuffer,aLen); + mBuffer.AppendWithConversion(aBuffer,aLen); mTotalRead+=aLen; } @@ -394,7 +389,7 @@ nsresult nsScanner::FillBuffer(void) { } mOffset=mBuffer.Length(); if((0OpenContainer(theNode); @@ -664,7 +673,7 @@ nsresult WriteText(const nsString& aTextString,nsIContentSink& aSink,PRBool aPre } if(0mKey:0; eHTMLTags theTag=(eHTMLTags)theToken->GetTypeID(); - result=theService->Notify(theTag,theContext.mTokenNode,(PRUint32)theDocID,kViewSourceCommand,mParser); + result=theService->Notify(theTag,theContext.mTokenNode,(PRUint32)theDocID, NS_ConvertToString(kViewSourceCommand), mParser); } } theContext.mTokenNode.Init(0,0,gTokenRecycler); //now recycle. @@ -906,8 +915,8 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { case eToken_cdatasection: { nsString& theStr=aToken->GetStringValueXXX(); - theStr.Insert(""); + theStr.InsertWithConversion(""); result=WriteTag(mCDATATag,aToken,0,PR_TRUE); } break; @@ -933,10 +942,10 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { { nsAutoString theStr; nsString& theEntity=aToken->GetStringValueXXX(); - if(!theEntity.Equals("XI",IGNORE_CASE)) { + if(!theEntity.EqualsWithConversion("XI",IGNORE_CASE)) { PRUnichar theChar=theEntity.CharAt(0); if((nsCRT::IsAsciiDigit(theChar)) || ('X'==theChar) || ('x'==theChar)){ - theStr.Append("#"); + theStr.AppendWithConversion("#"); } theStr.Append(theEntity); } diff --git a/mozilla/htmlparser/src/nsWellFormedDTD.cpp b/mozilla/htmlparser/src/nsWellFormedDTD.cpp index 59feff06562..88961eaf146 100644 --- a/mozilla/htmlparser/src/nsWellFormedDTD.cpp +++ b/mozilla/htmlparser/src/nsWellFormedDTD.cpp @@ -122,7 +122,7 @@ NS_IMPL_RELEASE(CWellFormedDTD) * @param * @return */ -CWellFormedDTD::CWellFormedDTD() : nsIDTD(), mFilename("") { +CWellFormedDTD::CWellFormedDTD() : nsIDTD() { NS_INIT_REFCNT(); mParser=0; mSink=0; @@ -177,15 +177,15 @@ eAutoDetectResult CWellFormedDTD::CanParse(CParserContext& aParserContext,nsStri eAutoDetectResult result=eUnknownDetect; if(eViewSource!=aParserContext.mParserCommand) { - if(aParserContext.mMimeType.Equals(kXMLTextContentType) || - aParserContext.mMimeType.Equals(kRDFTextContentType) || - aParserContext.mMimeType.Equals(kXULTextContentType)) { + if(aParserContext.mMimeType.EqualsWithConversion(kXMLTextContentType) || + aParserContext.mMimeType.EqualsWithConversion(kRDFTextContentType) || + aParserContext.mMimeType.EqualsWithConversion(kXULTextContentType)) { result=ePrimaryDetect; } else { if(-1GetStringValueXXX(); - if (!temp.Equals("")) + if (!temp.EqualsWithConversion("")) { result= AddLeaf(node); } @@ -872,9 +872,9 @@ PRBool nsXIFDTD::GetAttributePair(nsIParserNode& aNode, nsString& aKey, nsString key.StripChars(quote); value.StripChars(quote); - if (key.Equals("name")) + if (key.EqualsWithConversion("name")) aKey = value; - if (key.Equals("value")) + if (key.EqualsWithConversion("value")) { aValue = value; hasValue = PR_TRUE; @@ -901,12 +901,12 @@ eHTMLTags nsXIFDTD::GetStartTag(const nsIParserNode& aNode, nsString& aName) { case eXIFTag_container: case eXIFTag_leaf: - if (GetAttribute(aNode,nsString("isa"),aName)) + if (GetAttribute(aNode,NS_ConvertToString("isa"),aName)) tag = tag = nsHTMLTags::LookupTag(aName); break; case eXIFTag_css_stylesheet: - aName = "style"; + aName.AssignWithConversion("style"); tag = nsHTMLTags::LookupTag(aName); break; @@ -1299,7 +1299,7 @@ nsresult nsXIFDTD::CollectContentComment(CToken* aToken, nsCParserNode& aNode) { PRBool done=PR_FALSE; PRBool inContent=PR_FALSE; nsString& comment=aToken->GetStringValueXXX(); - comment=""); + else if(fragment.EqualsWithConversion("comment")) { + comment.AppendWithConversion("-->"); result=(mSink)? mSink->AddComment(aNode):NS_OK; done=PR_TRUE; } @@ -1414,7 +1414,7 @@ void nsXIFDTD::ProcessEncodeTag(const nsIParserNode& aNode) nsString value; PRInt32 error; - if (GetAttribute(aNode,nsString("selection"),value)) + if (GetAttribute(aNode,NS_ConvertToString("selection"),value)) { PRInt32 temp = value.ToInteger(&error); if (temp == 1) @@ -1431,7 +1431,7 @@ void nsXIFDTD::ProcessEntityTag(const nsIParserNode& aNode) { nsAutoString value; - if (GetAttribute(aNode,nsString("value"),value)) { + if (GetAttribute(aNode,NS_ConvertToString("value"),value)) { value+=';'; CEntityToken* entity = new CEntityToken(value); nsCParserNode node((CToken*)entity); @@ -1448,7 +1448,7 @@ void nsXIFDTD::BeginCSSStyleSheet(const nsIParserNode& aNode) mBuffer.Truncate(0); mMaxCSSSelectorWidth = 10; - if (GetAttribute(aNode,nsString("max_css_selector_width"),value)) + if (GetAttribute(aNode,NS_ConvertToString("max_css_selector_width"),value)) { PRInt32 temp = value.ToInteger(&error); if (error == NS_OK) @@ -1470,9 +1470,9 @@ void nsXIFDTD::EndCSSStyleSheet(const nsIParserNode& aNode) CStartToken startToken(tagName); nsCParserNode startNode((CToken*)&startToken); - mBuffer.Append(""); + mBuffer.AppendWithConversion(">"); startNode.SetSkippedContent(mBuffer); mSink->AddLeaf(startNode); @@ -1494,7 +1494,7 @@ void nsXIFDTD::AddCSSSelector(const nsIParserNode& aNode) { nsString value; - if (GetAttribute(aNode, nsString("selectors"), value)) + if (GetAttribute(aNode, NS_ConvertToString("selectors"), value)) { if (mLowerCaseAttributes == PR_TRUE) value.ToLowerCase(); @@ -1517,16 +1517,16 @@ void nsXIFDTD::BeginCSSDeclarationList(const nsIParserNode& aNode) count = 0; for (PRInt32 i = 0; i < count; i++) - mBuffer.Append(" "); + mBuffer.AppendWithConversion(" "); - mBuffer.Append(" {"); + mBuffer.AppendWithConversion(" {"); mCSSDeclarationCount = 0; } void nsXIFDTD::EndCSSDeclarationList(const nsIParserNode& aNode) { - mBuffer.Append("}\n"); + mBuffer.AppendWithConversion("}\n"); } @@ -1536,14 +1536,14 @@ void nsXIFDTD::AddCSSDeclaration(const nsIParserNode& aNode) nsString value; - if (PR_TRUE == GetAttribute(aNode, nsString("property"), property)) - if (PR_TRUE == GetAttribute(aNode, nsString("value"), value)) + if (PR_TRUE == GetAttribute(aNode, NS_ConvertToString("property"), property)) + if (PR_TRUE == GetAttribute(aNode, NS_ConvertToString("value"), value)) { if (mCSSDeclarationCount != 0) - mBuffer.Append(";"); - mBuffer.Append(" "); + mBuffer.AppendWithConversion(";"); + mBuffer.AppendWithConversion(" "); mBuffer.Append(property); - mBuffer.Append(": "); + mBuffer.AppendWithConversion(": "); mBuffer.Append(value); mCSSDeclarationCount++; } diff --git a/mozilla/htmlparser/src/nsXMLTokenizer.cpp b/mozilla/htmlparser/src/nsXMLTokenizer.cpp index 12368e2ebb9..7cb88064a60 100644 --- a/mozilla/htmlparser/src/nsXMLTokenizer.cpp +++ b/mozilla/htmlparser/src/nsXMLTokenizer.cpp @@ -237,7 +237,7 @@ nsresult nsXMLTokenizer::ConsumeSpecialMarkup(PRUnichar aChar,CToken*& aToken,ns PRBool isComment=PR_TRUE; nsAutoString theEmpty; if(theChar==kLeftSquareBracket) { - nsAutoString CDATAString("[CDATA["); + nsAutoString CDATAString; CDATAString.AssignWithConversion("[CDATA["); PRBool isCDATA = PR_FALSE; result = ConsumeConditional(aScanner, CDATAString, isCDATA); if (NS_OK == result) { diff --git a/mozilla/parser/htmlparser/src/nsLoggingSink.cpp b/mozilla/parser/htmlparser/src/nsLoggingSink.cpp index a8d5ca86c9b..2803f6474ef 100644 --- a/mozilla/parser/htmlparser/src/nsLoggingSink.cpp +++ b/mozilla/parser/htmlparser/src/nsLoggingSink.cpp @@ -510,15 +510,15 @@ nsLoggingSink::QuoteText(const nsString& aValue, nsString& aResult) while (cp < end) { PRUnichar ch = *cp++; if (ch == '"') { - aResult.Append("""); + aResult.AppendWithConversion("""); } else if (ch == '&') { - aResult.Append("&"); + aResult.AppendWithConversion("&"); } else if ((ch < 32) || (ch >= 127)) { - aResult.Append("&#"); - aResult.Append(PRInt32(ch), 10); - aResult.Append(';'); + aResult.AppendWithConversion("&#"); + aResult.AppendWithConversion(PRInt32(ch), 10); + aResult.AppendWithConversion(';'); } else { aResult.Append(ch); diff --git a/mozilla/parser/htmlparser/src/nsParser.cpp b/mozilla/parser/htmlparser/src/nsParser.cpp index 1f987bba792..e68f2867e98 100644 --- a/mozilla/parser/htmlparser/src/nsParser.cpp +++ b/mozilla/parser/htmlparser/src/nsParser.cpp @@ -194,8 +194,9 @@ void nsParser::FreeSharedObjects(void) { * @param * @return */ -nsParser::nsParser(nsITokenObserver* anObserver) : mUnusedInput("") , mCharset("ISO-8859-1") { +nsParser::nsParser(nsITokenObserver* anObserver) { NS_INIT_REFCNT(); + mCharset.AssignWithConversion("ISO-8859-1"); mParserFilter = 0; mObserver = 0; mProgressEventSink = nsnull; @@ -311,7 +312,7 @@ nsIParserFilter * nsParser::SetParserFilter(nsIParserFilter * aFilter) * @return ptr to previously set contentsink (usually null) */ void nsParser::SetCommand(const char* aCommand){ - nsAutoString theCommand(aCommand); + nsCAutoString theCommand(aCommand); if(theCommand.Equals(kViewSourceCommand)) mCommand=eViewSource; else mCommand=eViewNormal; @@ -872,7 +873,7 @@ nsresult nsParser::Parse(nsIURI* aURL,nsIStreamObserver* aListener,PRBool aVerif if (rv != NS_OK) { return rv; } - nsAutoString theName(spec); + nsAutoString theName; theName.AssignWithConversion(spec); nsCRT::free(spec); nsScanner* theScanner=new nsScanner(theName,PR_FALSE,mCharset,mCharsetSource); @@ -903,7 +904,7 @@ nsresult nsParser::Parse(nsIInputStream& aStream,const nsString& aMimeType,PRBoo nsresult result=NS_ERROR_OUT_OF_MEMORY; //ok, time to create our tokenizer and begin the process - nsAutoString theUnknownFilename("unknown"); + nsAutoString theUnknownFilename; theUnknownFilename.AssignWithConversion("unknown"); nsInputStream input(&aStream); @@ -1035,11 +1036,11 @@ PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aSta PRUint32 theCount=aStack.GetSize(); PRUint32 theIndex=0; while(theIndex++"); + theContext.AppendWithConversion(">"); } - theContext.Append(""); //XXXHack! I'll make this better later. + theContext.AppendWithConversion(""); //XXXHack! I'll make this better later. nsAutoString theBuffer(theContext); theBuffer.Append(aSourceBuffer); @@ -1047,7 +1048,7 @@ PRBool nsParser::IsValidFragment(const nsString& aSourceBuffer,nsITagStack& aSta if(theBuffer.Length()){ //now it's time to try to build the model from this fragment - nsString theOutput(""); + nsString theOutput; nsIHTMLContentSink* theSink=0; nsresult theResult=NS_New_HTML_ContentSinkStream(&theSink,&theOutput,0); SetContentSink(theSink); @@ -1078,11 +1079,11 @@ nsresult nsParser::ParseFragment(const nsString& aSourceBuffer,void* aKey,nsITag PRUint32 theCount=aStack.GetSize(); PRUint32 theIndex=0; while(theIndex++"); + theContext.AppendWithConversion(">"); } - theContext.Append(""); //XXXHack! I'll make this better later. + theContext.AppendWithConversion(""); //XXXHack! I'll make this better later. nsAutoString theBuffer(theContext); #if 0 @@ -1386,7 +1387,7 @@ nsresult nsParser::OnStartRequest(nsIChannel* channel, nsISupports* aContext) rv = channel->GetContentType(&contentType); if (NS_SUCCEEDED(rv)) { - mParserContext->SetMimeType(contentType); + mParserContext->SetMimeType( NS_ConvertToString(contentType) ); nsCRT::free(contentType); } else @@ -1409,7 +1410,7 @@ nsresult nsParser::OnStartRequest(nsIChannel* channel, nsISupports* aContext) static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsString& oCharset, nsCharsetSource& oCharsetSource) { oCharsetSource= kCharsetFromAutoDetection; - oCharset = ""; + oCharset.SetLength(0); // see http://www.w3.org/TR/1998/REC-xml-19980210#sec-oCharseting // for details switch(aBytes[0]) @@ -1419,19 +1420,19 @@ static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS // 00 00 if((0x00==aBytes[2]) && (0x3C==aBytes[3])) { // 00 00 00 3C UCS-4, big-endian machine (1234 order) - oCharset = UCS4_BE; + oCharset.AssignWithConversion(UCS4_BE); } else if((0x3C==aBytes[2]) && (0x00==aBytes[3])) { // 00 00 3C 00 UCS-4, unusual octet order (2143) - oCharset = UCS4_2143; + oCharset.AssignWithConversion(UCS4_2143); } } else if(0x3C==aBytes[1]) { // 00 3C if((0x00==aBytes[2]) && (0x00==aBytes[3])) { // 00 3C 00 00 UCS-4, unusual octet order (3412) - oCharset = UCS4_3412; + oCharset.AssignWithConversion(UCS4_3412); } else if((0x3C==aBytes[2]) && (0x3F==aBytes[3])) { // 00 3C 00 3F UTF-16, big-endian, no Byte Order Mark - oCharset = UCS2_BE; // should change to UTF-16BE + oCharset.AssignWithConversion(UCS2_BE); // should change to UTF-16BE } } break; @@ -1440,17 +1441,17 @@ static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS // 3C 00 if((0x00==aBytes[2]) && (0x00==aBytes[3])) { // 3C 00 00 00 UCS-4, little-endian machine (4321 order) - oCharset = UCS4_LE; + oCharset.AssignWithConversion(UCS4_LE); } else if((0x3F==aBytes[2]) && (0x00==aBytes[3])) { // 3C 00 3F 00 UTF-16, little-endian, no Byte Order Mark - oCharset = UCS2_LE; // should change to UTF-16LE + oCharset.AssignWithConversion(UCS2_LE); // should change to UTF-16LE } } else if((0x3C==aBytes[0]) && (0x3F==aBytes[1]) && (0x78==aBytes[2]) && (0x6D==aBytes[3]) && (0 == PL_strncmp(" XMLENCODING_PEEKBYTES)? XMLENCODING_PEEKBYTES: aLen)); @@ -1481,7 +1482,7 @@ static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS if(0xFF==aBytes[1]) { // FE FF // UTF-16, big-endian - oCharset = UCS2_BE; // should change to UTF-16BE + oCharset.AssignWithConversion(UCS2_BE); // should change to UTF-16BE oCharsetSource= kCharsetFromByteOrderMark; } break; @@ -1489,7 +1490,7 @@ static PRBool detectByteOrderMark(const unsigned char* aBytes, PRInt32 aLen, nsS if(0xFE==aBytes[1]) { // FF FE // UTF-16, little-endian - oCharset = UCS2_LE; // should change to UTF-16LE + oCharset.AssignWithConversion(UCS2_LE); // should change to UTF-16LE oCharsetSource= kCharsetFromByteOrderMark; } break; @@ -1565,7 +1566,7 @@ theContext->mTransferBufferSize; if(NS_SUCCEEDED(result) && (theNumRead>0)) { if(needCheckFirst4Bytes && (theNumRead >= 4)) { nsCharsetSource guessSource; - nsAutoString guess(""); + nsAutoString guess; needCheckFirst4Bytes = PR_FALSE; if(detectByteOrderMark((const unsigned char*)theContext->mTransferBuffer, @@ -1639,7 +1640,7 @@ nsresult nsParser::OnStopRequest(nsIChannel* channel, nsISupports* aContext, //If you're here, then OnDataAvailable() never got called. //Prior to necko, we never dealt with this case, but the problem may have existed. //What we'll do (for now at least) is construct a blank HTML document. - nsAutoString temp(""); + nsAutoString temp; temp.AssignWithConversion(""); mParserContext->mScanner->Append(temp); result=ResumeParse(PR_TRUE,PR_TRUE); } diff --git a/mozilla/parser/htmlparser/src/nsParserModule.cpp b/mozilla/parser/htmlparser/src/nsParserModule.cpp index 73e4f21a4de..5812d390f8d 100644 --- a/mozilla/parser/htmlparser/src/nsParserModule.cpp +++ b/mozilla/parser/htmlparser/src/nsParserModule.cpp @@ -78,7 +78,7 @@ nsParserService::HTMLStringTagToId(const nsString &aTag, PRInt32* aId) const NS_IMETHODIMP nsParserService::HTMLIdToStringTag(PRInt32 aId, nsString& aTag) const { - aTag = nsHTMLTags::GetStringValue((nsHTMLTag)aId); + aTag.AssignWithConversion( nsHTMLTags::GetStringValue((nsHTMLTag)aId) ); return NS_OK; } diff --git a/mozilla/parser/htmlparser/src/nsParserNode.cpp b/mozilla/parser/htmlparser/src/nsParserNode.cpp index b92349e5a3f..747bcf36809 100644 --- a/mozilla/parser/htmlparser/src/nsParserNode.cpp +++ b/mozilla/parser/htmlparser/src/nsParserNode.cpp @@ -35,7 +35,7 @@ static NS_DEFINE_IID(kIParserNodeIID, NS_IPARSER_NODE_IID); nsString& GetEmptyString() { static nsString* gEmptyStr=0; if(!gEmptyStr) - gEmptyStr=new nsString(""); + gEmptyStr=new nsString; return *gEmptyStr; } diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp index 34ac6a43252..04b48fc9d54 100644 --- a/mozilla/parser/htmlparser/src/nsScanner.cpp +++ b/mozilla/parser/htmlparser/src/nsScanner.cpp @@ -53,7 +53,7 @@ MOZ_DECL_CTOR_COUNTER(nsScanner); * @return */ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharsetSource aSource) : - mBuffer(anHTMLString), mFilename(""), mUnicodeXferBuf("") + mBuffer(anHTMLString) { MOZ_COUNT_CTOR(nsScanner); @@ -64,7 +64,6 @@ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharset mMarkPos=0; mInputStream=0; mUnicodeDecoder = 0; - mCharset = ""; mCharsetSource = kCharsetUninitialized; SetDocumentCharset(aCharset, aSource); mNewlinesSkipped=0; @@ -80,7 +79,7 @@ nsScanner::nsScanner(nsString& anHTMLString, const nsString& aCharset, nsCharset * @return */ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& aCharset, nsCharsetSource aSource) : - mBuffer(""), mFilename(aFilename), mUnicodeXferBuf("") + mFilename(aFilename) { MOZ_COUNT_CTOR(nsScanner); @@ -94,7 +93,6 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a mInputStream = new nsInputFileStream(nsFileSpec(aFilename)); } //if mUnicodeDecoder = 0; - mCharset = ""; mCharsetSource = kCharsetUninitialized; SetDocumentCharset(aCharset, aSource); mNewlinesSkipped=0; @@ -110,7 +108,7 @@ nsScanner::nsScanner(nsString& aFilename,PRBool aCreateStream, const nsString& a * @return */ nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& aCharset, nsCharsetSource aSource) : - mBuffer(""), mFilename(aFilename) , mUnicodeXferBuf("") + mFilename(aFilename) { MOZ_COUNT_CTOR(nsScanner); @@ -121,7 +119,6 @@ nsScanner::nsScanner(nsString& aFilename,nsInputStream& aStream,const nsString& mOwnsStream=PR_FALSE; mInputStream=&aStream; mUnicodeDecoder = 0; - mCharset = ""; mCharsetSource = kCharsetUninitialized; SetDocumentCharset(aCharset, aSource); mNewlinesSkipped=0; @@ -152,7 +149,7 @@ nsresult nsScanner::SetDocumentCharset(const nsString& aCharset , nsCharsetSourc if(NS_FAILED(res) && (kCharsetUninitialized == mCharsetSource) ) { // failed - unknown alias , fallback to ISO-8859-1 - charsetName = "ISO-8859-1"; + charsetName.AssignWithConversion("ISO-8859-1"); } mCharset = charsetName; mCharsetSource = aSource; @@ -241,10 +238,8 @@ PRUint32 nsScanner::Mark(PRInt32 anIndex){ */ PRBool nsScanner::Insert(const nsString& aBuffer) { - PRInt32 theLen=aBuffer.Length(); - - mBuffer.Insert(aBuffer,mOffset,theLen); - mTotalRead+=theLen; + mBuffer.Insert(aBuffer,mOffset); + mTotalRead+=aBuffer.Length(); return PR_TRUE; } @@ -317,7 +312,7 @@ PRBool nsScanner::Append(const char* aBuffer, PRUint32 aLen){ // delete[] unichars; } else { - mBuffer.Append(aBuffer,aLen); + mBuffer.AppendWithConversion(aBuffer,aLen); mTotalRead+=aLen; } @@ -394,7 +389,7 @@ nsresult nsScanner::FillBuffer(void) { } mOffset=mBuffer.Length(); if((0OpenContainer(theNode); @@ -664,7 +673,7 @@ nsresult WriteText(const nsString& aTextString,nsIContentSink& aSink,PRBool aPre } if(0mKey:0; eHTMLTags theTag=(eHTMLTags)theToken->GetTypeID(); - result=theService->Notify(theTag,theContext.mTokenNode,(PRUint32)theDocID,kViewSourceCommand,mParser); + result=theService->Notify(theTag,theContext.mTokenNode,(PRUint32)theDocID, NS_ConvertToString(kViewSourceCommand), mParser); } } theContext.mTokenNode.Init(0,0,gTokenRecycler); //now recycle. @@ -906,8 +915,8 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { case eToken_cdatasection: { nsString& theStr=aToken->GetStringValueXXX(); - theStr.Insert(""); + theStr.InsertWithConversion(""); result=WriteTag(mCDATATag,aToken,0,PR_TRUE); } break; @@ -933,10 +942,10 @@ NS_IMETHODIMP CViewSourceHTML::HandleToken(CToken* aToken,nsIParser* aParser) { { nsAutoString theStr; nsString& theEntity=aToken->GetStringValueXXX(); - if(!theEntity.Equals("XI",IGNORE_CASE)) { + if(!theEntity.EqualsWithConversion("XI",IGNORE_CASE)) { PRUnichar theChar=theEntity.CharAt(0); if((nsCRT::IsAsciiDigit(theChar)) || ('X'==theChar) || ('x'==theChar)){ - theStr.Append("#"); + theStr.AppendWithConversion("#"); } theStr.Append(theEntity); } diff --git a/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp b/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp index 59feff06562..88961eaf146 100644 --- a/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp +++ b/mozilla/parser/htmlparser/src/nsWellFormedDTD.cpp @@ -122,7 +122,7 @@ NS_IMPL_RELEASE(CWellFormedDTD) * @param * @return */ -CWellFormedDTD::CWellFormedDTD() : nsIDTD(), mFilename("") { +CWellFormedDTD::CWellFormedDTD() : nsIDTD() { NS_INIT_REFCNT(); mParser=0; mSink=0; @@ -177,15 +177,15 @@ eAutoDetectResult CWellFormedDTD::CanParse(CParserContext& aParserContext,nsStri eAutoDetectResult result=eUnknownDetect; if(eViewSource!=aParserContext.mParserCommand) { - if(aParserContext.mMimeType.Equals(kXMLTextContentType) || - aParserContext.mMimeType.Equals(kRDFTextContentType) || - aParserContext.mMimeType.Equals(kXULTextContentType)) { + if(aParserContext.mMimeType.EqualsWithConversion(kXMLTextContentType) || + aParserContext.mMimeType.EqualsWithConversion(kRDFTextContentType) || + aParserContext.mMimeType.EqualsWithConversion(kXULTextContentType)) { result=ePrimaryDetect; } else { if(-1GetStringValueXXX(); - if (!temp.Equals("")) + if (!temp.EqualsWithConversion("")) { result= AddLeaf(node); } @@ -872,9 +872,9 @@ PRBool nsXIFDTD::GetAttributePair(nsIParserNode& aNode, nsString& aKey, nsString key.StripChars(quote); value.StripChars(quote); - if (key.Equals("name")) + if (key.EqualsWithConversion("name")) aKey = value; - if (key.Equals("value")) + if (key.EqualsWithConversion("value")) { aValue = value; hasValue = PR_TRUE; @@ -901,12 +901,12 @@ eHTMLTags nsXIFDTD::GetStartTag(const nsIParserNode& aNode, nsString& aName) { case eXIFTag_container: case eXIFTag_leaf: - if (GetAttribute(aNode,nsString("isa"),aName)) + if (GetAttribute(aNode,NS_ConvertToString("isa"),aName)) tag = tag = nsHTMLTags::LookupTag(aName); break; case eXIFTag_css_stylesheet: - aName = "style"; + aName.AssignWithConversion("style"); tag = nsHTMLTags::LookupTag(aName); break; @@ -1299,7 +1299,7 @@ nsresult nsXIFDTD::CollectContentComment(CToken* aToken, nsCParserNode& aNode) { PRBool done=PR_FALSE; PRBool inContent=PR_FALSE; nsString& comment=aToken->GetStringValueXXX(); - comment=""); + else if(fragment.EqualsWithConversion("comment")) { + comment.AppendWithConversion("-->"); result=(mSink)? mSink->AddComment(aNode):NS_OK; done=PR_TRUE; } @@ -1414,7 +1414,7 @@ void nsXIFDTD::ProcessEncodeTag(const nsIParserNode& aNode) nsString value; PRInt32 error; - if (GetAttribute(aNode,nsString("selection"),value)) + if (GetAttribute(aNode,NS_ConvertToString("selection"),value)) { PRInt32 temp = value.ToInteger(&error); if (temp == 1) @@ -1431,7 +1431,7 @@ void nsXIFDTD::ProcessEntityTag(const nsIParserNode& aNode) { nsAutoString value; - if (GetAttribute(aNode,nsString("value"),value)) { + if (GetAttribute(aNode,NS_ConvertToString("value"),value)) { value+=';'; CEntityToken* entity = new CEntityToken(value); nsCParserNode node((CToken*)entity); @@ -1448,7 +1448,7 @@ void nsXIFDTD::BeginCSSStyleSheet(const nsIParserNode& aNode) mBuffer.Truncate(0); mMaxCSSSelectorWidth = 10; - if (GetAttribute(aNode,nsString("max_css_selector_width"),value)) + if (GetAttribute(aNode,NS_ConvertToString("max_css_selector_width"),value)) { PRInt32 temp = value.ToInteger(&error); if (error == NS_OK) @@ -1470,9 +1470,9 @@ void nsXIFDTD::EndCSSStyleSheet(const nsIParserNode& aNode) CStartToken startToken(tagName); nsCParserNode startNode((CToken*)&startToken); - mBuffer.Append(""); + mBuffer.AppendWithConversion(">"); startNode.SetSkippedContent(mBuffer); mSink->AddLeaf(startNode); @@ -1494,7 +1494,7 @@ void nsXIFDTD::AddCSSSelector(const nsIParserNode& aNode) { nsString value; - if (GetAttribute(aNode, nsString("selectors"), value)) + if (GetAttribute(aNode, NS_ConvertToString("selectors"), value)) { if (mLowerCaseAttributes == PR_TRUE) value.ToLowerCase(); @@ -1517,16 +1517,16 @@ void nsXIFDTD::BeginCSSDeclarationList(const nsIParserNode& aNode) count = 0; for (PRInt32 i = 0; i < count; i++) - mBuffer.Append(" "); + mBuffer.AppendWithConversion(" "); - mBuffer.Append(" {"); + mBuffer.AppendWithConversion(" {"); mCSSDeclarationCount = 0; } void nsXIFDTD::EndCSSDeclarationList(const nsIParserNode& aNode) { - mBuffer.Append("}\n"); + mBuffer.AppendWithConversion("}\n"); } @@ -1536,14 +1536,14 @@ void nsXIFDTD::AddCSSDeclaration(const nsIParserNode& aNode) nsString value; - if (PR_TRUE == GetAttribute(aNode, nsString("property"), property)) - if (PR_TRUE == GetAttribute(aNode, nsString("value"), value)) + if (PR_TRUE == GetAttribute(aNode, NS_ConvertToString("property"), property)) + if (PR_TRUE == GetAttribute(aNode, NS_ConvertToString("value"), value)) { if (mCSSDeclarationCount != 0) - mBuffer.Append(";"); - mBuffer.Append(" "); + mBuffer.AppendWithConversion(";"); + mBuffer.AppendWithConversion(" "); mBuffer.Append(property); - mBuffer.Append(": "); + mBuffer.AppendWithConversion(": "); mBuffer.Append(value); mCSSDeclarationCount++; } diff --git a/mozilla/parser/htmlparser/src/nsXMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsXMLTokenizer.cpp index 12368e2ebb9..7cb88064a60 100644 --- a/mozilla/parser/htmlparser/src/nsXMLTokenizer.cpp +++ b/mozilla/parser/htmlparser/src/nsXMLTokenizer.cpp @@ -237,7 +237,7 @@ nsresult nsXMLTokenizer::ConsumeSpecialMarkup(PRUnichar aChar,CToken*& aToken,ns PRBool isComment=PR_TRUE; nsAutoString theEmpty; if(theChar==kLeftSquareBracket) { - nsAutoString CDATAString("[CDATA["); + nsAutoString CDATAString; CDATAString.AssignWithConversion("[CDATA["); PRBool isCDATA = PR_FALSE; result = ConsumeConditional(aScanner, CDATAString, isCDATA); if (NS_OK == result) {