diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-07-24 16:40:16 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-07-24 16:40:16 +0300 |
commit | e69ab24c0b739be78fdc2e3e0bb17cee98cb19b1 (patch) | |
tree | ae23008c80c4eccc027bddf0767babdf6f5fd1d1 /src | |
parent | 1e0b3f4556f88013a2268bb2ef0c8d4bfaa40f90 (diff) | |
download | gdbm-e69ab24c0b739be78fdc2e3e0bb17cee98cb19b1.tar.gz gdbm-e69ab24c0b739be78fdc2e3e0bb17cee98cb19b1.tar.bz2 |
Fix handling of group headers in --help output.
* src/parseopt.c (print_option_descr): Return if descr is NULL
or empty. Translate it using gettext.
All callers changed.
Diffstat (limited to 'src')
-rw-r--r-- | src/parseopt.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/parseopt.c b/src/parseopt.c index a51fc04..27b3362 100644 --- a/src/parseopt.c +++ b/src/parseopt.c @@ -142,7 +142,7 @@ add_options (struct gdbm_option *options) { option_max = option_count + count + 1; option_tab = erealloc (option_tab, - sizeof (option_tab[0]) * option_max); + sizeof (option_tab[0]) * option_max); } #ifdef HAVE_GETOPT_LONG @@ -223,6 +223,9 @@ indent (size_t start, size_t col) static void print_option_descr (const char *descr, size_t lmargin, size_t rmargin) { + if (!(descr && descr[0])) + return; + descr = gettext (descr); while (*descr) { size_t s = 0; @@ -269,11 +272,8 @@ print_option (size_t num) if (IS_GROUP_HEADER (opt)) { - if (num) - putchar ('\n'); indent (0, GROUPCOLUMN); - print_option_descr (gettext (opt->opt_descr), - GROUPCOLUMN, RMARGIN); + print_option_descr (opt->opt_descr, GROUPCOLUMN, RMARGIN); putchar ('\n'); return num + 1; } @@ -333,7 +333,7 @@ print_option (size_t num) w = 0; } indent (w, DESCRCOLUMN); - print_option_descr (gettext (opt->opt_descr), DESCRCOLUMN, RMARGIN); + print_option_descr (opt->opt_descr, DESCRCOLUMN, RMARGIN); return next; } @@ -349,8 +349,7 @@ parseopt_print_help (void) parseopt_program_name ? parseopt_program_name : progname, _("OPTION"), gettext (parseopt_program_args)); - if (parseopt_program_doc) - print_option_descr (gettext (parseopt_program_doc), 0, RMARGIN); + print_option_descr (parseopt_program_doc, 0, RMARGIN); putchar ('\n'); sort_all_options (); @@ -362,7 +361,7 @@ parseopt_print_help (void) #ifdef HAVE_GETOPT_LONG if (argsused) { - print_option_descr (_("Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options."), 0, RMARGIN); + print_option_descr (N_("Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options."), 0, RMARGIN); putchar ('\n'); } #endif |