diff --git a/src/libinput-util.h b/src/libinput-util.h index 1ef4387f..850f1cc1 100644 --- a/src/libinput-util.h +++ b/src/libinput-util.h @@ -31,7 +31,9 @@ #include #include #include +#ifdef HAVE_LOCALE_H #include +#endif #ifdef HAVE_XLOCALE_H #include #endif @@ -559,7 +561,9 @@ safe_atod(const char *str, double *val) { char *endptr; double v; +#ifdef HAVE_LOCALE_H locale_t c_locale; +#endif size_t slen = strlen(str); /* We don't have a use-case where we want to accept hex for a double @@ -579,6 +583,7 @@ safe_atod(const char *str, double *val) } } +#ifdef HAVE_LOCALE_H /* Create a "C" locale to force strtod to use '.' as separator */ c_locale = newlocale(LC_NUMERIC_MASK, "C", (locale_t)0); if (c_locale == (locale_t)0) @@ -587,6 +592,11 @@ safe_atod(const char *str, double *val) errno = 0; v = strtod_l(str, &endptr, c_locale); freelocale(c_locale); +#else + /* No locale support in provided libc, assume it already uses '.' */ + errno = 0; + v = strtod(str, &endptr); +#endif if (errno > 0) return false; if (str == endptr)