aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-03-23 13:50:02 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2021-03-23 13:50:02 +0100
commitc2bd0b680667c7ec4956552f75d9ff7d040ac941 (patch)
tree8d117fedfebe03f6f97071ebc522d4ac03f08c47 /libbb
parent14ed4ec8a416a60a214bf40f9185aa227ac44598 (diff)
downloadbusybox-w32-c2bd0b680667c7ec4956552f75d9ff7d040ac941.tar.gz
busybox-w32-c2bd0b680667c7ec4956552f75d9ff7d040ac941.tar.bz2
busybox-w32-c2bd0b680667c7ec4956552f75d9ff7d040ac941.zip
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.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/libbb/duration.c b/libbb/duration.c
index 086da15fb..a6a29ddae 100644
--- a/libbb/duration.c
+++ b/libbb/duration.c
@@ -37,8 +37,18 @@ duration_t FAST_FUNC parse_duration_str(char *str)
37 if (strchr(str, '.')) { 37 if (strchr(str, '.')) {
38 double d; 38 double d;
39 char *pp; 39 char *pp;
40 int len = strspn(str, "0123456789."); 40 int len;
41 char sv = str[len]; 41 char sv;
42
43# if ENABLE_LOCALE_SUPPORT
44 /* Undo busybox.c: on input, we want to use dot
45 * as fractional separator in strtod(),
46 * regardless of current locale
47 */
48 setlocale(LC_NUMERIC, "C");
49# endif
50 len = strspn(str, "0123456789.");
51 sv = str[len];
42 str[len] = '\0'; 52 str[len] = '\0';
43 errno = 0; 53 errno = 0;
44 d = strtod(str, &pp); 54 d = strtod(str, &pp);