From 7d4586a4d1bcf1f574cb3634105f501ba4e8ead0 Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Thu, 8 Jul 1999 04:39:38 +0000 Subject: [PATCH] fixed bug 9386 and added Terminate() to parser API --- htmlparser/src/nsHTMLTokenizer.cpp | 2 +- htmlparser/src/nsHTMLTokens.cpp | 37 +++++++++-------------- htmlparser/src/nsIParser.h | 1 + htmlparser/src/nsParser.cpp | 13 ++++++++ htmlparser/src/nsParser.h | 3 +- parser/htmlparser/src/nsHTMLTokenizer.cpp | 2 +- parser/htmlparser/src/nsHTMLTokens.cpp | 37 +++++++++-------------- parser/htmlparser/src/nsIParser.h | 1 + parser/htmlparser/src/nsParser.cpp | 13 ++++++++ parser/htmlparser/src/nsParser.h | 3 +- 10 files changed, 64 insertions(+), 48 deletions(-) diff --git a/htmlparser/src/nsHTMLTokenizer.cpp b/htmlparser/src/nsHTMLTokenizer.cpp index f8d9dd8cb5a..cf9ad14def9 100644 --- a/htmlparser/src/nsHTMLTokenizer.cpp +++ b/htmlparser/src/nsHTMLTokenizer.cpp @@ -462,9 +462,9 @@ nsresult nsHTMLTokenizer::ConsumeStartTag(PRUnichar aChar,CToken*& aToken,nsScan if((eHTMLTag_style==theTag) || (eHTMLTag_script==theTag)) { nsAutoString endTag(NS_EnumToTag(theTag)); endTag.Insert(""); CToken* textToken=theRecycler->CreateTokenOfType(eToken_text,theTag,endTag); result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(eHTMLTag_style==theTag),aScanner,endTag); //tell new token to finish consuming text... + //endTag.Append(">"); CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag,endTag); AddToken(textToken,result,mTokenDeque,theRecycler); AddToken(endToken,result,mTokenDeque,theRecycler); diff --git a/htmlparser/src/nsHTMLTokens.cpp b/htmlparser/src/nsHTMLTokens.cpp index 0225d4ade4f..671f61ae73e 100644 --- a/htmlparser/src/nsHTMLTokens.cpp +++ b/htmlparser/src/nsHTMLTokens.cpp @@ -507,11 +507,12 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner) { * @return error result */ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,nsString& aTerminalString){ - PRBool done=PR_FALSE; - nsresult result=NS_OK; - nsString temp; - PRUnichar theChar; - nsAutoString theRight; + PRBool done=PR_FALSE; + nsresult result=NS_OK; + nsString temp; + PRUnichar theChar; + nsAutoString theRight; + PRInt32 rpos=0; //We're going to try a new algorithm here. Rather than scan for the matching //end tag like we used to do, we're now going to scan for whitespace and comments. @@ -519,7 +520,7 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann //target endtag, or the start of another comment. static nsAutoString theWhitespace2("\b\t "); - + PRInt32 termStrLen=aTerminalString.Length(); while((!done) && (NS_OK==result)) { result=aScanner.GetChar(aChar); if((NS_OK==result) && (kLessThan==aChar)) { @@ -553,17 +554,20 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann temp+=aChar; result=aScanner.ReadUntil(temp,kLessThan,PR_FALSE); } - temp.Right(theRight,aTerminalString.Length()); - done=PRBool(0==theRight.Compare(aTerminalString,PR_TRUE)); + temp.Right(theRight,termStrLen+10); //first, get a wad of chars from the temp string + rpos=theRight.RFind('<'); //now scan for the '<' + if(-1"); CToken* textToken=theRecycler->CreateTokenOfType(eToken_text,theTag,endTag); result=((CTextToken*)textToken)->ConsumeUntil(0,PRBool(eHTMLTag_style==theTag),aScanner,endTag); //tell new token to finish consuming text... + //endTag.Append(">"); CToken* endToken=theRecycler->CreateTokenOfType(eToken_end,theTag,endTag); AddToken(textToken,result,mTokenDeque,theRecycler); AddToken(endToken,result,mTokenDeque,theRecycler); diff --git a/parser/htmlparser/src/nsHTMLTokens.cpp b/parser/htmlparser/src/nsHTMLTokens.cpp index 0225d4ade4f..671f61ae73e 100644 --- a/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/parser/htmlparser/src/nsHTMLTokens.cpp @@ -507,11 +507,12 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner) { * @return error result */ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScanner& aScanner,nsString& aTerminalString){ - PRBool done=PR_FALSE; - nsresult result=NS_OK; - nsString temp; - PRUnichar theChar; - nsAutoString theRight; + PRBool done=PR_FALSE; + nsresult result=NS_OK; + nsString temp; + PRUnichar theChar; + nsAutoString theRight; + PRInt32 rpos=0; //We're going to try a new algorithm here. Rather than scan for the matching //end tag like we used to do, we're now going to scan for whitespace and comments. @@ -519,7 +520,7 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann //target endtag, or the start of another comment. static nsAutoString theWhitespace2("\b\t "); - + PRInt32 termStrLen=aTerminalString.Length(); while((!done) && (NS_OK==result)) { result=aScanner.GetChar(aChar); if((NS_OK==result) && (kLessThan==aChar)) { @@ -553,17 +554,20 @@ nsresult CTextToken::ConsumeUntil(PRUnichar aChar,PRBool aIgnoreComments,nsScann temp+=aChar; result=aScanner.ReadUntil(temp,kLessThan,PR_FALSE); } - temp.Right(theRight,aTerminalString.Length()); - done=PRBool(0==theRight.Compare(aTerminalString,PR_TRUE)); + temp.Right(theRight,termStrLen+10); //first, get a wad of chars from the temp string + rpos=theRight.RFind('<'); //now scan for the '<' + if(-1