aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2020-02-21 22:14:48 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2020-02-26 17:40:31 +0300
commitc69d5dc7a81013647400e055d8c05b12eb545801 (patch)
treea2f14d52b9ff87e84b8cce07d6a36033bf774c8c
parent003f56bf62433d6b009368e52855c766118468e1 (diff)
Adapt to adding validator to butl::char_scanner
-rw-r--r--libbuild2/cc/lexer.cxx50
-rw-r--r--libbuild2/cc/lexer.hxx4
-rw-r--r--libbuild2/lexer.hxx4
3 files changed, 34 insertions, 24 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)
diff --git a/libbuild2/lexer.hxx b/libbuild2/lexer.hxx
index 40be996..65a9ba6 100644
--- a/libbuild2/lexer.hxx
+++ b/libbuild2/lexer.hxx
@@ -88,7 +88,7 @@ namespace build2
lexer_mode (base_type v): base_type (v) {}
};
- class LIBBUILD2_SYMEXPORT lexer: public butl::char_scanner
+ class LIBBUILD2_SYMEXPORT lexer: public butl::char_scanner<>
{
public:
// If escape is not NULL then only escape sequences with characters from
@@ -220,7 +220,7 @@ namespace build2
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;