X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=mailinfo.c;h=9f95f37651e2ce5a3930051fe875f1c16ede97c2;hb=724b511d4fb363ebee828ba3992c831ba006444c;hp=d4b4163628e582185e8a28defe009c75aa62edab;hpb=5e80092f7e6db09a40a62e837ca3f74f0bc5ad73;p=git.git diff --git a/mailinfo.c b/mailinfo.c index d4b41636..9f95f376 100644 --- a/mailinfo.c +++ b/mailinfo.c @@ -40,13 +40,43 @@ static char *sanity_check(char *name, char *email) return name; } +static int bogus_from(char *line) +{ + /* John Doe */ + char *bra, *ket, *dst, *cp; + + /* This is fallback, so do not bother if we already have an + * e-mail address. + */ + if (*email) + return 0; + + bra = strchr(line, '<'); + if (!bra) + return 0; + ket = strchr(bra, '>'); + if (!ket) + return 0; + + for (dst = email, cp = bra+1; cp < ket; ) + *dst++ = *cp++; + *dst = 0; + for (cp = line; isspace(*cp); cp++) + ; + for (bra--; isspace(*bra); bra--) + *bra = 0; + cp = sanity_check(cp, email); + strcpy(name, cp); + return 1; +} + static int handle_from(char *line) { char *at = strchr(line, '@'); char *dst; if (!at) - return 0; + return bogus_from(line); /* * If we already have one email, don't take any confusing lines