From: Wolfgang Bangerth Date: Mon, 4 Mar 2024 23:57:03 +0000 (-0700) Subject: Improve an error message. X-Git-Tag: v9.6.0-rc1~510^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c575a1b471a7b59988a743a9e6827523006dc30;p=dealii.git Improve an error message. While there, also simplify a piece of code by not relying on old-style C parsing functions. --- 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