From 3ee335a762a667975fec726344b4129876e05331 Mon Sep 17 00:00:00 2001 From: Enrico Granata Date: Sat, 23 Aug 2014 00:11:38 +0000 Subject: [PATCH] Fix a couple of potential issues in the lexer where we were ignoring the putback data llvm-svn: 216304 --- lldb/source/Utility/StringLexer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lldb/source/Utility/StringLexer.cpp b/lldb/source/Utility/StringLexer.cpp index 69880d21e961..4889ed7451af 100644 --- a/lldb/source/Utility/StringLexer.cpp +++ b/lldb/source/Utility/StringLexer.cpp @@ -55,7 +55,9 @@ StringLexer::Next () bool StringLexer::HasAtLeast (Size s) { - return m_data.size()-m_position >= s; + auto in_m_data = m_data.size()-m_position; + auto in_putback = m_putback_data.size(); + return (in_m_data + in_putback >= s); } @@ -68,6 +70,10 @@ StringLexer::PutBack (Character c) bool StringLexer::HasAny (Character c) { + const auto begin(m_putback_data.begin()); + const auto end(m_putback_data.end()); + if (std::find(begin, end, c) != end) + return true; return m_data.find(c, m_position) != std::string::npos; }