From patchwork Mon May 6 08:55:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Girish Joshi X-Patchwork-Id: 32569 Received: (qmail 95901 invoked by alias); 6 May 2019 08:55:48 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 95826 invoked by uid 89); 6 May 2019 08:55:48 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.6 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-wr1-f67.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=o+vtXo5iRfg4bq5LeUJZoWDUOnJMjhJsxVnA2mL8ncQ=; b=esfMdP2ZXEAGsIfw5xTIIjLyS2M22H2o270231eFa6kfzCsgqFqIV7/e8wECWWEveh 7iO/LBIVo2OzDENJ8GJlIYUDTfIMEtx+Pu8xFg6zcbS6lqMoYk/q0/UXuL3t+ZuL2YCV sqf5ebWkFiTXzNE9bWPwa6AKfy88j2tt6MB5yGYOwIkLR+KqJ9Y4cqYrLOib50nYC98P 5EuO7Rgga8KIAzD+/krPu26BB02AClWTPkxVmjGF4SpsNyNDo5l2NKwxH5tahYN7STjo 0M73SGu9mgjZpx3qW8xFdA4vvVYUdyVV1kWX60+f+0SzQV3LoWqxo84GU9xukN/tQXJY JZjA== MIME-Version: 1.0 From: Girish Joshi Date: Mon, 6 May 2019 04:55:33 -0400 Message-ID: Subject: [PATCH] argp: argp.doc prints incorrectly when it starts with "\v" [BZ #19038] To: libc-alpha@sourceware.org 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. } @@ -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'); 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;