diff options
| author | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-15 22:01:49 +0000 |
|---|---|---|
| committer | Denis Vlasenko <vda.linux@googlemail.com> | 2008-07-15 22:01:49 +0000 |
| commit | 97faf531c81be075ecafb2ac83b17eae78cd2afb (patch) | |
| tree | b4e51950da0b124b808242d041927acabe11cc5d /coreutils | |
| parent | 5e476bab9c6db89dfadc94a8c4fbf3082339fecf (diff) | |
| download | busybox-w32-97faf531c81be075ecafb2ac83b17eae78cd2afb.tar.gz busybox-w32-97faf531c81be075ecafb2ac83b17eae78cd2afb.tar.bz2 busybox-w32-97faf531c81be075ecafb2ac83b17eae78cd2afb.zip | |
sleep: make fractional seconds separately selectable in .config
Diffstat (limited to 'coreutils')
| -rw-r--r-- | coreutils/Config.in | 23 | ||||
| -rw-r--r-- | coreutils/sleep.c | 6 |
2 files changed, 22 insertions, 7 deletions
diff --git a/coreutils/Config.in b/coreutils/Config.in index 8d6192586..b01980d9a 100644 --- a/coreutils/Config.in +++ b/coreutils/Config.in | |||
| @@ -509,18 +509,33 @@ config SHA1SUM | |||
| 509 | Compute and check SHA1 message digest | 509 | Compute and check SHA1 message digest |
| 510 | 510 | ||
| 511 | config SLEEP | 511 | config SLEEP |
| 512 | bool "sleep (single integer arg with no suffix)" | 512 | bool "sleep" |
| 513 | default n | 513 | default n |
| 514 | help | 514 | help |
| 515 | sleep is used to pause for a specified number of seconds, | 515 | sleep is used to pause for a specified number of seconds. |
| 516 | It comes in 3 versions: | ||
| 517 | - small: takes one integer parameter | ||
| 518 | - fancy: takes multiple integer arguments with suffixes: | ||
| 519 | sleep 1d 2h 3m 15s | ||
| 520 | - fancy with fractional numbers: | ||
| 521 | sleep 2.3s 4.5h sleeps for 16202.3 seconds | ||
| 522 | Last one is "the most compatible" with coreutils sleep, | ||
| 523 | but it adds around 1k of code. | ||
| 516 | 524 | ||
| 517 | config FEATURE_FANCY_SLEEP | 525 | config FEATURE_FANCY_SLEEP |
| 518 | bool "Enable multiple integer args and optional time suffixes" | 526 | bool "Enable multiple arguments and s/m/h/d suffixes" |
| 519 | default n | 527 | default n |
| 520 | depends on SLEEP | 528 | depends on SLEEP |
| 521 | help | 529 | help |
| 522 | Allow sleep to pause for specified minutes, hours, and days. | 530 | Allow sleep to pause for specified minutes, hours, and days. |
| 523 | 531 | ||
| 532 | config FEATURE_FLOAT_SLEEP | ||
| 533 | bool "Enable fractional arguments" | ||
| 534 | default n | ||
| 535 | depends on FEATURE_FANCY_SLEEP | ||
| 536 | help | ||
| 537 | Allow for fractional numeric parameters. | ||
| 538 | |||
| 524 | config SORT | 539 | config SORT |
| 525 | bool "sort" | 540 | bool "sort" |
| 526 | default n | 541 | default n |
| @@ -532,7 +547,7 @@ config FEATURE_SORT_BIG | |||
| 532 | default y | 547 | default y |
| 533 | depends on SORT | 548 | depends on SORT |
| 534 | help | 549 | help |
| 535 | Without this, sort only supports -r, -u, and an integer version | 550 | Without this, sort only supports -r, -u, and an integer version |
| 536 | of -n. Selecting this adds sort keys, floating point support, and | 551 | of -n. Selecting this adds sort keys, floating point support, and |
| 537 | more. This adds a little over 3k to a nonstatic build on x86. | 552 | more. This adds a little over 3k to a nonstatic build on x86. |
| 538 | 553 | ||
diff --git a/coreutils/sleep.c b/coreutils/sleep.c index 93b178d76..de18dd0db 100644 --- a/coreutils/sleep.c +++ b/coreutils/sleep.c | |||
| @@ -23,7 +23,7 @@ | |||
| 23 | /* This is a NOFORK applet. Be very careful! */ | 23 | /* This is a NOFORK applet. Be very careful! */ |
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | #if ENABLE_FEATURE_FANCY_SLEEP | 26 | #if ENABLE_FEATURE_FANCY_SLEEP || ENABLE_FEATURE_FLOAT_SLEEP |
| 27 | static const struct suffix_mult sfx[] = { | 27 | static const struct suffix_mult sfx[] = { |
| 28 | { "s", 1 }, | 28 | { "s", 1 }, |
| 29 | { "m", 60 }, | 29 | { "m", 60 }, |
| @@ -36,7 +36,7 @@ static const struct suffix_mult sfx[] = { | |||
| 36 | int sleep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; | 36 | int sleep_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
| 37 | int sleep_main(int argc UNUSED_PARAM, char **argv) | 37 | int sleep_main(int argc UNUSED_PARAM, char **argv) |
| 38 | { | 38 | { |
| 39 | #if ENABLE_FEATURE_FANCY_SLEEP && ENABLE_DESKTOP | 39 | #if ENABLE_FEATURE_FLOAT_SLEEP |
| 40 | double duration; | 40 | double duration; |
| 41 | struct timespec ts; | 41 | struct timespec ts; |
| 42 | #else | 42 | #else |
| @@ -47,7 +47,7 @@ int sleep_main(int argc UNUSED_PARAM, char **argv) | |||
| 47 | if (!*argv) | 47 | if (!*argv) |
| 48 | bb_show_usage(); | 48 | bb_show_usage(); |
| 49 | 49 | ||
| 50 | #if ENABLE_FEATURE_FANCY_SLEEP && ENABLE_DESKTOP | 50 | #if ENABLE_FEATURE_FLOAT_SLEEP |
| 51 | 51 | ||
| 52 | duration = 0; | 52 | duration = 0; |
| 53 | do { | 53 | do { |
