diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2004-08-02 22:19:27 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2004-08-02 22:19:27 +0000 |
commit | 9d581705a7bc1c528176e290746851979025ab9e (patch) | |
tree | c6a9d011197df78f3e1985de7604b19b70ddbff1 /src | |
parent | 76a844a9c38630f8afc6ec5133818f7fb388a990 (diff) | |
download | coreutils-9d581705a7bc1c528176e290746851979025ab9e.tar.xz |
(apply_suffix): Use bool for booleans.
Diffstat (limited to 'src')
-rw-r--r-- | src/sleep.c | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/src/sleep.c b/src/sleep.c index 43ff8e8c4..aa766ee33 100644 --- a/src/sleep.c +++ b/src/sleep.c @@ -70,12 +70,12 @@ point number.\n\ scale *X by the multiplier implied by SUFFIX_CHAR. SUFFIX_CHAR may be the NUL byte or `s' to denote seconds, `m' for minutes, `h' for hours, or `d' for days. If SUFFIX_CHAR is invalid, don't modify *X - and return nonzero. Otherwise return zero. */ + and return false. Otherwise return true. */ -static int +static bool apply_suffix (double *x, char suffix_char) { - unsigned int multiplier; + int multiplier; switch (suffix_char) { @@ -93,15 +93,12 @@ apply_suffix (double *x, char suffix_char) multiplier = 60 * 60 * 24; break; default: - multiplier = 0; + return false; } - if (multiplier == 0) - return 1; - *x *= multiplier; - return 0; + return true; } int @@ -110,7 +107,7 @@ main (int argc, char **argv) int i; double seconds = 0.0; int c; - int fail = 0; + bool ok = true; initialize_main (&argc, &argv); program_name = argv[0]; @@ -145,22 +142,22 @@ main (int argc, char **argv) { double s; const char *p; - if (xstrtod (argv[i], &p, &s, c_strtod) + if (! xstrtod (argv[i], &p, &s, c_strtod) /* Nonnegative interval. */ || ! (0 <= s) /* No extra chars after the number and an optional s,m,h,d char. */ || (*p && *(p+1)) /* Check any suffix char and update S based on the suffix. */ - || apply_suffix (&s, *p)) + || ! apply_suffix (&s, *p)) { error (0, 0, _("invalid time interval `%s'"), argv[i]); - fail = 1; + ok = false; } seconds += s; } - if (fail) + if (!ok) usage (EXIT_FAILURE); if (xnanosleep (seconds)) |