Pierre Habouzit, Sat, Oct 13, 2007 22:54:04 +0200:It is not. Not yet. What could they use a usage text for? Besides, you could just export the callback (call_usage_callback or something) from usage.c and call it. on top of yours: From: Alex Riesen <raa.lkml@gmail.com> Date: Sun, 14 Oct 2007 00:10:51 +0200 Subject: [PATCH] Rework make_usage to print the usage message immediately Signed-off-by: Alex Riesen <raa.lkml@gmail.com> --- parse-options.c | 60 ++++++++++++++++++++++++------------------------------ 1 files changed, 27 insertions(+), 33 deletions(-) diff --git a/parse-options.c b/parse-options.c index 07abb50..1e3940f 100644 --- a/parse-options.c +++ b/parse-options.c @@ -1,6 +1,5 @@ #include "git-compat-util.h" #include "parse-options.h" -#include "strbuf.h" #define OPT_SHORT 1 #define OPT_UNSET 2 @@ -171,57 +170,52 @@ int parse_options(int argc, const char **argv, void make_usage(const char * const usagestr[], struct option *opts, int cnt) { - struct strbuf sb; - - strbuf_init(&sb, 4096); - do { - strbuf_addstr(&sb, *usagestr++); - strbuf_addch(&sb, '\n'); - } while (*usagestr); + fprintf(stderr, "usage: "); + while (*usagestr) + fprintf(stderr, "%s\n", *usagestr++); if (cnt && opts->type != OPTION_GROUP) - strbuf_addch(&sb, '\n'); + fputc('\n', stderr); for (; cnt-- > 0; opts++) { size_t pos; if (opts->type == OPTION_GROUP) { - strbuf_addch(&sb, '\n'); + fputc('\n', stderr); if (*opts->help) - strbuf_addf(&sb, "%s\n", opts->help); + fprintf(stderr, "%s\n", opts->help); continue; } - pos = sb.len; - strbuf_addstr(&sb, " "); - if (opts->short_name) { - strbuf_addf(&sb, "-%c", opts->short_name); - } - if (opts->long_name) { - strbuf_addf(&sb, opts->short_name ? ", --%s" : "--%s", - opts->long_name); - } + pos = fprintf(stderr, " "); + if (opts->short_name) + pos += fprintf(stderr, "-%c", opts->short_name); + if (opts->long_name) + pos += fprintf(stderr, + opts->short_name ? ", --%s" : "--%s", + opts->long_name); switch (opts->type) { case OPTION_INTEGER: - strbuf_addstr(&sb, " <n>"); + fputs(" <n>", stderr); + pos += 4; break; case OPTION_STRING: - if (opts->argh) { - strbuf_addf(&sb, " <%s>", opts->argh); - } else { - strbuf_addstr(&sb, " ..."); + if (opts->argh) + pos += fprintf(stderr, " <%s>", opts->argh); + else { + fputs(" ...", stderr); + pos += 4; } break; default: break; } - if (sb.len - pos <= USAGE_OPTS_WIDTH) { - int pad = USAGE_OPTS_WIDTH - (sb.len - pos) + USAGE_GAP; - strbuf_addf(&sb, "%*s%s\n", pad, "", opts->help); - } else { - strbuf_addf(&sb, "\n%*s%s\n", USAGE_OPTS_WIDTH + USAGE_GAP, "", - opts->help); - } + if (pos <= USAGE_OPTS_WIDTH) { + int pad = USAGE_OPTS_WIDTH - pos + USAGE_GAP; + fprintf(stderr, "%*s%s\n", pad, "", opts->help); + } else + fprintf(stderr, "\n%*s%s\n", + USAGE_OPTS_WIDTH + USAGE_GAP, "", opts->help); } - usage(sb.buf); + exit(129); } -- 1.5.3.4.232.ga843 - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
| James Bottomley | Breakage caused by unreviewed patch in x86 tree |
| Andrew Morton | Re: POHMELFS high performance network filesystem. Transactions, failover, performa... |
| Randy Dunlap | Re: 2.6.25-rc5-mm1 (paravirt/vsmp/no PCI) |
| Arnd Hannemann | 2.6.24-rc8 hangs at mfgpt-timer |
| Theodore Ts'o | Re: SVGA-alphanum. modes |
| Joseph R. Pannon | More install questions |
| Paul Richards | Header files |
| Les Andrzejewski | X386/WD90C31/SUMSUNG SYNC MASTER 4 |
git: | |
| David Miller | Re: [BUG] New Kernel Bugs |
| David Miller | Re: iptables very slow after commit784544739a25c30637397ace5489eeb6e15d7d49 |
| Gerrit Renker | [PATCH 27/37] dccp: Integration of dynamic feature activation - part 2 (server side) |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
