diff --git a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp
index 4e82e5744ec..89876110630 100644
--- a/mozilla/htmlparser/src/nsHTMLTokenizer.cpp
+++ b/mozilla/htmlparser/src/nsHTMLTokenizer.cpp
@@ -539,7 +539,7 @@ nsresult nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner&
aScanner.GetChar(oldChar);
result=ConsumeStartTag(aChar,aToken,aScanner,aFlushTokens);
}
- else if(kEOF!=aChar) {
+ else {
// We are not dealing with a tag. So, don't consume the original
// char and leave the decision to ConsumeText().
result=ConsumeText(aToken,aScanner);
diff --git a/mozilla/htmlparser/src/nsScanner.cpp b/mozilla/htmlparser/src/nsScanner.cpp
index 0fcd1c29eb6..83cc78f9fac 100644
--- a/mozilla/htmlparser/src/nsScanner.cpp
+++ b/mozilla/htmlparser/src/nsScanner.cpp
@@ -411,9 +411,7 @@ nsresult nsScanner::Eof() {
return kEOF;
}
- if (mCurrentPosition == mEndPosition) {
- theError=FillBuffer();
- }
+ theError=FillBuffer();
if(NS_OK==theError) {
if (0==(PRUint32)mSlidingBuffer->Length()) {
@@ -473,10 +471,11 @@ nsresult nsScanner::Peek(PRUnichar& aChar, PRUint32 aOffset) {
if(NS_OK == result){
if (aOffset) {
- if (mCountRemaining < aOffset) {
+ while ((NS_OK == result) && (mCountRemaining <= aOffset)) {
result = Eof();
}
- else {
+
+ if (NS_OK == result) {
nsReadingIterator pos = mCurrentPosition;
pos.advance(aOffset);
aChar=*pos;
diff --git a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
index 4e82e5744ec..89876110630 100644
--- a/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
+++ b/mozilla/parser/htmlparser/src/nsHTMLTokenizer.cpp
@@ -539,7 +539,7 @@ nsresult nsHTMLTokenizer::ConsumeTag(PRUnichar aChar,CToken*& aToken,nsScanner&
aScanner.GetChar(oldChar);
result=ConsumeStartTag(aChar,aToken,aScanner,aFlushTokens);
}
- else if(kEOF!=aChar) {
+ else {
// We are not dealing with a tag. So, don't consume the original
// char and leave the decision to ConsumeText().
result=ConsumeText(aToken,aScanner);
diff --git a/mozilla/parser/htmlparser/src/nsScanner.cpp b/mozilla/parser/htmlparser/src/nsScanner.cpp
index 0fcd1c29eb6..83cc78f9fac 100644
--- a/mozilla/parser/htmlparser/src/nsScanner.cpp
+++ b/mozilla/parser/htmlparser/src/nsScanner.cpp
@@ -411,9 +411,7 @@ nsresult nsScanner::Eof() {
return kEOF;
}
- if (mCurrentPosition == mEndPosition) {
- theError=FillBuffer();
- }
+ theError=FillBuffer();
if(NS_OK==theError) {
if (0==(PRUint32)mSlidingBuffer->Length()) {
@@ -473,10 +471,11 @@ nsresult nsScanner::Peek(PRUnichar& aChar, PRUint32 aOffset) {
if(NS_OK == result){
if (aOffset) {
- if (mCountRemaining < aOffset) {
+ while ((NS_OK == result) && (mCountRemaining <= aOffset)) {
result = Eof();
}
- else {
+
+ if (NS_OK == result) {
nsReadingIterator pos = mCurrentPosition;
pos.advance(aOffset);
aChar=*pos;