From 529e1866845a7dc24b29b2b8193fd90793555446 Mon Sep 17 00:00:00 2001 From: jbj Date: Wed, 21 Jan 2009 20:14:26 +0000 Subject: - jbj: fix typo, display toggled long options as "--[no]foo" with --help. --- popthelp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'popthelp.c') 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 -- cgit v1.2.1