Re: [PATCH v2 01/12] commit.c: use strchrnul() to scan for one line
- From
Junio C Hamano <gitster@pobox.com>
- Date
- May 16, 2016, 23:41 UTC
- Message-ID
- <CAPc5daXM9a=W2R6YE=4PSuHWKXoZs_-VT+48ajh3mq1RoqYncA@mail.gmail.com>
- In-Reply-To
- <CAGZ79kbeXCsCs35hva2FWUhOD2F37ZDrzupEZLGBVbqnMxPjXQ@mail.gmail.com>
On Mon, May 16, 2016 at 4:19 PM, Stefan Beller <sbeller@google.com> wrote:
Show 9 quoted lines
>> if (*p) {
>> p += 2;
>> - for (eol = p; *eol && *eol != '\n'; eol++)
>> - ; /* do nothing */
>> + eol = strchrnul(p, '\n');
>
> Nit:
> You could include the +2 into the arg of strchrnul,
> such that you can drop the braces.You're right. With or without braces,
eol = strchrnul(p + 2, '\n');
would be easier to understand (I do not know offhand if the value of p matters after this part, as I am responding from GMail Web UI without access to the wider context in the source, though).