summaryrefslogtreecommitdiff
path: root/src/unexpand.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1993-04-29 05:26:22 +0000
committerJim Meyering <jim@meyering.net>1993-04-29 05:26:22 +0000
commit2ff4fc16721b6caac08c16c851024b51b16a1824 (patch)
tree34d2aba87f63f370d03812e5c8660c2e84b3908e /src/unexpand.c
parent19272693f57193a57e5c4c66f65c791b2ee97378 (diff)
downloadcoreutils-2ff4fc16721b6caac08c16c851024b51b16a1824.tar.xz
add --version and --help
Diffstat (limited to 'src/unexpand.c')
-rw-r--r--src/unexpand.c24
1 files changed, 21 insertions, 3 deletions
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 <getopt.h>
#include <sys/types.h>
#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);
}