summaryrefslogtreecommitdiff
path: root/src/comm.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2004-07-30 05:25:17 +0000
committerPaul Eggert <eggert@cs.ucla.edu>2004-07-30 05:25:17 +0000
commite61348619a4b05688a2973a28ee0b182e905b735 (patch)
tree974fdd8a292c2acd18be60a82dec27d29f54af5b /src/comm.c
parent299d98cfe2a54168d01c4ecc72c3918d3cadb7a5 (diff)
downloadcoreutils-e61348619a4b05688a2973a28ee0b182e905b735.tar.xz
(hard_LC_COLLATE, only_file_1, only_file_2, both, compare_files, main):
Use bool when appropriate.
Diffstat (limited to 'src/comm.c')
-rw-r--r--src/comm.c43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/comm.c b/src/comm.c
index c854b8c70..96b59ea47 100644
--- a/src/comm.c
+++ b/src/comm.c
@@ -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, 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);
}