]> git.draconx.ca Git - dxcommon.git/commitdiff
help_print_desc: Allow NULL option to disable localisation.
authorNick Bowler <nbowler@draconx.ca>
Tue, 23 Nov 2021 02:54:58 +0000 (21:54 -0500)
committerNick Bowler <nbowler@draconx.ca>
Tue, 23 Nov 2021 02:54:58 +0000 (21:54 -0500)
This enables the block-indenting functionality to be used in
other contexts.

src/help.c
src/help.h

index d1dd5f5bc44055bf50a4599b0e1f24cf15ddc0bf..b09833a4a1cbd3e0a48e2a436cb087876128dcd7 100644 (file)
@@ -179,7 +179,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);
 
index 9eb26540a19d4139d91a8024a71367e3db391f5c..a78bc59c0b6fc48953d8e556a12d0b8ef34bc3c1 100644 (file)
@@ -23,10 +23,11 @@ struct option;
 int help_print_optstring(const struct option *opt, const char *argname, int l);
 
 /*
- * Print an option description with each line indented.  The string is first
- * localized (if NLS is enabled).  The first line will be indented by i-w
- * spaces (to account for the cursor being in some other column), all other
- * lines are indented by i spaces.
+ * Print an option description with each line indented.  If opt is not NULL,
+ * then the string is first localized (if NLS is enabled) via pgettext_expr
+ * with the context set to opt->name.  The first line will be indented by
+ * i-w spaces (to account for the cursor being in some other column), all
+ * other lines are indented by i spaces.
  */
 void help_print_desc(const struct option *opt, const char *desc, int i, int w);