From 17d7a1d9760b9a7625ff1431fd9f90725b6ba8a3 Mon Sep 17 00:00:00 2001 From: Miles Bader Date: Wed, 12 Feb 1997 06:32:07 +0000 Subject: (argp_args_usage): Don't trash memory. --- libshouldbeinlibc/argp-help.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'libshouldbeinlibc/argp-help.c') 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)++; -- cgit v1.2.3