X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=ucw%2Fopt-help.c;h=74ea18b2185373c055a91c07b61f1e47bbc44e66;hb=d0dc1d6dd693d9824e82ffd9d987fceac960b9e6;hp=c69c22d360e6f55b498acf0f396360ad01fd36c2;hpb=bdccfb6b49a17a2ac0e1fb3063df3766cd4abd5c;p=libucw.git diff --git a/ucw/opt-help.c b/ucw/opt-help.c index c69c22d3..74ea18b2 100644 --- a/ucw/opt-help.c +++ b/ucw/opt-help.c @@ -30,42 +30,40 @@ 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, 1); - l->extra = item->help ? : ""; + struct help_line *l = GARY_PUSH(h->lines); + l->extra = item->help; return; } if (item->letter >= OPT_POSITIONAL_TAIL) return; - struct help_line *first = GARY_PUSH(h->lines, 1); - 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, 1); + struct help_line *first = 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) { @@ -160,6 +158,7 @@ void opt_help(const struct opt_section * sec) { void opt_handle_help(struct opt_item * opt UNUSED, const char * value UNUSED, void * data) { - opt_help(data); + struct opt_context *oc = data; + opt_help(oc->options); exit(0); }