timeout,top,watch,ping: parse NN.N fractional duration in locales with other separators

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2021-03-23 13:50:02 +01:00
parent 14ed4ec8a4
commit c2bd0b6806
6 changed files with 16 additions and 6 deletions

View File

@@ -37,8 +37,18 @@ duration_t FAST_FUNC parse_duration_str(char *str)
if (strchr(str, '.')) {
double d;
char *pp;
int len = strspn(str, "0123456789.");
char sv = str[len];
int len;
char sv;
# if ENABLE_LOCALE_SUPPORT
/* Undo busybox.c: on input, we want to use dot
* as fractional separator in strtod(),
* regardless of current locale
*/
setlocale(LC_NUMERIC, "C");
# endif
len = strspn(str, "0123456789.");
sv = str[len];
str[len] = '\0';
errno = 0;
d = strtod(str, &pp);