- struct opt_item *item = opt->item;
-
- if (opt->flags & OPT_NO_HELP)
- return;
-
- if (item->cls == OPT_CL_HELP) {
- struct help_line *l = GARY_PUSH(h->lines, 1);
- 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);
- }
- }
-
- if (item->name) {
- char *val = first->fields[1] ? : "";
- if (opt->flags & OPT_REQUIRED_VALUE)
- val = mp_printf(h->pool, "=%s", val);
- else if (!(opt->flags & OPT_NO_VALUE))
- val = mp_printf(h->pool, "[=%s]", val);
- first->fields[1] = mp_printf(h->pool, "--%s%s", item->name, val);
- }
-
- if (item->letter) {
- if (item->name)
- first->fields[0] = mp_printf(h->pool, "-%c, ", item->letter);
- else {
- char *val = first->fields[1] ? : "";
- if (!(opt->flags & OPT_REQUIRED_VALUE) && !(opt->flags & OPT_NO_VALUE))
- val = mp_printf(h->pool, "[%s]", val);
- first->fields[0] = mp_printf(h->pool, "-%c%s", item->letter, val);
- first->fields[1] = NULL;
+ for (int i = 0; i < oc->hook_count; i++) {
+ struct opt_item *hook = oc->hooks[i];
+ if (hook->flags & event) {
+ void *data = (hook->flags & OPT_HOOK_INTERNAL) ? oc : hook->ptr;
+ hook->u.hook(item, event, value, data);