X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=parse-options.c;h=fca7159646c82cb9213e72afd94d8debc6bd4c51;hb=69f8d44d387b0a4ceb005486aa7baac5e47097f7;hp=0dd9fc6a0dd0a518200d9bbd834decb3c3ee22c6;hpb=638eb4e70189fd13ad9a44c514bb16dbcdf829a7;p=git-core%2Fgit.git diff --git a/parse-options.c b/parse-options.c index 0dd9fc6a0..fca715964 100644 --- a/parse-options.c +++ b/parse-options.c @@ -581,6 +581,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx, const struct option *opts, int full, int err) { FILE *outfile = err ? stderr : stdout; + int need_newline; if (!usagestr) return PARSE_OPT_HELP; @@ -599,12 +600,11 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx, if (**usagestr) fprintf_ln(outfile, _(" %s"), _(*usagestr)); else - putchar('\n'); + fputc('\n', outfile); usagestr++; } - if (opts->type != OPTION_GROUP) - fputc('\n', outfile); + need_newline = 1; for (; opts->type != OPTION_END; opts++) { size_t pos; @@ -612,6 +612,7 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx, if (opts->type == OPTION_GROUP) { fputc('\n', outfile); + need_newline = 0; if (*opts->help) fprintf(outfile, "%s\n", _(opts->help)); continue; @@ -619,6 +620,11 @@ static int usage_with_options_internal(struct parse_opt_ctx_t *ctx, if (!full && (opts->flags & PARSE_OPT_HIDDEN)) continue; + if (need_newline) { + fputc('\n', outfile); + need_newline = 0; + } + pos = fprintf(outfile, " "); if (opts->short_name) { if (opts->flags & PARSE_OPT_NODASH)