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)
{
multiplier = 60 * 60 * 24;
break;
default:
- multiplier = 0;
+ return false;
}
- if (multiplier == 0)
- return 1;
-
*x *= multiplier;
- return 0;
+ return true;
}
int
int i;
double seconds = 0.0;
int c;
- int fail = 0;
+ bool ok = true;
initialize_main (&argc, &argv);
program_name = argv[0];
{
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))