From c7e6b5ab3e244ae5a47c7f461ebc9cb683c93270 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 23 Nov 2021 13:42:03 +0200 Subject: Fix multi-line comment parsing to accept trailing eos in place of newline --- libbuild2/lexer.cxx | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'libbuild2') diff --git a/libbuild2/lexer.cxx b/libbuild2/lexer.cxx index f445d4b..992e5d1 100644 --- a/libbuild2/lexer.cxx +++ b/libbuild2/lexer.cxx @@ -989,7 +989,7 @@ namespace build2 if ((c = peek ()) == '\\') { get (); - if ((c = peek ()) == '\n') + if ((c = peek ()) == '\n' || eos (c)) return true; } @@ -1000,15 +1000,16 @@ namespace build2 { // Scan until we see the closing one. // - for (; !eos (c); c = peek ()) + for (;;) { - get (); if (c == '#' && ml ()) break; - } - if (eos (c)) - fail (c) << "unterminated multi-line comment"; + if (eos (c = peek ())) + fail (c) << "unterminated multi-line comment"; + + get (); + } } else { -- cgit v1.1