aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/cc
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/cc')
-rw-r--r--libbuild2/cc/lexer.cxx50
-rw-r--r--libbuild2/cc/lexer.hxx4
2 files changed, 32 insertions, 22 deletions
diff --git a/libbuild2/cc/lexer.cxx b/libbuild2/cc/lexer.cxx
index 36725e3..d57f5eb 100644
--- a/libbuild2/cc/lexer.cxx
+++ b/libbuild2/cc/lexer.cxx
@@ -32,7 +32,7 @@ static const uint8_t char_flags[256] =
namespace butl // ADL
{
inline build2::location
- get_location (const butl::char_scanner::xchar& c, const void* data)
+ get_location (const butl::char_scanner<>::xchar& c, const void* data)
{
using namespace build2;
@@ -702,7 +702,8 @@ namespace build2
const char* p (b);
for (char c;
- p != e && (c = *p) != '\"' && c != '\\' && c != '\n';
+ p != e &&
+ (c = *p) != '\"' && c != '\\' && c != '\n' && c != '\r';
++p) ;
size_t n (p - b);
@@ -885,7 +886,8 @@ namespace build2
const char* p (b);
for (char c;
- p != e && (c = *p) != '\"' && c != '\\' && c != '\n';
+ p != e &&
+ (c = *p) != '\"' && c != '\\' && c != '\n' && c != '\r';
++p) ;
size_t n (p - b);
@@ -1095,27 +1097,35 @@ namespace build2
break;
}
- // Direct buffer scan.
- //
- const char* b (gptr_);
- const char* e (egptr_);
- const char* p (b);
-
- for (char c;
- p != e && (c = *p) != '*' && c != '\\';
- ++p)
+ if (c != '*' && c != '\\')
{
- if (c == '\n')
+ // Direct buffer scan.
+ //
+ // Note that we should call get() prior to the direct buffer
+ // scan (see butl::char_scanner for details).
+ //
+ get (c);
+
+ const char* b (gptr_);
+ const char* e (egptr_);
+ const char* p (b);
+
+ for (char c;
+ p != e && (c = *p) != '*' && c != '\\';
+ ++p)
{
- if (log_line_) ++*log_line_;
- ++line;
- column = 1;
+ if (c == '\n')
+ {
+ if (log_line_) ++*log_line_;
+ ++line;
+ column = 1;
+ }
+ else
+ ++column;
}
- else
- ++column;
- }
- gptr_ = p; buf_->gbump (static_cast<int> (p - b));
+ gptr_ = p; buf_->gbump (static_cast<int> (p - b));
+ }
}
continue;
}
diff --git a/libbuild2/cc/lexer.hxx b/libbuild2/cc/lexer.hxx
index 8bb7e0b..d3fe807 100644
--- a/libbuild2/cc/lexer.hxx
+++ b/libbuild2/cc/lexer.hxx
@@ -79,11 +79,11 @@ namespace build2
ostream&
operator<< (ostream&, const token&);
- class lexer: protected butl::char_scanner
+ class lexer: protected butl::char_scanner<>
{
public:
lexer (ifdstream& is, const path_name& name)
- : char_scanner (is, false),
+ : char_scanner (is, false /* crlf */),
name_ (name),
fail ("error", &name_),
log_file_ (name)