[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
coreutils comm int->bool cleanup
From: |
Paul Eggert |
Subject: |
coreutils comm int->bool cleanup |
Date: |
Thu, 29 Jul 2004 22:27:39 -0700 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3 (gnu/linux) |
Another minor cleanup; no bug fixes.
2004-07-29 Paul Eggert <address@hidden>
* src/comm.c (hard_LC_COLLATE, only_file_1, only_file_2, both,
compare_files, main): Use bool when appropriate.
Index: comm.c
===================================================================
RCS file: /home/eggert/coreutils/cu/src/comm.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -p -u -r1.75 -r1.76
--- comm.c 21 Jun 2004 15:03:35 -0000 1.75
+++ comm.c 30 Jul 2004 05:25:17 -0000 1.76
@@ -41,17 +41,17 @@
/* 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
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);
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- coreutils comm int->bool cleanup,
Paul Eggert <=