Re: [PATCH v14 01/11] trailer: add data structures and basic functions
- From
Christian Couder <christian.couder@gmail.com>
- Date
- Sep 16, 2014, 08:01 UTC
- Message-ID
- <CAP8UFD3wi2KCZhDAF7vqMpb72DbLMbHNDiDGi0tFLW+vzsQqSA@mail.gmail.com>
- In-Reply-To
- <xmqqsijs4o02.fsf@gitster.dls.corp.google.com>
On Mon, Sep 15, 2014 at 10:39 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 6 quoted lines
> Christian Couder <chriscool@tuxfamily.org> writes: > >> +/* Get the length of buf from its beginning until its last alphanumeric character */ > > That makes it sound as if feeding "abc%de#f@" to the function returns > 3 for "abc", but
For me the last alphanumeric character in "abc%de#f@" is "f", so it is the length from the beginning to "f" so it should return 8.
Show 9 quoted lines
>> +static size_t alnum_len(const char *buf, size_t len)
>> +{
>> + while (len > 0 && !isalnum(buf[len - 1]))
>> + len--;
>> + return len;
>> +}
>
> doesn't it look at '@', be unhappy and decrement, look at 'f' and
> break out to return the length of "abc%de#f"?Yeah, that's the expected behavior.
> Perhaps that behaviour _is_ what you want, but then the comment is > lying, no?
I don't think so, but maybe you are parsing the comment in a different way than I am. What would you suggest instead?
Thanks, Christian.