diff options
author | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-18 23:01:58 +0000 |
---|---|---|
committer | Dmitri Gribenko <gribozavr@gmail.com> | 2012-07-18 23:01:58 +0000 |
commit | 64da4e55c111f4733135e1780216609569767351 (patch) | |
tree | 86516a74165194d5d35b39797960ad63b579764e /lib/AST/CommentLexer.cpp | |
parent | c0e8ad5fc389a6735b54f7e410ba169adbc88180 (diff) |
Comment parsing: don't parse whitespace before \endverbatim as a separate line of whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@160464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/CommentLexer.cpp')
-rw-r--r-- | lib/AST/CommentLexer.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/AST/CommentLexer.cpp b/lib/AST/CommentLexer.cpp index 5b411ca9cc..31468321cf 100644 --- a/lib/AST/CommentLexer.cpp +++ b/lib/AST/CommentLexer.cpp @@ -201,6 +201,10 @@ const char *skipWhitespace(const char *BufferPtr, const char *BufferEnd) { return BufferEnd; } +bool isWhitespace(const char *BufferPtr, const char *BufferEnd) { + return skipWhitespace(BufferPtr, BufferEnd) == BufferEnd; +} + bool isCommandNameCharacter(char C) { return (C >= 'a' && C <= 'z') || (C >= 'A' && C <= 'Z') || @@ -429,6 +433,7 @@ void Lexer::setupAndLexVerbatimBlock(Token &T, } void Lexer::lexVerbatimBlockFirstLine(Token &T) { +again: assert(BufferPtr < CommentEnd); // FIXME: It would be better to scan the text once, finding either the block @@ -458,6 +463,11 @@ void Lexer::lexVerbatimBlockFirstLine(Token &T) { // There is some text, followed by end command. Extract text first. TextEnd = BufferPtr + Pos; NextLine = TextEnd; + // If there is only whitespace before end command, skip whitespace. + if (isWhitespace(BufferPtr, TextEnd)) { + BufferPtr = TextEnd; + goto again; + } } StringRef Text(BufferPtr, TextEnd - BufferPtr); |