summaryrefslogtreecommitdiff
path: root/libshouldbeinlibc/argp-help.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-02-12 06:32:07 +0000
committerMiles Bader <miles@gnu.org>1997-02-12 06:32:07 +0000
commit17d7a1d9760b9a7625ff1431fd9f90725b6ba8a3 (patch)
treeb4e0bb7d4803f07a3266b4c1592c9c41d298d205 /libshouldbeinlibc/argp-help.c
parent09652e54f851c293a6aa8f13080c1bca59e0782a (diff)
(argp_args_usage): Don't trash memory.
Diffstat (limited to 'libshouldbeinlibc/argp-help.c')
-rw-r--r--libshouldbeinlibc/argp-help.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/libshouldbeinlibc/argp-help.c b/libshouldbeinlibc/argp-help.c
index fb0a7481..831bd9d5 100644
--- a/libshouldbeinlibc/argp-help.c
+++ b/libshouldbeinlibc/argp-help.c
@@ -1030,6 +1030,7 @@ argp_args_usage (const struct argp *argp, char **levels, int advance,
argp_fmtstream_t stream)
{
char *our_level = *levels;
+ int multiple = 0;
const struct argp_child *child = argp->children;
const char *doc = argp->args_doc, *nl = 0;
@@ -1041,6 +1042,7 @@ argp_args_usage (const struct argp *argp, char **levels, int advance,
as determined by our state in LEVELS, and update LEVELS. */
{
int i;
+ multiple = 1;
for (i = 0; i < *our_level; i++)
doc = nl + 1, nl = strchr (doc, '\n');
(*levels)++;
@@ -1063,9 +1065,9 @@ argp_args_usage (const struct argp *argp, char **levels, int advance,
while (child->argp)
advance = !argp_args_usage ((child++)->argp, levels, advance, stream);
- if (advance)
+ if (advance && multiple)
/* Need to increment our level. */
- if (nl && *nl)
+ if (*nl)
/* There's more we can do here. */
{
(*our_level)++;