This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] argp: argp.doc prints incorrectly when it starts with "\v" [BZ #19038]
- From: Girish Joshi <girish946 at gmail dot com>
- To: libc-alpha at sourceware dot org
- Date: Mon, 6 May 2019 04:55:33 -0400
- Subject: [PATCH] argp: argp.doc prints incorrectly when it starts with "\v" [BZ #19038]
In argp-help.c `char *vt` is being initialized only once. It needs to
be initialized for every child in the doc and it needs to be printed
only in two cases.
1. There are no children and the doc does not starts with '\v'.
2. Argument `first_only` to the function `argp_doc` is false and the
complete doc needs to be printed.
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 3b1727c4aa..ee4d247824 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -1465,10 +1465,11 @@ argp_doc (const struct argp *argp, const
struct argp_state *state,
size_t inp_text_limit = 0;
const char *doc = dgettext (argp->argp_domain, argp->doc);
const struct argp_child *child = argp->children;
+ char *vt = 0;
if (doc)
{
- char *vt = strchr (doc, '\v');
+ vt = strchr (doc, '\v');
inp_text = post ? (vt ? vt + 1 : 0) : doc;
inp_text_limit = (!post && vt) ? (vt - doc) : 0;
}
@@ -1498,8 +1499,11 @@ argp_doc (const struct argp *argp, const struct
argp_state *state,
if (text == inp_text && inp_text_limit)
__argp_fmtstream_write (stream, inp_text, inp_text_limit);
- else
- __argp_fmtstream_puts (stream, text);
+ else{
+ if((!vt && !child) || (text == inp_text && !first_only)){
+ __argp_fmtstream_puts (stream, text);
+ }
+ }
if (__argp_fmtstream_point (stream) > __argp_fmtstream_lmargin (stream))
__argp_fmtstream_putc (stream, '\n');