This patch clean up append_signoff() by moving specific code that
looks up for "^[-A-Za-z]+: [^@]+@" pattern into a function.
It also stops the primary search when the cursor oversteps
'buf + at' limit.
This patch changes slightly append_signoff() behaviour too. If we
detect any Signed-off-by pattern during the primary search, we
needn't to do a pattern research after.
Signed-off-by: Franck Bui-Huu <vagabon.xyz@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
maint
Franck Bui-Huu19 years agocommitted byJunio C Hamano
@ -57,7 +40,7 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
@@ -57,7 +40,7 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
}
if (!seen_colon) {
if (ch == '@')
not_signoff = 1;
return 0;
else if (ch == ':')
seen_colon = 1;
else
@ -70,12 +53,45 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
@@ -70,12 +53,45 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
seen_head = 1;
continue;
}
not_signoff = 1;
/* no empty last line doesn't match */
return 0;
}
if (not_signoff || !seen_head || !seen_name)
buf[at++] = '\n';
return seen_head && seen_name;
}
static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)