[ET Trac] [Einstein Toolkit] #1518: Parameter parser and CCTK_ParameterSet interpret leading zeros in numbers differently
Einstein Toolkit
trac-noreply at einsteintoolkit.org
Wed Jan 15 23:01:50 CST 2014
#1518: Parameter parser and CCTK_ParameterSet interpret leading zeros in numbers
differently
--------------------+-------------------------------------------------------
Reporter: rhaas | Owner:
Type: defect | Status: new
Priority: minor | Milestone:
Component: Cactus | Version: development version
Keywords: |
--------------------+-------------------------------------------------------
the parameter parser allows things like:
{{{
thorn::param1 = 011
thorn::param2 = 012.34
}}}
in parameter files. For floating point values this is a bit unexpected but
otherwise mostly harmless. For integers the situation is a bit more
complex since in C a leading zero is used to indicate a octal number. And
(worse) while the parameter file parser converts the string "011" to the
number 11 the Cactus call CCTK_ParameterSet will convert it to 9. The
difference is ultimately the difference between calling atof (Parser) and
strtol (CCTK_ParameterSet).
To avoid confusion it would likely be good to change CCTK_ParameterSet to
behave the way the Parameter parser does. This is a change in behaviour
compared to the pre-Piraha parser, however I suspect the number of users
that actually used octal (or hexedecimal) notation in their parameter
files is small.
The change is to change {{{inval = strtol (value, &endptr, 0);}}} to
{{{inval = strtol (value, &endptr, 10);}}} in line 2209 of
src/main/Parameters.c and similar in line 2270.
--
Ticket URL: <https://trac.einsteintoolkit.org/ticket/1518>
Einstein Toolkit <http://einsteintoolkit.org>
The Einstein Toolkit
More information about the Trac
mailing list