diff options
author | Denys Vlasenko | 2021-03-23 13:50:02 +0100 |
---|---|---|
committer | Denys Vlasenko | 2021-03-23 13:50:02 +0100 |
commit | c2bd0b680667c7ec4956552f75d9ff7d040ac941 (patch) | |
tree | 8d117fedfebe03f6f97071ebc522d4ac03f08c47 /libbb | |
parent | 14ed4ec8a416a60a214bf40f9185aa227ac44598 (diff) | |
download | busybox-c2bd0b680667c7ec4956552f75d9ff7d040ac941.zip busybox-c2bd0b680667c7ec4956552f75d9ff7d040ac941.tar.gz |
timeout,top,watch,ping: parse NN.N fractional duration in locales with other separators
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/duration.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libbb/duration.c b/libbb/duration.c index 086da15..a6a29dd 100644 --- a/libbb/duration.c +++ b/libbb/duration.c @@ -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); |