Skip to content

Commit 7361007

Browse files
committed
[parser] Fix parse error when a macro invocation is immediately followed by the end of file.
1 parent d4e7426 commit 7361007

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

source/parser/scanner.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,11 +338,14 @@ void Scanner::SetInputStream(SourcePtr stream)
338338

339339
bool Scanner::SetInputStream(SourcePtr stream, const Bookmark& bookmark)
340340
{
341+
bool seekOk;
342+
341343
if ((mpSource == stream) && (bookmark.offset >= mBase) &&
342344
((bookmark.offset - mBase) < (mpBufferEnd - maBuffer)))
343345
{
344346
// Bookmark is already loaded in the buffer.
345347
// Just advance/rewind the next character accordingly.
348+
seekOk = true;
346349
mpNextChar = maBuffer + (bookmark.offset - mBase);
347350
}
348351
else
@@ -353,11 +356,12 @@ bool Scanner::SetInputStream(SourcePtr stream, const Bookmark& bookmark)
353356
mpSource = stream;
354357

355358
// Refill the buffer.
356-
mEndOfStream = !mpSource->seekg(bookmark.offset);
359+
seekOk = mpSource->seekg(bookmark.offset);
357360
mBase = mpSource->tellg();
358361
mpBufferEnd = maBuffer;
359362
mpNextChar = maBuffer;
360-
if (!mEndOfStream)
363+
mEndOfStream = !seekOk;
364+
if (seekOk)
361365
RefillBuffer();
362366
}
363367

@@ -370,7 +374,7 @@ bool Scanner::SetInputStream(SourcePtr stream, const Bookmark& bookmark)
370374
mNominalEndOfLine = bookmark.nominalEndOfLine;
371375
mAllowNestedBlockComments = bookmark.allowNestedBlockComments;
372376

373-
return !mEndOfStream;
377+
return seekOk;
374378
}
375379

376380
void pov_parser::Scanner::SetStringEncoding(StringEncoding encoding)

0 commit comments

Comments
 (0)