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>
This commit is contained in:
Denys Vlasenko 2010-09-24 12:39:45 +02:00
parent ebec11dff1
commit 0f2e278a8a

View File

@ -49,6 +49,9 @@ int sleep_main(int argc UNUSED_PARAM, char **argv)
#if ENABLE_FEATURE_FLOAT_SLEEP #if ENABLE_FEATURE_FLOAT_SLEEP
# if ENABLE_LOCALE_SUPPORT
setlocale (LC_NUMERIC, "C");
# endif
duration = 0; duration = 0;
do { do {
char *arg = *argv; char *arg = *argv;
@ -62,14 +65,15 @@ int sleep_main(int argc UNUSED_PARAM, char **argv)
d = strtod(arg, &pp); d = strtod(arg, &pp);
if (errno || *pp) if (errno || *pp)
bb_show_usage(); bb_show_usage();
arg[len] = sv; arg += len;
len--; *arg-- = sv;
sv = arg[len]; sv = *arg;
arg[len] = '1'; *arg = '1';
duration += d * xatoul_sfx(&arg[len], sfx); duration += d * xatoul_sfx(arg, sfx);
arg[len] = sv; *arg = sv;
} else } else {
duration += xatoul_sfx(arg, sfx); duration += xatoul_sfx(arg, sfx);
}
} while (*++argv); } while (*++argv);
ts.tv_sec = MAXINT(typeof(ts.tv_sec)); ts.tv_sec = MAXINT(typeof(ts.tv_sec));