aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2024-03-19 13:20:14 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2024-03-19 13:20:14 +0200
commit24c5a3ebb2555b49ebbd10f5c1749fb3308c4772 (patch)
tree864268630e5a4aed5a11aeaed50458acd9c8a5a0
parentce558a5aebc649e52da9598f248bd15fd08a9ba2 (diff)
Use new next_word() to observe blank lines for accurate line count
-rw-r--r--libbuild2/parser.cxx6
1 files changed, 4 insertions, 2 deletions
diff --git a/libbuild2/parser.cxx b/libbuild2/parser.cxx
index 4cbb30d..5321cd5 100644
--- a/libbuild2/parser.cxx
+++ b/libbuild2/parser.cxx
@@ -2374,10 +2374,12 @@ namespace build2
string s;
location sloc (file, 1, 1);
{
- // @@ Line is inaccurate since we skip consecutive newlines!
+ // Note: observe blank lines for accurate line count.
//
size_t b (0), e (0);
- for (; next_word (text, b, e, '\n', '\r'); sloc.line++)
+ for (size_t m (0), n (text.size ());
+ next_word (text, n, b, e, m, '\n', '\r'), b != n;
+ sloc.line++)
{
s.assign (text, b, e - b);