summaryrefslogtreecommitdiff
path: root/src/du.c
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2007-08-04 13:36:59 +0200
committerJim Meyering <jim@meyering.net>2007-08-04 13:36:59 +0200
commit8188c3b48ded8b53d88440f0736690d2e30508ed (patch)
treeb36bbe8ed28eaa4dc37c9876cc5f71a520bb9fdd /src/du.c
parent33f95a9ab62968a6b13eb1a6a71f180f61721f71 (diff)
downloadcoreutils-8188c3b48ded8b53d88440f0736690d2e30508ed.tar.xz
Adapt to new human and xstrtol API.
* src/df.c (long_options): Prepend "--" to long options that OPT_STR might decode. * src/du.c (long_options): Likewise. * src/od.c (long_options): Likewise. * src/sort.c (long_options): Likewise. * src/df.c (main): Adjust to new human and xstrtol API. * src/du.c (main): Likewise. * src/ls.c (decode_switches): Likewise. * src/od.c (main): Likewise. * src/pr.c (first_last_page): Likewise. New argument OPTION. All callers changed. * src/sort.c (specify_sort_size): New arg OPTION. All callers changed. Adjust to new xstrtol API. * src/system.h (opt_str_storage): New static var. (OPT_STR, LONG_OPT_STR, OPT_STR_INIT): New macros.
Diffstat (limited to 'src/du.c')
-rw-r--r--src/du.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/du.c b/src/du.c
index f9bd2e364..caacbb0bd 100644
--- a/src/du.c
+++ b/src/du.c
@@ -204,7 +204,7 @@ static struct option const long_options[] =
{
{"all", no_argument, NULL, 'a'},
{"apparent-size", no_argument, NULL, APPARENT_SIZE_OPTION},
- {"block-size", required_argument, NULL, 'B'},
+ {OPT_STR_INIT ("block-size"), required_argument, NULL, 'B'},
{"bytes", no_argument, NULL, 'b'},
{"count-links", no_argument, NULL, 'l'},
{"dereference", no_argument, NULL, 'L'},
@@ -661,7 +661,6 @@ du_files (char **files, int bit_flags)
int
main (int argc, char **argv)
{
- int c;
char *cwd_only[2];
bool max_depth_specified = false;
char **files;
@@ -692,12 +691,17 @@ main (int argc, char **argv)
exclude = new_exclude ();
- human_output_opts = human_options (getenv ("DU_BLOCK_SIZE"), false,
- &output_block_size);
+ human_options (getenv ("DU_BLOCK_SIZE"),
+ &human_output_opts, &output_block_size);
- while ((c = getopt_long (argc, argv, DEBUG_OPT "0abchHklmsxB:DLPSX:",
- long_options, NULL)) != -1)
+ for (;;)
{
+ int oi = -1;
+ int c = getopt_long (argc, argv, DEBUG_OPT "0abchHklmsxB:DLPSX:",
+ long_options, &oi);
+ if (c == -1)
+ break;
+
switch (c)
{
#if DU_DEBUG
@@ -788,7 +792,12 @@ main (int argc, char **argv)
break;
case 'B':
- human_output_opts = human_options (optarg, true, &output_block_size);
+ {
+ enum strtol_error e = human_options (optarg, &human_output_opts,
+ &output_block_size);
+ if (e != LONGINT_OK)
+ STRTOL_FATAL_ERROR (OPT_STR (oi, c, long_options), optarg, e);
+ }
break;
case 'D': /* This will eventually be 'H' (-H), too. */