From 1c575a1b471a7b59988a743a9e6827523006dc30 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 4 Mar 2024 16:57:03 -0700 Subject: [PATCH] Improve an error message. While there, also simplify a piece of code by not relying on old-style C parsing functions. --- source/base/parsed_function.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/source/base/parsed_function.cc b/source/base/parsed_function.cc index a71ff02ad7..9d0446f5cf 100644 --- a/source/base/parsed_function.cc +++ b/source/base/parsed_function.cc @@ -123,11 +123,11 @@ namespace Functions { std::vector this_c = Utilities::split_string_list(constant, '='); - AssertThrow(this_c.size() == 2, ExcMessage("Invalid format")); - double tmp; - AssertThrow(std::sscanf(this_c[1].c_str(), "%lf", &tmp), - ExcMessage("Double number?")); - constants[this_c[0]] = tmp; + AssertThrow(this_c.size() == 2, + ExcMessage("The list of constants, <" + constants_list + + ">, is not a comma-separated list of " + "entries of the form 'name=value'.")); + constants[this_c[0]] = Utilities::string_to_double(this_c[1]); } // set pi and Pi as synonyms for the corresponding value. note that -- 2.39.5