]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(hard_LC_COLLATE, only_file_1, only_file_2, both, compare_files, main):
authorPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Jul 2004 05:25:17 +0000 (05:25 +0000)
committerPaul Eggert <eggert@cs.ucla.edu>
Fri, 30 Jul 2004 05:25:17 +0000 (05:25 +0000)
Use bool when appropriate.

src/comm.c

index c854b8c707fa86283950e30e661fbc4917ebb0a4..96b59ea47b41545bc4c6a558aa32f9fdc6334367 100644 (file)
 /* The name this program was run with. */
 char *program_name;
 
-/* Nonzero if the LC_COLLATE locale is hard.  */
-static int hard_LC_COLLATE;
+/* True if the LC_COLLATE locale is hard.  */
+static bool hard_LC_COLLATE;
 
-/* If nonzero, print lines that are found only in file 1. */
-static int only_file_1;
+/* If true, print lines that are found only in file 1. */
+static bool only_file_1;
 
-/* If nonzero, print lines that are found only in file 2. */
-static int only_file_2;
+/* If true, print lines that are found only in file 2. */
+static bool only_file_2;
 
-/* If nonzero, print lines that are found in both files. */
-static int both;
+/* If true, print lines that are found in both files. */
+static bool both;
 
 static struct option const long_options[] =
 {
@@ -138,9 +138,9 @@ writeline (const struct linebuffer *line, FILE *stream, int class)
    If either is "-", use the standard input for that file.
    Assume that each input file is sorted;
    merge them and output the result.
-   Return 0 if successful, 1 if any errors occur. */
+   Return true if successful.  */
 
-static int
+static bool
 compare_files (char **infiles)
 {
   /* For each file, we have one linebuffer in lb1.  */
@@ -156,7 +156,8 @@ compare_files (char **infiles)
   /* errno values for each stream.  */
   int saved_errno[2];
 
-  int i, ret = 0;
+  int i;
+  bool ret = true;
 
   /* Initialize the storage. */
   for (i = 0; i < 2; i++)
@@ -167,7 +168,7 @@ compare_files (char **infiles)
       if (!streams[i])
        {
          error (0, errno, "%s", infiles[i]);
-         return 1;
+         return false;
        }
 
       thisline[i] = readlinebuffer (thisline[i], streams[i]);
@@ -229,12 +230,12 @@ compare_files (char **infiles)
       if (ferror (streams[i]))
        {
          error (0, saved_errno[i], "%s", infiles[i]);
-         ret = 1;
+         ret = false;
        }
       if (fclose (streams[i]) != 0)
        {
          error (0, errno, "%s", infiles[i]);
-         ret = 1;
+         ret = false;
        }
     }
   return ret;
@@ -254,9 +255,9 @@ main (int argc, char **argv)
 
   atexit (close_stdout);
 
-  only_file_1 = 1;
-  only_file_2 = 1;
-  both = 1;
+  only_file_1 = true;
+  only_file_2 = true;
+  both = true;
 
   while ((c = getopt_long (argc, argv, "123", long_options, NULL)) != -1)
     switch (c)
@@ -265,15 +266,15 @@ main (int argc, char **argv)
        break;
 
       case '1':
-       only_file_1 = 0;
+       only_file_1 = false;
        break;
 
       case '2':
-       only_file_2 = 0;
+       only_file_2 = false;
        break;
 
       case '3':
-       both = 0;
+       both = false;
        break;
 
       case_GETOPT_HELP_CHAR;
@@ -299,6 +300,6 @@ main (int argc, char **argv)
       usage (EXIT_FAILURE);
     }
 
-  exit (compare_files (argv + optind) == 0
+  exit (compare_files (argv + optind)
        ? EXIT_SUCCESS : EXIT_FAILURE);
 }