[PATCH] argp: argp.doc prints incorrectly when it starts with "\v" [BZ #19038]

Girish Joshi girish946@gmail.com
Wed Mar 25 17:55:50 GMT 2020


Thanks DJ for the review.

On Sat, Mar 21, 2020 at 7:33 AM DJ Delorie <dj@redhat.com> wrote:
>
> Girish Joshi <girish946@gmail.com> 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


More information about the Libc-alpha mailing list