From 6f3fdf06c064465f94b0b61c6c74fd0c49a96b8b Mon Sep 17 00:00:00 2001 From: David Wells Date: Thu, 15 Sep 2016 08:16:32 -0400 Subject: [PATCH] Number continuation lines with their first line. Since a continuation line in a parameter file consists of several lines concatenated by trailing '\'s, use the first line number when printing error messages to make things a bit clearer. --- source/base/parameter_handler.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/base/parameter_handler.cc b/source/base/parameter_handler.cc index 75ced58783..937869c49f 100644 --- a/source/base/parameter_handler.cc +++ b/source/base/parameter_handler.cc @@ -1616,12 +1616,18 @@ bool ParameterHandler::read_input (std::istream &input, std::string input_line; std::string fully_concatenated_line; bool is_concatenated = false; + // Maintain both the current line number and the current logical line + // number, where the latter refers to the line number where (possibly) the + // current line continuation started. unsigned int current_line_n = 0; + unsigned int current_logical_line_n = 0; bool status = true; while (std::getline (input, input_line)) { ++current_line_n; + if (!is_concatenated) + current_logical_line_n = current_line_n; // Trim the whitespace at the ends of the line here instead of in // scan_line. This makes the continuation line logic a lot simpler. input_line = Utilities::trim (input_line); @@ -1658,7 +1664,7 @@ bool ParameterHandler::read_input (std::istream &input, if (!is_concatenated) { - status &= scan_line (fully_concatenated_line, filename, current_line_n); + status &= scan_line (fully_concatenated_line, filename, current_logical_line_n); fully_concatenated_line.clear(); } } -- 2.39.5