Brandon Casey wrote:

> --- a/sequencer.c
> +++ b/sequencer.c
> @@ -1024,16 +1024,19 @@ int sequencer_pick_revisions(struct replay_opts *opts)
>  static int ends_rfc2822_footer(struct strbuf *sb, int ignore_footer)
>  {
>       int ch;
> -     int hit = 0;
> +     int last_char_was_nl, this_char_is_nl;
>       int i, j, k;
>       int len = sb->len - ignore_footer;
>       int first = 1;
>       const char *buf = sb->buf;
>  
> +     /* find start of last paragraph */
> +     last_char_was_nl = 0;
>       for (i = len - 1; i > 0; i--) {
> -             if (hit && buf[i] == '\n')
> +             this_char_is_nl = (buf[i] == '\n');
> +             if (last_char_was_nl && this_char_is_nl)
>                       break;
> -             hit = (buf[i] == '\n');
> +             last_char_was_nl = this_char_is_nl;

I would have been tempted to write

        char prev;

        prev = 0;
        for (i = len - 1; i > 0; i--) {
                char ch = buf[i];
                if (prev == '\n' && ch == '\n') /* paragraph break */
                        break;
                prev = ch;
        }

but your rewrite is just as clear.  For what it's worth,
Reviewed-by: Jonathan Nieder <jrnie...@gmail.com>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to