[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnuastro-commits] master 86c0e0e 2/2: Library (options.h): accounting f
[gnuastro-commits] master 86c0e0e 2/2: Library (options.h): accounting for non-sexagesimal colons in values
Sat, 18 Dec 2021 14:56:48 -0500 (EST)
Author: Mohammad Akhlaghi <email@example.com>
Commit: Mohammad Akhlaghi <firstname.lastname@example.org>
Library (options.h): accounting for non-sexagesimal colons in values
Until now, when 'gal_options_parse_list_of_numbers' was given a string like
'4:5' (extracted for example from Table's '--range=NAME,4:5') it would
abort, complaining that '4:5' can't be parsed as a number. This is the
result of a recent change in this function to allow reading sexagesimal
coordinates for example '01:23:45.67'.
With this commit, the issue was fixed by avoiding the stopping of the
program when the first un-parsed character was a ':'.
It wasn't registered as a bug because it was due to a recent addition
(after version 0.16).
This issue was reported by Sepideh Eskandarlou.
lib/options.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/lib/options.c b/lib/options.c
index fd89456..70c572f 100644
@@ -827,11 +827,20 @@ gal_options_parse_list_of_numbers(char *string, char
*filename, size_t lineno)
if(*tailptr!=',' && *tailptr!='/' && *tailptr!='\0')
+ /* See if the user has given a sexagesimal value (that can't
+ be easily read with 'strtod'). */
ttmp=gal_options_read_sexagesimal(num%2, c, &tailptr);
- error_at_line(EXIT_FAILURE, 0, filename, lineno, "the "
- "'%s' component of '%s' couldn't be parsed "
- "as a usable number", c, string);
+ /* This happens in cases like the values to Table's
+ '--range=NAME,5:10'. In such cases, we do have a
+ colon, but don't have a sexagesimal number. So we
+ shouldn't abort the program! */
+ error_at_line(EXIT_FAILURE, 0, filename, lineno, "the "
+ "'%s' component of '%s' couldn't be parsed "
+ "as a usable number", c, string);