- changed status to open
- removed comment
disallow empty value strings when setting numbers in CCTK_ParameterSet
Issue #1544
closed
Currently due to the way strtol and strtod work one can do
CCTK_ParameterSet("cctk_itlast", "Cactus", "")
which return 0 (all is fine) and sets cctk_itlast to 0 (rather than failing with -6 "invalid string").
The attached patch checks that the parameter value string is not empty.
This cannot happen from inside of parfiles since the parser disallows it. It can happen when using the Trigger thorn.
Keyword:
Comments (6)
-
reporter -
- removed comment
According to the strtol documentation:
If endptr is not NULL, strtol() stores the address of the first invalid character in *endptr. If there were no digits at all, however, strtol() stores the original value of str in *endptr. (Thus, if *str is not `\0' but **endptr is `\0' on return, the entire string was valid.)
Thus it should not be necessary to check whether the whole string consists of whitespace.
-
reporter - removed comment
Much simpler. Many thanks for th suggestion. Attached please find an updated patch.
-
- changed status to open
- removed comment
Please apply.
-
reporter - changed status to resolved
- removed comment
Applied as rev 5083 of the flesh.
-
reporter - changed status to closed
- edited description
- Log in to comment