mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-16 06:18:47 +02:00
Accept but warn if $Latitude/$Longituded uses locale decimal separator instead of "."
This commit is contained in:
11
src/var.c
11
src/var.c
@@ -47,6 +47,8 @@ strtod_in_c_locale(char const *str, char **endptr)
|
||||
char const *loc = setlocale(LC_NUMERIC, NULL);
|
||||
double x;
|
||||
|
||||
errno = 0;
|
||||
|
||||
/* If it failed, punt */
|
||||
if (!loc) {
|
||||
return strtod(str, endptr);
|
||||
@@ -59,6 +61,15 @@ strtod_in_c_locale(char const *str, char **endptr)
|
||||
|
||||
/* Back to original locale */
|
||||
setlocale(LC_NUMERIC, loc);
|
||||
|
||||
/* If we got an error, try in original locale, but issue a warning */
|
||||
if (errno || **endptr) {
|
||||
errno = 0;
|
||||
x = strtod(str, endptr);
|
||||
if (!errno && !**endptr) {
|
||||
Wprint("Accepting \"%s\" for $Latitude/$Longitude, but you should use the \"C\" locale decimal separator \".\" instead", str);
|
||||
}
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user