diff options
author | Miles Bader <miles@gnu.org> | 1997-02-21 18:52:10 +0000 |
---|---|---|
committer | Miles Bader <miles@gnu.org> | 1997-02-21 18:52:10 +0000 |
commit | 6ea644900d88a274736a088e8bb70d136cc45d21 (patch) | |
tree | 48169a42502cb7a760a766dc3175097f11ef0ac0 | |
parent | 2fbb9422d15efea6a7d7061d2f75dd5c5b1e169b (diff) |
(usage_long_opt, usage_argful_short_opt, add_argless_short_opt):
Implement OPTION_NO_USAGE.
-rw-r--r-- | libshouldbeinlibc/argp-help.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/libshouldbeinlibc/argp-help.c b/libshouldbeinlibc/argp-help.c index a4941464..b7568b56 100644 --- a/libshouldbeinlibc/argp-help.c +++ b/libshouldbeinlibc/argp-help.c @@ -1155,7 +1155,8 @@ add_argless_short_opt (const struct argp_option *opt, void *cookie) { char **snao_end = cookie; - if (! (opt->arg || real->arg)) + if (!(opt->arg || real->arg) + && !((opt->flags | real->flags) & OPTION_NO_USAGE)) *(*snao_end)++ = opt->key; return 0; } @@ -1169,15 +1170,16 @@ usage_argful_short_opt (const struct argp_option *opt, { argp_fmtstream_t stream = cookie; const char *arg = opt->arg; + int flags = opt->flags | real->flags; if (! arg) arg = real->arg; - if (arg) + if (arg && !(flags & OPTION_NO_USAGE)) { arg = gettext (arg); - if ((opt->flags | real->flags) & OPTION_ARG_OPTIONAL) + if (flags & OPTION_ARG_OPTIONAL) __argp_fmtstream_printf (stream, " [-%c[%s]]", opt->key, arg); else { @@ -1200,20 +1202,22 @@ usage_long_opt (const struct argp_option *opt, { argp_fmtstream_t stream = cookie; const char *arg = opt->arg; + int flags = opt->flags | real->flags; if (! arg) arg = real->arg; - if (arg) - { - arg = gettext (arg); - if ((opt->flags | real->flags) & OPTION_ARG_OPTIONAL) - __argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg); - else - __argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg); - } - else - __argp_fmtstream_printf (stream, " [--%s]", opt->name); + if (! (flags & OPTION_NO_USAGE)) + if (arg) + { + arg = gettext (arg); + if (flags & OPTION_ARG_OPTIONAL) + __argp_fmtstream_printf (stream, " [--%s[=%s]]", opt->name, arg); + else + __argp_fmtstream_printf (stream, " [--%s=%s]", opt->name, arg); + } + else + __argp_fmtstream_printf (stream, " [--%s]", opt->name); return 0; } |