From 24c5a3ebb2555b49ebbd10f5c1749fb3308c4772 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 19 Mar 2024 13:20:14 +0200 Subject: Use new next_word() to observe blank lines for accurate line count --- libbuild2/parser.cxx | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libbuild2') 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); -- cgit v1.1