sequencer.c: rework search for start of footer to improve clarity
This code sequence is somewhat difficult to read. Let's rewrite it and add some comments to improve clarity. Signed-off-by: Brandon Casey <drafnel@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>maint
parent
e8a1f5a2ae
commit
fa1727fb21
10
sequencer.c
10
sequencer.c
|
@ -1019,19 +1019,21 @@ int sequencer_pick_revisions(struct replay_opts *opts)
|
||||||
|
|
||||||
static int ends_rfc2822_footer(struct strbuf *sb, int ignore_footer)
|
static int ends_rfc2822_footer(struct strbuf *sb, int ignore_footer)
|
||||||
{
|
{
|
||||||
int ch;
|
char ch, prev;
|
||||||
int hit = 0;
|
|
||||||
int i, j, k;
|
int i, j, k;
|
||||||
int len = sb->len - ignore_footer;
|
int len = sb->len - ignore_footer;
|
||||||
int first = 1;
|
int first = 1;
|
||||||
const char *buf = sb->buf;
|
const char *buf = sb->buf;
|
||||||
|
|
||||||
|
prev = '\0';
|
||||||
for (i = len - 1; i > 0; i--) {
|
for (i = len - 1; i > 0; i--) {
|
||||||
if (hit && buf[i] == '\n')
|
ch = buf[i];
|
||||||
|
if (prev == '\n' && ch == '\n') /* paragraph break */
|
||||||
break;
|
break;
|
||||||
hit = (buf[i] == '\n');
|
prev = ch;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* advance to start of last paragraph */
|
||||||
while (i < len - 1 && buf[i] == '\n')
|
while (i < len - 1 && buf[i] == '\n')
|
||||||
i++;
|
i++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue