summaryrefslogtreecommitdiff
path: root/src/dirname.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1994-02-13 20:27:08 +0000
committerJim Meyering <jim@meyering.net>1994-02-13 20:27:08 +0000
commite4aba2047ab257bddf475af70f04d15041dd6d70 (patch)
tree793824e9beaba79b04fb0ef4987272e5b0bae3fd /src/dirname.c
parentfd69d39c66214d8d10aa7f6a908b524b84014dca (diff)
downloadcoreutils-e4aba2047ab257bddf475af70f04d15041dd6d70.tar.xz
.
Diffstat (limited to 'src/dirname.c')
-rw-r--r--src/dirname.c42
1 files changed, 4 insertions, 38 deletions
diff --git a/src/dirname.c b/src/dirname.c
index b615ba13d..a0345be7a 100644
--- a/src/dirname.c
+++ b/src/dirname.c
@@ -30,29 +30,15 @@
#include <stdio.h>
#include <sys/types.h>
-#include <getopt.h>
-#include "version.h"
#include "system.h"
+#include "long-options.h"
void strip_trailing_slashes ();
/* The name this program was run with. */
char *program_name;
-/* If non-zero, display usage information and exit. */
-static int show_help;
-
-/* If non-zero, print the version on standard output and exit. */
-static int show_version;
-
-static struct option const long_options[] =
-{
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
- {0, 0, 0, 0}
-};
-
static void
usage (status)
int status;
@@ -79,35 +65,15 @@ main (argc, argv)
{
register char *path;
register char *slash;
- int c;
program_name = argv[0];
- while ((c = getopt_long (argc, argv, "", long_options, (int *) 0)) != EOF)
- {
- switch (c)
- {
- case 0:
- break;
-
- default:
- usage (1);
- }
- }
-
- if (show_version)
- {
- printf ("%s\n", version_string);
- exit (0);
- }
-
- if (show_help)
- usage (0);
+ parse_long_options (argc, argv, usage);
- if (argc - optind != 1)
+ if (argc != 2)
usage (1);
- path = argv[optind];
+ path = argv[1];
strip_trailing_slashes (path);
slash = rindex (path, '/');