From: epg <> Date: Mon, 8 Mar 2004 01:40:48 +0000 (+0000) Subject: Apply patch from Doug Porter to compare headers case-insensitively and X-Git-Url: https://diplodocus.org/git/mdfrm/commitdiff_plain/46caf3a41bf76e17fbf28e6c24883ecefbdd4ef1?ds=sidebyside;hp=669d681d1f57b5ac33d11cb74106fd00f8753c8a Apply patch from Doug Porter to compare headers case-insensitively and trim leading whitespace on the From and Subject values printed. --- diff --git a/mdfrm.c b/mdfrm.c index 319bb07..8977cdd 100644 --- a/mdfrm.c +++ b/mdfrm.c @@ -7,6 +7,7 @@ #include +#include #include #include #include @@ -25,8 +26,8 @@ #endif enum { - FROMLEN = 6, /* "From: " */ - SUBJLEN = 9, /* "Subject: " */ + FROMLEN = 5, /* "From:" */ + SUBJLEN = 8, /* "Subject:" */ /* Number of characters for each field we actually output. This * must also be changed in the printf functions at the end of the @@ -57,9 +58,13 @@ scan_message(char *filename, char *fromheader, char *subjheader) } --len; - if (len > FROMLEN && strncmp(line, "From: ", FROMLEN) == 0) { + if (len > FROMLEN && strncasecmp(line, "From:", FROMLEN) == 0) { line += FROMLEN; len -= FROMLEN; + while (len > 0 && isspace(line[0])) { + line++; + len--; + } if (len < FROMCOUNT) { fromcount = len; } else { @@ -67,9 +72,13 @@ scan_message(char *filename, char *fromheader, char *subjheader) } strncpy(fromheader, line, fromcount); fromheader[fromcount] = '\0'; - } else if (len > SUBJLEN && strncmp(line, "Subject: ", SUBJLEN) == 0) { + } else if (len > SUBJLEN && strncasecmp(line, "Subject:", SUBJLEN) == 0) { line += SUBJLEN; len -= SUBJLEN; + while (len > 0 && isspace(line[0])) { + line++; + len--; + } if (len < SUBJCOUNT) { subjcount = len; } else {