| 98 | } |
| 99 | |
| 100 | static char *parse_name_and_email(char *buffer, char **name, |
| 101 | char **email, int allow_empty_email) |
| 102 | { |
| 103 | char *left, *right, *nstart, *nend; |
| 104 | *name = *email = NULL; |
| 105 | |
| 106 | if (!(left = strchr(buffer, '<'))) |
| 107 | return NULL; |
| 108 | if (!(right = strchr(left + 1, '>'))) |
| 109 | return NULL; |
| 110 | if (!allow_empty_email && (left+1 == right)) |
| 111 | return NULL; |
| 112 | |
| 113 | /* remove whitespace from beginning and end of name */ |
| 114 | nstart = buffer; |
| 115 | while (isspace(*nstart) && nstart < left) |
| 116 | ++nstart; |
| 117 | nend = left-1; |
| 118 | while (nend > nstart && isspace(*nend)) |
| 119 | --nend; |
| 120 | |
| 121 | *name = (nstart <= nend ? nstart : NULL); |
| 122 | *email = left+1; |
| 123 | *(nend+1) = '\0'; |
| 124 | *right++ = '\0'; |
| 125 | |
| 126 | return (*right == '\0' ? NULL : right); |
| 127 | } |
| 128 | |
| 129 | static void read_mailmap_line(struct string_list *map, char *buffer) |
| 130 | { |