Re: [PATCH v2 02/12] attr.c: use strchrnul() to scan for one line
- From
Stefan Beller <sbeller@google.com>
- Date
- May 16, 2016, 23:28 UTC
- Message-ID
- <CAGZ79kbSFp5e6-AeSbqk4hFxcuzTo-4oSG_z5nGTpAY0uvLAuw@mail.gmail.com>
- In-Reply-To
- <20160516210545.6591-3-gitster@pobox.com>
On Mon, May 16, 2016 at 2:05 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
> Signed-off-by: Junio C Hamano <gitster@pobox.com>
> ---
> attr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/attr.c b/attr.c
> index eec5d7d..45aec1b 100644
> --- a/attr.c
> +++ b/attr.c
> @@ -402,8 +402,8 @@ static struct attr_stack *read_attr_from_index(const char *path, int macro_ok)
> for (sp = buf; *sp; ) {
> char *ep;
> int more;
> - for (ep = sp; *ep && *ep != '\n'; ep++)
> - ;
> +
> + ep = strchrnul(sp, '\n');(Even lesser nit as in patch 1) You could directly assign ep and more when declaring them.
Show 10 quoted lines
> more = (*ep == '\n'); > *ep = '\0'; > handle_attr_line(res, sp, path, ++lineno, macro_ok); > -- > 2.8.2-748-gfb85f76 > > -- > To unsubscribe from this list: send the line "unsubscribe git" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html