diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2007-08-04 13:36:59 +0200 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2007-08-04 13:36:59 +0200 |
commit | 8188c3b48ded8b53d88440f0736690d2e30508ed (patch) | |
tree | b36bbe8ed28eaa4dc37c9876cc5f71a520bb9fdd /src/df.c | |
parent | 33f95a9ab62968a6b13eb1a6a71f180f61721f71 (diff) | |
download | coreutils-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/df.c')
-rw-r--r-- | src/df.c | 23 |
1 files changed, 16 insertions, 7 deletions
@@ -121,7 +121,7 @@ enum static struct option const long_options[] = { {"all", no_argument, NULL, 'a'}, - {"block-size", required_argument, NULL, 'B'}, + {OPT_STR_INIT ("block-size"), required_argument, NULL, 'B'}, {"inodes", no_argument, NULL, 'i'}, {"human-readable", no_argument, NULL, 'h'}, {"si", no_argument, NULL, 'H'}, @@ -776,7 +776,6 @@ kB 1000, K 1024, MB 1000*1000, M 1024*1024, and so on for G, T, P, E, Z, Y.\n\ int main (int argc, char **argv) { - int c; struct stat *stats IF_LINT (= 0); initialize_main (&argc, &argv); @@ -798,16 +797,26 @@ main (int argc, char **argv) posix_format = false; exit_status = EXIT_SUCCESS; - while ((c = getopt_long (argc, argv, "aB:iF:hHklmPTt:vx:", long_options, NULL)) - != -1) + for (;;) { + int oi = -1; + int c = getopt_long (argc, argv, "aB:iF:hHklmPTt:vx:", long_options, + &oi); + if (c == -1) + break; + switch (c) { case 'a': show_all_fs = true; 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 'i': inode_format = true; @@ -873,8 +882,8 @@ main (int argc, char **argv) output_block_size = (getenv ("POSIXLY_CORRECT") ? 512 : 1024); } else - human_output_opts = human_options (getenv ("DF_BLOCK_SIZE"), false, - &output_block_size); + human_options (getenv ("DF_BLOCK_SIZE"), + &human_output_opts, &output_block_size); } /* Fail if the same file system type was both selected and excluded. */ |