From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr1-x441.google.com (mail-wr1-x441.google.com [IPv6:2a00:1450:4864:20::441]) by sourceware.org (Postfix) with ESMTPS id 7F9D0385E00B for ; Wed, 25 Mar 2020 17:56:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7F9D0385E00B Received: by mail-wr1-x441.google.com with SMTP id m17so4281540wrw.11 for ; Wed, 25 Mar 2020 10:56:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oKJTs88OwtBXnhFKxmhMNLMkT8RMDCnTECeRsM/oOEU=; b=Fsugg41aDscvVQsdK5mF0iYVSGd3hHarjOQsO71De9IUygqQFugwfFvPd/WSj+f7N3 mRRsmR2p1j2h6Y7BrO0Pc/T0hVUIBF1lqF/leW/QPKIMVLQWxSsWi6WJTKUMDthiY80F DOud0sXJSHVZvoNF9gIOZU+Af2o7LWmEbL8FlSUiXQ4JQjWt2o4EA0pWLTzmqkMvCvSM 9CaRxrEw9i55dm41SyVQI3AwM4jucZNGBcO/L/ZCsWXjl6QEt628oZXhch+4r4qZclwG OvR3AxNTZXaV8N7GYILNjatf2b2LcSJpKi7mnK55kJRkQ81Ozha6a6/FFQHVm5ksy0Wn rdZA== X-Gm-Message-State: ANhLgQ3JP31fNZcIg2BLJySYffRULpPSrz4cBv6KKC1hPhLcsQtSIw18 xRWdQDvg8M9DiFRS2CzBxdTyADIrMIDeP4Iq3Cg= X-Google-Smtp-Source: ADFU+vudF1HkHateZ7f2hXTz2/caLystQ2XDdAPr+6d4XDuh+v0REiFFx+gi3Q2bZiG9zdyAnPHPyt/7WMgsAeA88uw= X-Received: by 2002:adf:fe4c:: with SMTP id m12mr4775548wrs.96.1585158961412; Wed, 25 Mar 2020 10:56:01 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Girish Joshi Date: Wed, 25 Mar 2020 23:25:50 +0530 Message-ID: Subject: Re: [PATCH] argp: argp.doc prints incorrectly when it starts with "\v" [BZ #19038] To: DJ Delorie Cc: libc-alpha@sourceware.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Mar 2020 17:56:04 -0000 Thanks DJ for the review. On Sat, Mar 21, 2020 at 7:33 AM DJ Delorie wrote: > > Girish Joshi writes: > > + if ((!vt && !child) || (text == inp_text && !first_only)) > > I stared at this code for a long time, and I'm still not sure I > understand it. I think that means the code is wrong, even if it does > the right thing. > > The original bug has the root cause: > > "When processing what should come before the '\v', this section sets > inp_text = doc and inp_text_limit = 0. That value of inp_text_limit is > interpreted later to mean "print the whole string." > > Would the logic be easier to follow if you just initialized > inp_text_limit to -1 and have -1 mean "print the whole string"? That > way a value of zero is unambiguously an empty string. > I see your point. > You'd end up with code like this: > > > size_t inp_text_limit = -1; > > > inp_text_limit = (!post && vt) ? (vt - doc) : -1; > > > if (text == inp_text && inp_text_limit != -1) > I tried this, it does work properly. I'll create and post a patch with these changes tomorrow. Thanks again for the input. Girish Joshi