summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>1999-03-04 05:09:05 +0000
committerJim Meyering <jim@meyering.net>1999-03-04 05:09:05 +0000
commit61fa70ac19d9202f6509e97e4bda1f4ab8f5d1fd (patch)
tree1fb89b9b511548ea40a899b6c60f1371cf6123f4 /src/du.c
parentd0bdbe00ba72224915a61589a399bc0e86d74d80 (diff)
downloadcoreutils-61fa70ac19d9202f6509e97e4bda1f4ab8f5d1fd.tar.xz
Include long-options.h
[long_options]: Remove the "help" and "version" entries. (main): Use parse_long_options, including author name(s). Remove the show_version and show_help blocks.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c42
1 files changed, 14 insertions, 28 deletions
diff --git a/src/du.c b/src/du.c
index be8c227cb..dfa4bd5a6 100644
--- a/src/du.c
+++ b/src/du.c
@@ -51,14 +51,15 @@
#include <sys/types.h>
#include <assert.h>
-#include "exclude.h"
#include "system.h"
-#include "save-cwd.h"
#include "closeout.h"
#include "error.h"
+#include "exclude.h"
#include "human.h"
-#include "xstrtol.h"
+#include "long-options.h"
+#include "save-cwd.h"
#include "savedir.h"
+#include "xstrtol.h"
/* Initial number of entries in each hash table entry's table of inodes. */
#define INITIAL_HASH_MODULE 100
@@ -163,12 +164,6 @@ static int (*xstat) ();
/* The exit status to use if we don't get any fatal errors. */
static int exit_status;
-/* If nonzero, display usage information and exit. */
-static int show_help;
-
-/* If nonzero, print the version on standard output and exit. */
-static int show_version;
-
/* File name patterns to exclude. */
static struct exclude *exclude;
@@ -194,18 +189,12 @@ static struct option const long_options[] =
{"separate-dirs", no_argument, NULL, 'S'},
{"summarize", no_argument, NULL, 's'},
{"total", no_argument, NULL, 'c'},
- {"help", no_argument, &show_help, 1},
- {"version", no_argument, &show_version, 1},
{NULL, 0, NULL, 0}
};
void
-usage (int status, char *reason)
+usage (int status)
{
- if (reason != NULL)
- fprintf (status == 0 ? stdout : stderr, "%s: %s\n",
- program_name, reason);
-
if (status != 0)
fprintf (stderr, _("Try `%s --help' for more information.\n"),
program_name);
@@ -262,6 +251,10 @@ main (int argc, char **argv)
bindtextdomain (PACKAGE, LOCALEDIR);
textdomain (PACKAGE);
+ parse_long_options (argc, argv, "du", GNU_PACKAGE, VERSION,
+ "Torbjorn Granlund, David MacKenzie, Larry McVoy, and Paul Eggert",
+ usage);
+
exclude = new_exclude ();
xstat = lstat;
@@ -351,23 +344,16 @@ main (int argc, char **argv)
break;
default:
- usage (1, (char *) 0);
+ usage (1);
}
}
- if (show_version)
+ if (opt_all && opt_summarize_only)
{
- printf ("du (%s) %s\n", GNU_PACKAGE, VERSION);
- close_stdout ();
- exit (0);
+ error (0, 0, _("cannot both summarize and show all entries"));
+ usage (1);
}
- if (show_help)
- usage (0, NULL);
-
- if (opt_all && opt_summarize_only)
- usage (1, _("cannot both summarize and show all entries"));
-
if (opt_summarize_only && max_depth_specified && max_depth == 0)
{
error (0, 0,
@@ -379,7 +365,7 @@ main (int argc, char **argv)
error (0, 0,
_("warning: summarizing conflicts with --max-depth=%d"),
max_depth);
- usage (1, NULL);
+ usage (1);
}
if (opt_summarize_only)