]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Improve an error message. 16715/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Mon, 4 Mar 2024 23:57:03 +0000 (16:57 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Mon, 4 Mar 2024 23:57:03 +0000 (16:57 -0700)
While there, also simplify a piece of code by not relying on old-style
C parsing functions.

source/base/parsed_function.cc

index a71ff02ad7c6acc4123b31abcd46fba1e393fb2d..9d0446f5cf055270268764d3a3dc7f39639d9e79 100644 (file)
@@ -123,11 +123,11 @@ namespace Functions
       {
         std::vector<std::string> 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

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.