Subject: Re: [PATCH v14 01/11] trailer: add data structures and basic functions

From: Jeff King <[email-masked]>
Date: Wed, 17 Sep 2014 03:58:39 -0400

On Tue, Sep 16, 2014 at 10:01:11AM +0200, Christian Couder wrote:

> On Mon, Sep 15, 2014 at 10:39 PM, Junio C Hamano <[email-masked]> wrote:
> > Christian Couder <[email-masked]> 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.

FWIW, I parsed the comment as you intended, but I do think it is a bit
unclear (especially given the name, as it is skipping over more than
just alnums). From reading the calling code, it looks like the intent is
to take a token string like "Signed-off-by:" and find that the ":" is
part of the ending punctuation, but that the "-" are retained as
internal punctuation.

Would it make sense as:

  /*
   * Return the length of the string not including any final
   * punctuation. E.g., the input "Signed-off-by:" would return
   * 13, stripping the trailing punctuation but retaining
   * internal punctuation.
   */
  int token_len_without_separator(const char *token)
  ...

The name is a bit clunky, but hopefully it is more clear what the point
is.

-Peff