From 0cd1a8b586cd645fb304556814e496fe075450b2 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 17 Feb 2014 18:12:58 +0100 Subject: [PATCH] Opt: OPT_NO_HELP is gone --- ucw/opt-help.c | 46 ++++++++++++++++++++++------------------------ ucw/opt.h | 3 +-- 2 files changed, 23 insertions(+), 26 deletions(-) diff --git a/ucw/opt-help.c b/ucw/opt-help.c index 199427d0..74ea18b2 100644 --- a/ucw/opt-help.c +++ b/ucw/opt-help.c @@ -30,12 +30,12 @@ static void opt_help_scan_item(struct help *h, struct opt_precomputed *opt) { struct opt_item *item = opt->item; - if (opt->flags & OPT_NO_HELP) + if (!item->help) return; if (item->cls == OPT_CL_HELP) { struct help_line *l = GARY_PUSH(h->lines); - l->extra = item->help ? : ""; + l->extra = item->help; return; } @@ -43,29 +43,27 @@ static void opt_help_scan_item(struct help *h, struct opt_precomputed *opt) return; struct help_line *first = GARY_PUSH(h->lines); - if (item->help) { - char *text = mp_strdup(h->pool, item->help); - struct help_line *l = first; - while (text) { - char *eol = strchr(text, '\n'); - if (eol) - *eol++ = 0; - - int field = (l == first ? 1 : 0); - char *f = text; - while (f) { - char *tab = strchr(f, '\t'); - if (tab) - *tab++ = 0; - if (field < 3) - l->fields[field++] = f; - f = tab; - } - - text = eol; - if (text) - l = GARY_PUSH(h->lines); + char *text = mp_strdup(h->pool, item->help); + struct help_line *l = first; + while (text) { + char *eol = strchr(text, '\n'); + if (eol) + *eol++ = 0; + + int field = (l == first ? 1 : 0); + char *f = text; + while (f) { + char *tab = strchr(f, '\t'); + if (tab) + *tab++ = 0; + if (field < 3) + l->fields[field++] = f; + f = tab; } + + text = eol; + if (text) + l = GARY_PUSH(h->lines); } if (item->name) { diff --git a/ucw/opt.h b/ucw/opt.h index 5eae050e..cdc6a0aa 100644 --- a/ucw/opt.h +++ b/ucw/opt.h @@ -100,7 +100,7 @@ struct opt_item { const char * name; // long name (NULL if none) int letter; // short name (0 if none) void * ptr; // variable to store the value to - const char * help; // description in --help + const char * help; // description in --help (NULL to omit the option from the help) union opt_union { struct opt_section * section; // subsection for OPT_CL_SECTION int value; // value for OPT_CL_SWITCH @@ -126,7 +126,6 @@ struct opt_item { #define OPT_NO_VALUE 0x4 /** The option must have no value. **/ #define OPT_MAYBE_VALUE 0x8 /** The option may have a value. **/ #define OPT_NEGATIVE 0x10 /** Reversing the effect of OPT_INC or saving @false into OPT_BOOL. **/ -#define OPT_NO_HELP 0x20 /** Exclude this option from the help. **/ #define OPT_LAST_ARG 0x40 /** Stop processing arguments after this line. **/ #define OPT_SINGLE 0x100 /** The option must appear at most once. **/ #define OPT_MULTIPLE 0x200 /** The option may appear multiple times; will save all the values into a simple list. **/ -- 2.39.2