[PATCH] argp: argp.doc prints incorrectly when it starts with "\v" [BZ #19038]
DJ Delorie
dj@redhat.com
Sat Mar 21 02:03:00 GMT 2020
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.
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)
More information about the Libc-alpha
mailing list