diff options
author | Jim Meyering <jim@meyering.net> | 1993-04-29 05:26:22 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1993-04-29 05:26:22 +0000 |
commit | 2ff4fc16721b6caac08c16c851024b51b16a1824 (patch) | |
tree | 34d2aba87f63f370d03812e5c8660c2e84b3908e /src/join.c | |
parent | 19272693f57193a57e5c4c66f65c791b2ee97378 (diff) | |
download | coreutils-2ff4fc16721b6caac08c16c851024b51b16a1824.tar.xz |
add --version and --help
Diffstat (limited to 'src/join.c')
-rw-r--r-- | src/join.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/src/join.c b/src/join.c index 6aac838a8..39599efaf 100644 --- a/src/join.c +++ b/src/join.c @@ -24,6 +24,7 @@ #include <sys/types.h> #include <getopt.h> #include "system.h" +#include "version.h" char *xmalloc (); char *xrealloc (); @@ -66,6 +67,9 @@ struct seq struct line *lines; }; +/* The name this program was run with. */ +char *program_name; + /* If nonzero, print unpairable lines in file 1 or 2. */ static int print_unpairables_1, print_unpairables_2; @@ -89,8 +93,23 @@ static struct outlist *outlist_end; tab character. */ static char tab; -/* The name this program was run with. */ -char *program_name; +/* If non-zero, display usage information and exit. */ +static int flag_help; + +/* If non-zero, print the version on standard error. */ +static int flag_version; + +/* When using getopt_long_only, no long option can start with + a character that is a short option. */ +static struct option const longopts[] = +{ + {"j", required_argument, NULL, 'j'}, + {"j1", required_argument, NULL, '1'}, + {"j2", required_argument, NULL, '2'}, + {"help", no_argument, &flag_help, 1}, + {"version", no_argument, &flag_version, 1}, + {NULL, 0, NULL, 0} +}; /* Fill in the `fields' structure in LINE. */ @@ -546,16 +565,6 @@ add_field_list (str) return added; } -/* When using getopt_long_only, no long option can start with - a character that is a short option. */ -static struct option const longopts[] = -{ - {"j", required_argument, NULL, 'j'}, - {"j1", required_argument, NULL, '1'}, - {"j2", required_argument, NULL, '2'}, - {NULL, 0, NULL, 0} -}; - void main (argc, argv) int argc; @@ -574,6 +583,9 @@ main (argc, argv) { switch (optc) { + case 0: + break; + case 'a': val = atoi (optarg); if (val == 1) @@ -647,6 +659,12 @@ main (argc, argv) } prev_optc = optc; } + + if (flag_version) + fprintf (stderr, "%s\n", version_string); + + if (flag_help) + usage (); if (nfiles != 2) usage (); |