From 99a53edca0cda4bae0aeab9527d1613b340f8325 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Mon, 27 Jul 2015 00:57:30 -0400 Subject: [PATCH] Lexer: ::isLiteral now stops at EOS --- src/Lexer.cpp | 1 + test/lexer.t.cpp | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Lexer.cpp b/src/Lexer.cpp index e489c0c69..95a28afcf 100644 --- a/src/Lexer.cpp +++ b/src/Lexer.cpp @@ -1271,6 +1271,7 @@ bool Lexer::isLiteral ( // End boundary conditions must be met. if (endBoundary && + _text[_cursor + common] && ! Lexer::isWhitespace (_text[_cursor + common]) && ! Lexer::isSingleCharOperator (_text[_cursor + common])) return false; diff --git a/test/lexer.t.cpp b/test/lexer.t.cpp index 6c6acda98..d85f18b21 100644 --- a/test/lexer.t.cpp +++ b/test/lexer.t.cpp @@ -272,9 +272,9 @@ int main (int argc, char** argv) t.ok (l4.isLiteral(".", false, false), "isLiteral 'one.two' --> '.'"); t.ok (l4.isLiteral("two", false, true), "isLiteral 'one.two' --> 'two'"); - Lexer l5 ("wonderful"); - t.notok (l5.isLiteral ("wonder", false, false), "isLiteral 'wonder' != 'wonderful' without abbreviation"); - t.ok (l5.isLiteral ("wonder", true, false), "isLiteral 'wonder' == 'wonderful' with abbreviation"); + Lexer l5 ("wonder"); + t.notok (l5.isLiteral ("wonderful", false, false), "isLiteral 'wonderful' != 'wonder' without abbreviation"); + t.ok (l5.isLiteral ("wonderful", true, false), "isLiteral 'wonderful' == 'wonder' with abbreviation"); // bool isOneOf (const std::string&, bool, bool); Lexer l6 ("Grumpy.");