mirror of
https://salsa.debian.org/dskoll/remind.git
synced 2026-04-17 23:08:40 +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);
|
char const *loc = setlocale(LC_NUMERIC, NULL);
|
||||||
double x;
|
double x;
|
||||||
|
|
||||||
|
errno = 0;
|
||||||
|
|
||||||
/* If it failed, punt */
|
/* If it failed, punt */
|
||||||
if (!loc) {
|
if (!loc) {
|
||||||
return strtod(str, endptr);
|
return strtod(str, endptr);
|
||||||
@@ -59,6 +61,15 @@ strtod_in_c_locale(char const *str, char **endptr)
|
|||||||
|
|
||||||
/* Back to original locale */
|
/* Back to original locale */
|
||||||
setlocale(LC_NUMERIC, loc);
|
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;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user