aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc/lexer.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-04-28 08:48:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-05-27 15:47:28 +0200
commitb808c255b6a9ddba085bf5646e7d20ec344f2e2d (patch)
tree32730291f7e6de8ef0a227905520dd66fb4ec0f3 /libbuild2/cc/lexer.cxx
parent3552356a87402727e663131994fa87f48b3cd4fb (diff)
Initial support for ad hoc recipes (still work in progress)
Diffstat (limited to 'libbuild2/cc/lexer.cxx')
-rw-r--r--libbuild2/cc/lexer.cxx13
1 files changed, 5 insertions, 8 deletions
diff --git a/libbuild2/cc/lexer.cxx b/libbuild2/cc/lexer.cxx
index d57f5eb..d2be3d8 100644
--- a/libbuild2/cc/lexer.cxx
+++ b/libbuild2/cc/lexer.cxx
@@ -48,8 +48,8 @@ namespace build2
auto lexer::
peek (bool e) -> xchar
{
- if (unget_)
- return ungetc_;
+ if (ungetn_ != 0)
+ return ungetb_[ungetn_ - 1];
if (unpeek_)
return unpeekc_;
@@ -98,11 +98,8 @@ namespace build2
inline auto lexer::
get (bool e) -> xchar
{
- if (unget_)
- {
- unget_ = false;
- return ungetc_;
- }
+ if (ungetn_ != 0)
+ return ungetb_[--ungetn_];
else
{
xchar c (peek (e));
@@ -117,7 +114,7 @@ namespace build2
// Increment the logical line similar to how base will increment the
// physical (the column counts are the same).
//
- if (log_line_ && c == '\n' && !unget_)
+ if (log_line_ && c == '\n' && ungetn_ == 0)
++*log_line_;
base::get (c);