/* 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[] =
{
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. */
/* 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++)
if (!streams[i])
{
error (0, errno, "%s", infiles[i]);
- return 1;
+ return false;
}
thisline[i] = readlinebuffer (thisline[i], streams[i]);
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;
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)
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;
usage (EXIT_FAILURE);
}
- exit (compare_files (argv + optind) == 0
+ exit (compare_files (argv + optind)
? EXIT_SUCCESS : EXIT_FAILURE);
}