]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Number continuation lines with their first line.
authorDavid Wells <wellsd2@rpi.edu>
Thu, 15 Sep 2016 12:16:32 +0000 (08:16 -0400)
committerDavid Wells <wellsd2@rpi.edu>
Tue, 27 Sep 2016 22:52:53 +0000 (18:52 -0400)
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

index 75ced5878301d1b4b910722b3844d820f152f116..937869c49fa4b2fd8adcb8ccd63dc36d10a9dc7a 100644 (file)
@@ -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();
         }
     }

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.