From 2ff4fc16721b6caac08c16c851024b51b16a1824 Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 29 Apr 1993 05:26:22 +0000 Subject: add --version and --help --- src/unexpand.c | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) (limited to 'src/unexpand.c') diff --git a/src/unexpand.c b/src/unexpand.c index 01dc41762..6fc5e78f1 100644 --- a/src/unexpand.c +++ b/src/unexpand.c @@ -42,6 +42,7 @@ #include #include #include "system.h" +#include "version.h" /* The number of bytes added at a time to the amount of memory allocated for the output line. */ @@ -62,6 +63,9 @@ static void unexpand (); static void usage (); static void validate_tabstops (); +/* The name this program was run with. */ +char *program_name; + /* If nonzero, convert blanks even after nonblank characters have been read on the line. */ static int convert_entire_line; @@ -93,13 +97,18 @@ static int have_read_stdin; /* Status to return to the system. */ static int exit_status; -/* 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; static struct option const longopts[] = { {"tabs", required_argument, NULL, 't'}, {"all", no_argument, NULL, 'a'}, + {"help", no_argument, &flag_help, 1}, + {"version", no_argument, &flag_version, 1}, {NULL, 0, NULL, 0} }; @@ -123,6 +132,9 @@ main (argc, argv) { switch (c) { + case 0: + break; + case '?': usage (); case 'a': @@ -144,6 +156,12 @@ main (argc, argv) } } + if (flag_version) + fprintf (stderr, "%s\n", version_string); + + if (flag_help) + usage (); + add_tabstop (tabval); validate_tabstops (tab_list, first_free_tab); @@ -418,7 +436,7 @@ usage () { fprintf (stderr, "\ Usage: %s [-tab1[,tab2[,...]]] [-t tab1[,tab2[,...]]] [-a]\n\ - [--tabs=tab1[,tab2[,...]]] [--all] [file...]\n", + [--tabs=tab1[,tab2[,...]]] [--all] [--help] [--version] [file...]\n", program_name); exit (1); } -- cgit v1.2.3-54-g00ecf