From 73565feba2bd4cf8ed4ae39707bc0bfccfa2eb09 Mon Sep 17 00:00:00 2001 From: "mrbkap%gmail.com" Date: Wed, 1 Jun 2005 22:34:29 +0000 Subject: [PATCH] bug 295646: Whitespace at the end of a document is thrown away by the tokenizer. r+sr=bzbarsky a=shaver git-svn-id: svn://10.0.0.236/trunk@173996 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/parser/htmlparser/src/nsHTMLTokens.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp index cbe2f620dee..2fbba19a35f 100644 --- a/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp +++ b/mozilla/parser/htmlparser/src/nsHTMLTokens.cpp @@ -1,4 +1,5 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=2 sw=2 et tw=78: */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * @@ -1626,6 +1627,11 @@ nsresult CNewlineToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 aFl } } + if (result == kEOF && !aScanner.IsIncremental()) { + // Make sure we don't lose information about this trailing newline. + result = NS_OK; + } + mNewlineCount = 1; return result; } @@ -2111,6 +2117,13 @@ nsresult CWhitespaceToken::Consume(PRUnichar aChar, nsScanner& aScanner,PRInt32 PRBool haveCR; nsresult result = aScanner.ReadWhitespace(mTextValue, mNewlineCount, haveCR); + + if (result == kEOF && !aScanner.IsIncremental()) { + // Oops, we ran off the end, make sure we don't lose the trailing + // whitespace! + result = NS_OK; + } + if (NS_OK == result && haveCR) { mTextValue.writable().StripChar(kCR); }