summaryrefslogtreecommitdiff
path: root/src/od.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/od.c
parent19272693f57193a57e5c4c66f65c791b2ee97378 (diff)
downloadcoreutils-2ff4fc16721b6caac08c16c851024b51b16a1824.tar.xz
add --version and --help
Diffstat (limited to 'src/od.c')
-rw-r--r--src/od.c26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/od.c b/src/od.c
index 20476831a..f79b3cce3 100644
--- a/src/od.c
+++ b/src/od.c
@@ -37,6 +37,7 @@ char *alloca ();
#include <getopt.h>
#include <sys/types.h>
#include "system.h"
+#include "version.h"
#if defined(__GNUC__) || defined(STDC_HEADERS)
#include <float.h>
@@ -138,6 +139,9 @@ struct tspec
char *fmt_string;
};
+/* The name this program was run with. */
+char *program_name;
+
/* Convert the number of 8-bit bytes of a binary representation to
the number of characters (digits + sign if the type is signed)
required to represent the same quantity in the specified base/type.
@@ -267,6 +271,12 @@ static enum size_spec integral_type_size[MAX_INTEGRAL_TYPE_SIZE + 1];
#define MAX_FP_TYPE_SIZE sizeof(LONG_DOUBLE)
static enum size_spec fp_type_size[MAX_FP_TYPE_SIZE + 1];
+/* 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 long_options[] =
{
/* POSIX options. */
@@ -280,12 +290,11 @@ static struct option const long_options[] =
{"compatible", no_argument, NULL, 'C'},
{"strings", optional_argument, NULL, 's'},
{"width", optional_argument, NULL, 'w'},
+ {"help", no_argument, &flag_help, 1},
+ {"version", no_argument, &flag_version, 1},
{NULL, 0, NULL, 0}
};
-/* The name this program was run with. */
-char *program_name;
-
static void
usage ()
{
@@ -293,7 +302,7 @@ usage ()
Usage: %s [-abcdfhiloxv] [-s[bytes]] [-w[bytes]] [-A radix] [-j bytes]\n\
[-N bytes] [-t type] [--skip-bytes=bytes] [--address-radix=radix]\n\
[--read-bytes=bytes] [--format=type] [--output-duplicates]\n\
- [--strings[=bytes]] [--width[=bytes]] [file...]\n",
+ [--strings[=bytes]] [--width[=bytes]] [--help] [--version] [file...]\n",
program_name);
exit (1);
}
@@ -1659,6 +1668,9 @@ main (argc, argv)
switch (c)
{
+ case 0:
+ break;
+
case 'A':
switch (optarg[0])
{
@@ -1776,6 +1788,12 @@ main (argc, argv)
}
}
+ if (flag_version)
+ fprintf (stderr, "%s\n", version_string);
+
+ if (flag_help)
+ usage ();
+
if (flag_dump_strings && n_specs > 0)
error (2, 0, "no type may be specified when dumping strings");