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
@ -23,58 +71,26 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
@@ -23,58 +71,26 @@ static int append_signoff(char *buf, int buf_sz, int at, const char *signoff)
return at;
/* First see if we already have the sign-off by the signer */
while (1) {
cp = strstr(cp, signed_off_by);
if (!cp)
break;
while ((cp = strstr(cp, signed_off_by))) {
has_signoff = 1;
cp += strlen(signed_off_by);
if ((cp + signoff_len < buf + at) &&
!strncmp(cp, signoff, signoff_len) &&
isspace(cp[signoff_len]))
return at; /* we already have him */
if (cp + signoff_len >= buf + at)
break;
if (strncmp(cp, signoff, signoff_len))
continue;
if (!isspace(cp[signoff_len]))
continue;
/* we already have him */
return at;
}
/* Does the last line already end with "^[-A-Za-z]+: [^@]+@"?
* If not, add a blank line to separate the message from
* the run of Signed-off-by: and Acked-by: lines.
*/
{
char ch;
int seen_colon, seen_at, seen_name, seen_head, not_signoff;