Fix a couple of potential issues in the lexer where we were ignoring the putback data

llvm-svn: 216304
This commit is contained in:
Enrico Granata 2014-08-23 00:11:38 +00:00
parent 300bdb35d4
commit 3ee335a762
1 changed files with 7 additions and 1 deletions

View File

@ -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;
}