Re: [PATCH 3/3] parse_commit(): handle broken whitespace-only timestamp

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Apr 22, 2023 at 05:53:10PM +0200, René Scharfe wrote:

> Am 22.04.23 um 15:50 schrieb Jeff King:
> > diff --git a/commit.c b/commit.c
> > index ede810ac1c..56877322d3 100644
> > --- a/commit.c
> > +++ b/commit.c
> > @@ -120,6 +120,16 @@ static timestamp_t parse_commit_date(const char *buf, const char *tail)
> >  	if (dateptr == buf || dateptr == eol)
> >  		return 0;
> >
> > +	/*
> > +	 * trim leading whitespace; parse_timestamp() will do this itself, but
> > +	 * it will walk past the newline at eol while doing so. So we insist
> > +	 * that there is at least one digit here.
> > +	 */
> > +	while (dateptr < eol && isspace(*dateptr))
> > +		dateptr++;
> > +	if (!strchr("0123456789", *dateptr))
> 
> You could use (our own) isdigit() here instead.  It's more concise and
> efficient.

Heh, yes, that is much better. I had strspn() on the mind since that is
what split_ident_line() uses.

I think it could even just be:

  if (dateptr != eol)

which implies that we found some non-whitespace character, and then we
rely on parse_timestamp() to return 0 (which is what the current code is
effectively doing).

-Peff



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux