summaryrefslogtreecommitdiff
path: root/builtin/mailinfo.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2014-06-01 09:00:40 (GMT)
committerJunio C Hamano <gitster@pobox.com>2014-06-02 20:30:18 (GMT)
commitb1a013dd6a79826675138cf9bdfaf18fafa786ba (patch)
treeea956884bdd7c45a7412d6e28ce510ddae5425cb /builtin/mailinfo.c
parent7bbc4e8fdb33e0a8e42e77cc05460d4c4f615f4d (diff)
downloadgit-b1a013dd6a79826675138cf9bdfaf18fafa786ba.zip
git-b1a013dd6a79826675138cf9bdfaf18fafa786ba.tar.gz
git-b1a013dd6a79826675138cf9bdfaf18fafa786ba.tar.bz2
mailinfo: use strcmp() for string comparison
The array header is defined as: static const char *header[MAX_HDR_PARSED] = { "From","Subject","Date", }; When looking for the index of a specfic string in that array, simply use strcmp() instead of memcmp(). This avoids running over the end of the string (e.g. with memcmp("Subject", "From", 7)) and gets rid of magic string length constants. Signed-off-by: Rene Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/mailinfo.c')
-rw-r--r--builtin/mailinfo.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index 24a772d..6b44156 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -334,7 +334,7 @@ static int check_header(const struct strbuf *line,
}
if (!prefixcmp(line->buf, "[PATCH]") && isspace(line->buf[7])) {
for (i = 0; header[i]; i++) {
- if (!memcmp("Subject", header[i], 7)) {
+ if (!strcmp("Subject", header[i])) {
handle_header(&hdr_data[i], line);
ret = 1;
goto check_header_out;
@@ -929,13 +929,13 @@ static void handle_info(void)
else
continue;
- if (!memcmp(header[i], "Subject", 7)) {
+ if (!strcmp(header[i], "Subject")) {
if (!keep_subject) {
cleanup_subject(hdr);
cleanup_space(hdr);
}
output_header_lines(fout, "Subject", hdr);
- } else if (!memcmp(header[i], "From", 4)) {
+ } else if (!strcmp(header[i], "From")) {
cleanup_space(hdr);
handle_from(hdr);
fprintf(fout, "Author: %s\n", name.buf);