X-Git-Url: https://git.draconx.ca/gitweb/dxcommon.git/blobdiff_plain/0567de2636ff0ed0a9dc378cdbd82e0bb7dce788..e1ebfe7f258c1c99006fee8a3b6e111dc1d34d79:/src/help.c?ds=sidebyside diff --git a/src/help.c b/src/help.c index d1dd5f5..43bb266 100644 --- a/src/help.c +++ b/src/help.c @@ -1,5 +1,5 @@ /* - * Copyright © 2021 Nick Bowler + * Copyright © 2021-2022 Nick Bowler * * Helper functions for formatting --help program output. * @@ -28,6 +28,7 @@ #endif #if ENABLE_NLS +# include # include # include #else @@ -50,7 +51,12 @@ */ 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 { @@ -179,7 +185,10 @@ out: void help_print_desc(const struct option *opt, const char *s, int i, int w) { - for (s = pgettext_expr(opt->name, s); *s; w = 0) { + if (opt) + s = pgettext_expr(opt->name, s); + + for (; *s; w = 0) { const char *nl = strchr(s, '\n'); int n = (nl ? nl-s : -1);