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/system.h | |
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/system.h')
-rw-r--r-- | src/system.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/system.h b/src/system.h index 3c7f49d10..cc97f2fec 100644 --- a/src/system.h +++ b/src/system.h @@ -592,3 +592,20 @@ emit_bug_reporting_address (void) bugs (typically your translation team's web or email address). */ printf (_("\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT); } + +/* Use OPT_IDX to decide whether to return either a short option + string "-C", or a long option string derived from LONG_OPTION. + OPT_IDX is -1 if the short option C was used; otherwise it is an + index into LONG_OPTIONS, which should have a name preceded by two + '-' characters. */ +static char opt_str_storage[3] = {'-', 0, 0}; +#define OPT_STR(opt_idx, c, long_options) \ + ((opt_idx) < 0 \ + ? (opt_str_storage[1] = c, opt_str_storage) \ + : LONG_OPT_STR (opt_idx, long_options)) + +/* Likewise, but assume OPT_IDX is nonnegative. */ +#define LONG_OPT_STR(opt_idx, long_options) ((long_options)[opt_idx].name - 2) + +/* Define an option string that will be used with OPT_STR or LONG_OPT_STR. */ +#define OPT_STR_INIT(name) ("--" name + 2) |