Re: [PATCH 04/14] shortlog: use skip_prefix_icase to parse "Author" lines
On Tue, Dec 29, 2015 at 2:27 AM, Jeff King <peff@peff.net> wrote:
> Because we must match both "Author" and "author" here, we
> could not use skip_prefix, and had to hand-code a partial
> case-insensitive match. Now that we have skip_prefix_case,
s/skip_prefix_case/skip_prefix_icase/
> we can use it. This is technically more liberal in what it
> matches (e.g., it will match AUTHOR), but in this particular
> case that that's OK (we are matching git-log output, so we
Show 30 quoted lines
> expect arbitrary data like commit headers to be indented).
>
> In addition to being easier to read, this will make the code
> easier to adapt for matching other lines.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
> diff --git a/builtin/shortlog.c b/builtin/shortlog.c
> @@ -94,8 +94,8 @@ static void read_from_stdin(struct shortlog *log)
> char author[1024], oneline[1024];
>
> while (fgets(author, sizeof(author), stdin) != NULL) {
> - if (!(author[0] == 'A' || author[0] == 'a') ||
> - !starts_with(author + 1, "uthor: "))
> + const char *v;
> + if (!skip_prefix_icase(author, "Author: ", &v))
> continue;
> while (fgets(oneline, sizeof(oneline), stdin) &&
> oneline[0] != '\n')
> @@ -103,7 +103,7 @@ static void read_from_stdin(struct shortlog *log)
> while (fgets(oneline, sizeof(oneline), stdin) &&
> oneline[0] == '\n')
> ; /* discard blanks */
> - insert_one_record(log, author + 8, oneline);
> + insert_one_record(log, v, oneline);
> }
> }
>
> --
> 2.7.0.rc3.367.g09631da