Skip to content

Commit 311c8ff

Browse files
rscharfegitster
authored andcommitted
parse-options: simplify usage_padding()
c512643 (short help: allow a gap smaller than USAGE_GAP, 2023-07-18) effectively did away with the two-space gap between options and their description; one space is enough now. Incorporate USAGE_GAP into USAGE_OPTS_WIDTH, merge the two cases with enough space on the line and incorporate the newline into the format for the remaining case. The output remains the same. Signed-off-by: René Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 2a409a1 commit 311c8ff

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

parse-options.c

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,21 +1025,14 @@ static int usage_indent(FILE *outfile)
10251025
return fprintf(outfile, " ");
10261026
}
10271027

1028-
#define USAGE_OPTS_WIDTH 24
1029-
#define USAGE_GAP 2
1028+
#define USAGE_OPTS_WIDTH 26
10301029

10311030
static void usage_padding(FILE *outfile, size_t pos)
10321031
{
1033-
int pad;
1034-
if (pos == USAGE_OPTS_WIDTH + 1)
1035-
pad = -1;
1036-
else if (pos <= USAGE_OPTS_WIDTH)
1037-
pad = USAGE_OPTS_WIDTH - pos;
1038-
else {
1039-
fputc('\n', outfile);
1040-
pad = USAGE_OPTS_WIDTH;
1041-
}
1042-
fprintf(outfile, "%*s", pad + USAGE_GAP, "");
1032+
if (pos < USAGE_OPTS_WIDTH)
1033+
fprintf(outfile, "%*s", USAGE_OPTS_WIDTH - (int)pos, "");
1034+
else
1035+
fprintf(outfile, "\n%*s", USAGE_OPTS_WIDTH, "");
10431036
}
10441037

10451038
static const struct option *find_option_by_long_name(const struct option *opts,

0 commit comments

Comments
 (0)