From: David Wells Date: Thu, 28 Jan 2016 13:44:48 +0000 (-0500) Subject: Allow parameter files to end with a '\'. X-Git-Tag: v8.4.0-rc2~46^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f736936e9a06308370046ca88366f504125cdcf0;p=dealii.git Allow parameter files to end with a '\'. --- diff --git a/source/base/parameter_handler.cc b/source/base/parameter_handler.cc index f761081dd5..28ecc77f9e 100644 --- a/source/base/parameter_handler.cc +++ b/source/base/parameter_handler.cc @@ -1381,6 +1381,13 @@ bool ParameterHandler::read_input (std::istream &input, } } + // While it does not make much sense for anyone to actually do this, allow + // the last line to end in a backslash. + if (is_concatenated) + { + status &= scan_line (fully_concatenated_line, filename, current_line_n); + } + if (status && (saved_path != subsection_path)) { std::cerr << "Unbalanced 'subsection'/'end' in file <" << filename diff --git a/tests/bits/parameter_handler_backslash_08.cc b/tests/bits/parameter_handler_backslash_08.cc new file mode 100644 index 0000000000..34dbeae514 --- /dev/null +++ b/tests/bits/parameter_handler_backslash_08.cc @@ -0,0 +1,62 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +#include "../tests.h" +#include +#include +#include + +/* + * Test that the last line in a parameter file can end in a '\' with no ill + * effect. + */ + + +int main () +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + for (unsigned int i = 0; i < 2; ++i) + { + ParameterHandler prm; + prm.enter_subsection ("Testing"); + prm.declare_entry ("value", "value", Patterns::Anything()); + prm.leave_subsection (); + + // test both relevant read_input functions + if (i == 0) + { + prm.read_input(SOURCE_DIR "/prm/parameter_handler_backslash_08.prm"); + } + else + { + std::ifstream input_stream + (SOURCE_DIR "/prm/parameter_handler_backslash_08.prm"); + prm.read_input(input_stream); + } + + std::string list; + prm.enter_subsection ("Testing"); + list = prm.get ("value"); + prm.leave_subsection (); + + deallog << list << std::endl; + } + + return 0; +} diff --git a/tests/bits/parameter_handler_backslash_08.output b/tests/bits/parameter_handler_backslash_08.output new file mode 100644 index 0000000000..d56fbce00b --- /dev/null +++ b/tests/bits/parameter_handler_backslash_08.output @@ -0,0 +1,3 @@ + +DEAL::value +DEAL::value diff --git a/tests/bits/prm/parameter_handler_backslash_08.prm b/tests/bits/prm/parameter_handler_backslash_08.prm new file mode 100644 index 0000000000..d9d7ec8d7e --- /dev/null +++ b/tests/bits/prm/parameter_handler_backslash_08.prm @@ -0,0 +1,5 @@ +# Allow the last line to end with a '\'. +#--------------------------------------- +subsection Testing + set value = value +end\