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: 1095733 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-101751-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="pa2eC1a4"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="esfMdP2Z"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44yGmX2wv8z9s4V for ; Mon, 6 May 2019 18:55:55 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; q=dns; s=default; b=bwwQji0zIkPEfB8fAGp1CxHBb9jUJ q964uoltZP1ZLVfqJFxuUtHhEOwL+vhKpdV1BwdOqJoPoUFAM7buzg914fe1gTKR t2YQal8f0ZWJdkahztQMLUOHnxUfrGDbRWDA3Qu+qahqHAf6bys13CmKY9Vf4mig 4B+5S3sixPsIXU= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:mime-version:from:date:message-id:subject:to :content-type; s=default; bh=C1Jhd6dVdom1VOpL12Nyg+V0fhE=; b=pa2 eC1a496Csa/p2N3lRHGmwF5jVil1ixG21HKny2MF6+I2ecr5CKPx/xHqVL+nqGCB 4DgnJ/EjzCMR2tw7IcxMI1aXVq+Jjfxx1d2DAu6W/kglwzAfbMW7xeyALP4ejFLa n2GnLzC1rb3gVJDH9HblDRImiVgAhCIRfpmvvuY8= 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;