From 9d581705a7bc1c528176e290746851979025ab9e Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 2 Aug 2004 22:19:27 +0000 Subject: (apply_suffix): Use bool for booleans. --- src/sleep.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/sleep.c') 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)) -- cgit v1.2.3-54-g00ecf