aboutsummaryrefslogtreecommitdiff
path: root/libbuild2/parser.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'libbuild2/parser.cxx')
-rw-r--r--libbuild2/parser.cxx27
1 files changed, 18 insertions, 9 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 4242b96..babe4c9 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -2259,9 +2259,9 @@ namespace build2
if (tt != type::word)
{
- diag_record dr;
+ diag_record dr (fail (t));
- dr << fail (t) << "unterminated recipe ";
+ dr << "unterminated recipe ";
if (kind.empty ()) dr << "block"; else dr << kind << "-block";
dr << info (st) << "recipe ";
@@ -2385,9 +2385,16 @@ namespace build2
//
size_t b (0), e (0);
for (size_t m (0), n (text.size ());
- next_word (text, n, b, e, m, '\n', '\r'), b != n;
- sloc.line++)
+ next_word (text, n, b, e, m, '\n', '\r'), b != n; )
{
+ // Treat consecutive \r\n (CRLF) as if they were a single
+ // delimiter.
+ //
+ if (b != 0 && text[b - 1] == '\r' &&
+ e != n && text[e] == '\n' &&
+ m != 2)
+ continue;
+
s.assign (text, b, e - b);
if (!trim (s).empty ())
@@ -2401,6 +2408,8 @@ namespace build2
break;
}
}
+
+ sloc.line++;
}
if (b == e)
@@ -2998,8 +3007,8 @@ namespace build2
// rule-specific search) can possibly succeed so we can fail now and
// with a more accurate reason. See import2(names) for background.
//
- diag_record dr;
- dr << fail (ploc) << "unable to import target " << n;
+ diag_record dr (fail (ploc));
+ dr << "unable to import target " << n;
import_suggest (dr, *n.proj, nullptr, string (), false);
}
else
@@ -3954,7 +3963,7 @@ namespace build2
proj = n.variable ();
}
- diag_record dr;
+ maybe_diag_record dr;
do // Breakout loop.
{
if (!config)
@@ -4058,7 +4067,7 @@ namespace build2
}
while (false);
- if (!dr.empty ())
+ if (dr)
dr << info << "expected variable name in the 'config[.**]."
<< (proj.empty () ? "<project>" : proj.c_str ()) << ".**' form";
}
@@ -5754,9 +5763,9 @@ namespace build2
void parser::
parse_diag (token& t, type& tt)
{
- diag_record dr;
const location l (get_location (t));
+ diag_record dr (nullptr);
switch (t.value[0])
{
case 'f': dr << fail (l); break;