{0, 0, 0, 0}
};
-static int compare_files ();
-static void writeline ();
-static void usage ();
\f
-void
-main (argc, argv)
- int argc;
- char *argv[];
-{
- int c;
-
- program_name = argv[0];
-
- only_file_1 = 1;
- only_file_2 = 1;
- both = 1;
-
- while ((c = getopt_long (argc, argv, "123", long_options, (int *) 0)) != EOF)
- switch (c)
- {
- case 0:
- break;
-
- case '1':
- only_file_1 = 0;
- break;
-
- case '2':
- only_file_2 = 0;
- break;
- case '3':
- both = 0;
- break;
+static void
+usage (status)
+ int status;
+{
+ if (status != 0)
+ fprintf (stderr, "Try `%s --help' for more information.\n",
+ program_name);
+ else
+ {
+ printf ("\
+Usage: %s [OPTION]... LEFT_FILE RIGHT_FILE\n\
+",
+ program_name);
+ printf ("\
+Compare sorted files LEFT_FILE and RIGHT_FILE line by line.\n\
+\n\
+ -1 suppress lines unique to left file\n\
+ -2 suppress lines unique to right file\n\
+ -3 suppress lines unique to both files\n\
+ --help display this help and exit\n\
+ --version output version information and exit\n\
+");
+ }
+ exit (status);
+}
- default:
- usage (1);
- }
+/* Output the line in linebuffer LINE to stream STREAM
+ provided the switches say it should be output.
+ CLASS is 1 for a line found only in file 1,
+ 2 for a line only in file 2, 3 for a line in both. */
- if (show_version)
+static void
+writeline (line, stream, class)
+ struct linebuffer *line;
+ FILE *stream;
+ int class;
+{
+ switch (class)
{
- printf ("comm - %s\n", version_string);
- exit (0);
- }
+ case 1:
+ if (!only_file_1)
+ return;
+ break;
- if (show_help)
- usage (0);
+ case 2:
+ if (!only_file_2)
+ return;
+ /* Skip the tab stop for case 1, if we are printing case 1. */
+ if (only_file_1)
+ putc ('\t', stream);
+ break;
- if (optind + 2 != argc)
- usage (1);
+ case 3:
+ if (!both)
+ return;
+ /* Skip the tab stop for case 1, if we are printing case 1. */
+ if (only_file_1)
+ putc ('\t', stream);
+ /* Skip the tab stop for case 2, if we are printing case 2. */
+ if (only_file_2)
+ putc ('\t', stream);
+ break;
+ }
- exit (compare_files (argv + optind));
+ fwrite (line->buffer, sizeof (char), line->length, stream);
+ putc ('\n', stream);
}
-\f
+
/* Compare INFILES[0] and INFILES[1].
If either is "-", use the standard input for that file.
Assume that each input file is sorted;
return ret;
}
-/* Output the line in linebuffer LINE to stream STREAM
- provided the switches say it should be output.
- CLASS is 1 for a line found only in file 1,
- 2 for a line only in file 2, 3 for a line in both. */
-
-static void
-writeline (line, stream, class)
- struct linebuffer *line;
- FILE *stream;
- int class;
+void
+main (argc, argv)
+ int argc;
+ char *argv[];
{
- switch (class)
- {
- case 1:
- if (!only_file_1)
- return;
- break;
+ int c;
- case 2:
- if (!only_file_2)
- return;
- /* Skip the tab stop for case 1, if we are printing case 1. */
- if (only_file_1)
- putc ('\t', stream);
- break;
+ program_name = argv[0];
- case 3:
- if (!both)
- return;
- /* Skip the tab stop for case 1, if we are printing case 1. */
- if (only_file_1)
- putc ('\t', stream);
- /* Skip the tab stop for case 2, if we are printing case 2. */
- if (only_file_2)
- putc ('\t', stream);
- break;
- }
+ only_file_1 = 1;
+ only_file_2 = 1;
+ both = 1;
- fwrite (line->buffer, sizeof (char), line->length, stream);
- putc ('\n', stream);
-}
-\f
-static void
-usage (status)
- int status;
-{
- if (status != 0)
- fprintf (stderr, "Try `%s --help' for more information.\n",
- program_name);
- else
+ while ((c = getopt_long (argc, argv, "123", long_options, (int *) 0)) != EOF)
+ switch (c)
+ {
+ case 0:
+ break;
+
+ case '1':
+ only_file_1 = 0;
+ break;
+
+ case '2':
+ only_file_2 = 0;
+ break;
+
+ case '3':
+ both = 0;
+ break;
+
+ default:
+ usage (1);
+ }
+
+ if (show_version)
{
- printf ("\
-Usage: %s [OPTION]... LEFT_FILE RIGHT_FILE\n\
-",
- program_name);
- printf ("\
-Compare sorted files LEFT_FILE and RIGHT_FILE line by line.\n\
-\n\
- -1 suppress lines unique to left file\n\
- -2 suppress lines unique to right file\n\
- -3 suppress lines unique to both files\n\
- --help display this help and exit\n\
- --version output version information and exit\n\
-");
+ printf ("comm - %s\n", version_string);
+ exit (0);
}
- exit (status);
+
+ if (show_help)
+ usage (0);
+
+ if (optind + 2 != argc)
+ usage (1);
+
+ exit (compare_files (argv + optind));
}