summaryrefslogtreecommitdiff
path: root/popthelp.c
diff options
context:
space:
mode:
authorjbj <jbj>2009-01-21 20:14:26 +0000
committerjbj <jbj>2009-01-21 20:14:26 +0000
commit529e1866845a7dc24b29b2b8193fd90793555446 (patch)
tree85df0197f61cec12cd4cec501d7ac336ac94bd77 /popthelp.c
parent3117c302da9fe0c860c65c32e0cc4c16df840373 (diff)
downloadlibpopt-529e1866845a7dc24b29b2b8193fd90793555446.tar.gz
- jbj: fix typo, display toggled long options as "--[no]foo" with --help.
Diffstat (limited to 'popthelp.c')
-rw-r--r--popthelp.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/popthelp.c b/popthelp.c
index fffabd0..fe73b6d 100644
--- a/popthelp.c
+++ b/popthelp.c
@@ -322,6 +322,7 @@ static void singleOptionHelp(FILE * fp, columns_t columns,
/* Make sure there's more than enough room in target buffer. */
if (opt->longName) nb += strlen(opt->longName);
+ if (F_ISSET(opt, TOGGLE)) nb += sizeof("[no]") - 1;
if (argDescrip) nb += strlen(argDescrip);
left = malloc(nb);
@@ -345,7 +346,8 @@ static void singleOptionHelp(FILE * fp, columns_t columns,
/* XXX --long always padded for alignment with/without "-X, ". */
char *dash = poptArgType(opt) == POPT_ARG_MAINCALL ? ""
: (F_ISSET(opt, ONEDASH) ? "-" : "--");
- (void) stpcpy(stpcpy(stpcpy(left, " "), dash), opt->longName);
+ char *toggle = (F_ISSET(opt, TOGGLE) ? "[no]" : "");
+ (void) stpcpy(stpcpy(stpcpy(stpcpy(left, " "), dash), toggle), opt->longName);
}
#undef prtlong