]> git.draconx.ca Git - dxcommon.git/blobdiff - src/help.c
Add a dedicated function to emit the copyright symbol.
[dxcommon.git] / src / help.c
index ea817e84ae47e485bfd9425d50510782a5da5294..f96025f1298fdcad10c29953d64cd92aef0da7bb 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright © 2021 Nick Bowler
+ * Copyright © 2021-2023 Nick Bowler
  *
  * Helper functions for formatting --help program output.
  *
  */
 static int option_type(const struct option *opt)
 {
-       return ((opt->val <= CHAR_MAX) << 2) | (opt->has_arg & 3);
+       int ret = opt->has_arg & 3;
+
+       if (!opt->flag)
+               ret |= (opt->val <= CHAR_MAX) << 2;
+
+       return ret;
 }
 
 enum {
@@ -183,6 +188,9 @@ void help_print_desc(const struct option *opt, const char *s, int i, int w)
        if (opt)
                s = pgettext_expr(opt->name, s);
 
+       if (i && s[0] == '\0')
+               putchar('\n');
+
        for (; *s; w = 0) {
                const char *nl = strchr(s, '\n');
                int n = (nl ? nl-s : -1);