[Lldb-commits] [lldb] r216304 - Fix a couple of potential issues in the lexer where we were ignoring the putback data

Enrico Granata egranata at apple.com
Fri Aug 22 17:11:39 PDT 2014


Author: enrico
Date: Fri Aug 22 19:11:38 2014
New Revision: 216304

URL: http://llvm.org/viewvc/llvm-project?rev=216304&view=rev
Log:
Fix a couple of potential issues in the lexer where we were ignoring the putback data

Modified:
    lldb/trunk/source/Utility/StringLexer.cpp

Modified: lldb/trunk/source/Utility/StringLexer.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/StringLexer.cpp?rev=216304&r1=216303&r2=216304&view=diff
==============================================================================
--- lldb/trunk/source/Utility/StringLexer.cpp (original)
+++ lldb/trunk/source/Utility/StringLexer.cpp Fri Aug 22 19:11:38 2014
@@ -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;
 }
 





More information about the lldb-commits mailing list