+ /* Indent description. */
+ p = opt->desc;
+ while ((l = consume_words(p, width - indent, &prefix, &start)) != 0) {
+ if (!same_line)
+ base = add_indent(base, len, max, indent);
+ p += prefix;
+ base = add_str_len(base, len, max, p, l);
+ base = add_str(base, len, max, "\n");
+ off = indent + l;
+ p += l;
+ same_line = false;
+ }
+
+ /* Empty description? Make it match normal case. */
+ if (same_line)
+ base = add_str(base, len, max, "\n");
+
+ if (opt->show) {
+ char buf[OPT_SHOW_LEN + sizeof("...")];
+ strcpy(buf + OPT_SHOW_LEN, "...");
+ if (opt->show(buf, OPT_SHOW_LEN, opt->u.arg)) {
+ /* If it doesn't fit on this line, indent. */
+ if (off + strlen(" (default: ") + strlen(buf) + strlen(")")
+ > width) {
+ base = add_indent(base, len, max, indent);
+ } else {
+ /* Remove \n. */
+ (*len)--;
+ }
+
+ base = add_str(base, len, max, " (default: ");
+ base = add_str(base, len, max, buf);
+ base = add_str(base, len, max, ")\n");
+ }
+ }
+ return base;
+}
+
+char *opt_usage(const char *argv0, const char *extra)
+{
+ unsigned int i;
+ size_t max, len, width, indent;
+ char *ret;
+
+ width = get_columns();
+ if (width < MIN_TOTAL_WIDTH)
+ width = MIN_TOTAL_WIDTH;
+
+ /* Figure out longest option. */
+ indent = 0;