From 6dafd0deacd56b6b9b3590ebdb05bbcb9227d531 Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Tue, 19 Oct 1999 08:52:30 +0000 Subject: [PATCH] fixed bug 16584; CRCRLF not handled correctly. r=syd git-svn-id: svn://10.0.0.236/trunk@51125 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/htmlparser/src/nsHTMLTokens.cpp | 46 ++++++++++++------- .../parser/htmlparser/src/nsHTMLTokens.cpp | 46 ++++++++++++------- 2 files changed, 60 insertions(+), 32 deletions(-) diff --git a/mozilla/htmlparser/src/nsHTMLTokens.cpp b/mozilla/htmlparser/src/nsHTMLTokens.cpp index 541611626e7..2289809b7ca 100644 --- a/mozilla/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/htmlparser/src/nsHTMLTokens.cpp @@ -443,24 +443,38 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) result=aScanner.ReadUntil(mTextValue,theTerminals,PR_TRUE,PR_FALSE); if(NS_OK==result) { result=aScanner.Peek(aChar); + if(((kCR==aChar) || (kNewLine==aChar)) && (NS_OK==result)) { - result=aScanner.GetChar(aChar); //strip off the \r - result=aScanner.Peek(aChar); //then see what's next. - if(NS_OK==result) { - switch(aChar) { - case kCR: - result=aScanner.GetChar(aChar); //strip off the \r - mTextValue.Append("\n\n"); - break; - case kNewLine: - //which means we saw \r\n, which becomes \n - result=aScanner.GetChar(aChar); //strip off the \n - //now fall through on purpose... - default: + result=aScanner.GetChar(aChar); //strip off the char + PRUnichar theNextChar; + result=aScanner.Peek(theNextChar); //then see what's next. + switch(aChar) { + case kCR: + // result=aScanner.GetChar(aChar); + if(kLF==theNextChar) { + result=aScanner.GetChar(theNextChar); + } + else if(kCR==theNextChar) { + result=aScanner.GetChar(theNextChar); + result=aScanner.Peek(theNextChar); //then see what's next. + if(kLF==theNextChar) { + result=aScanner.GetChar(theNextChar); + } mTextValue.Append("\n"); - break; - }//switch - }//if + } + mTextValue.Append("\n"); + break; + case kLF: + if((kLF==theNextChar) || (kCR==theNextChar)) { + result=aScanner.GetChar(theNextChar); + mTextValue.Append("\n"); + } + mTextValue.Append("\n"); + break; + default: + mTextValue.Append("\n"); + break; + } //switch } else done=PR_TRUE; } diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index 541611626e7..2289809b7ca 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -443,24 +443,38 @@ nsresult CTextToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aMode) result=aScanner.ReadUntil(mTextValue,theTerminals,PR_TRUE,PR_FALSE); if(NS_OK==result) { result=aScanner.Peek(aChar); + if(((kCR==aChar) || (kNewLine==aChar)) && (NS_OK==result)) { - result=aScanner.GetChar(aChar); //strip off the \r - result=aScanner.Peek(aChar); //then see what's next. - if(NS_OK==result) { - switch(aChar) { - case kCR: - result=aScanner.GetChar(aChar); //strip off the \r - mTextValue.Append("\n\n"); - break; - case kNewLine: - //which means we saw \r\n, which becomes \n - result=aScanner.GetChar(aChar); //strip off the \n - //now fall through on purpose... - default: + result=aScanner.GetChar(aChar); //strip off the char + PRUnichar theNextChar; + result=aScanner.Peek(theNextChar); //then see what's next. + switch(aChar) { + case kCR: + // result=aScanner.GetChar(aChar); + if(kLF==theNextChar) { + result=aScanner.GetChar(theNextChar); + } + else if(kCR==theNextChar) { + result=aScanner.GetChar(theNextChar); + result=aScanner.Peek(theNextChar); //then see what's next. + if(kLF==theNextChar) { + result=aScanner.GetChar(theNextChar); + } mTextValue.Append("\n"); - break; - }//switch - }//if + } + mTextValue.Append("\n"); + break; + case kLF: + if((kLF==theNextChar) || (kCR==theNextChar)) { + result=aScanner.GetChar(theNextChar); + mTextValue.Append("\n"); + } + mTextValue.Append("\n"); + break; + default: + mTextValue.Append("\n"); + break; + } //switch } else done=PR_TRUE; }