summaryrefslogtreecommitdiff
path: root/coreutils/sleep.c
diff options
context:
space:
mode:
authorDenys Vlasenko2010-09-24 12:39:45 +0200
committerDenys Vlasenko2010-09-24 12:39:45 +0200
commit0f2e278a8a44751594f461ee753b81da365b1147 (patch)
tree473be25e9a9dcd643e6dd6102316daacf18a24bb /coreutils/sleep.c
parentebec11dff1783023482a044a881aae5ebb020882 (diff)
downloadbusybox-0f2e278a8a44751594f461ee753b81da365b1147.zip
busybox-0f2e278a8a44751594f461ee753b81da365b1147.tar.gz
sleep: fix fractional arguments in non-POSIX locale
function old new delta sleep_main 390 379 -11 Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Diffstat (limited to 'coreutils/sleep.c')
-rw-r--r--coreutils/sleep.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/coreutils/sleep.c b/coreutils/sleep.c
index 12798d9..9acb2d1 100644
--- a/coreutils/sleep.c
+++ b/coreutils/sleep.c
@@ -49,6 +49,9 @@ int sleep_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_FLOAT_SLEEP
+# if ENABLE_LOCALE_SUPPORT
+ setlocale (LC_NUMERIC, "C");
+# endif
duration = 0;
do {
char *arg = *argv;
@@ -62,14 +65,15 @@ int sleep_main(int argc UNUSED_PARAM, char **argv)
d = strtod(arg, &pp);
if (errno || *pp)
bb_show_usage();
- arg[len] = sv;
- len--;
- sv = arg[len];
- arg[len] = '1';
- duration += d * xatoul_sfx(&arg[len], sfx);
- arg[len] = sv;
- } else
+ arg += len;
+ *arg-- = sv;
+ sv = *arg;
+ *arg = '1';
+ duration += d * xatoul_sfx(arg, sfx);
+ *arg = sv;
+ } else {
duration += xatoul_sfx(arg, sfx);
+ }
} while (*++argv);
ts.tv_sec = MAXINT(typeof(ts.tv_sec));