]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(apply_suffix): Use bool for booleans.
authorPaul Eggert <eggert@cs.ucla.edu>
Mon, 2 Aug 2004 22:19:27 +0000 (22:19 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Mon, 2 Aug 2004 22:19:27 +0000 (22:19 +0000)
src/sleep.c

index 43ff8e8c4a51c9e76a73bfda31bf05ea26458b84..aa766ee332b1079235649f21e6952c13638492d1 100644 (file)
@@ -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))