X-Git-Url: http://git.madism.org/?p=apps%2Fmadmutt.git;a=blobdiff_plain;f=from.c;h=59317898ca6eb5d91e7c1489554971202f6e28e8;hp=a53944a72b3ecbfc20f560417dbaf262d5ea3804;hb=ee48d4232053aee30adb5afb48b147e31d7aedfa;hpb=ac813896ca32d850febc2d95065ac4fa040f11f9 diff --git a/from.c b/from.c index a53944a..5931789 100644 --- a/from.c +++ b/from.c @@ -7,28 +7,10 @@ * please see the file GPL in the top level source directory. */ -#if HAVE_CONFIG_H -# include "config.h" -#endif - -#include -#include - -#include -#include -#include -#include +#include #include "mutt.h" -static const char *next_word(const char *s) -{ - while (*s && !ISSPACE(*s)) - s++; - s = skipspaces(s); - return s; -} - int mutt_check_month (const char *s) { int i; @@ -68,12 +50,11 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp) if (m_strncmp("From ", s, 5) != 0) return 0; - s = next_word (s); /* skip over the From part. */ + s = m_strnextsp(s); /* skip over the From part. */ + s = skipspaces(s); if (!*s) return 0; - debug_print (3, ("parsing: %s\n", s)); - if (!is_day_name (s)) { const char *p; ssize_t len; @@ -98,7 +79,6 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp) len = pathlen - 1; memcpy (path, s, len); path[len] = 0; - debug_print (3, ("got return path: %s\n", path)); } s = vskipspaces(p + 1); @@ -106,12 +86,12 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp) return 0; if (!is_day_name (s)) { - debug_print (1, ("expected weekday, got: %s\n", s)); return 0; } } - s = next_word (s); + s = m_strnextsp(s); + s = skipspaces(s); if (!*s) return 0; @@ -120,7 +100,8 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp) * is the same as a three-letter abbreviation of the day of the week. */ if (is_day_name (s)) { - s = next_word (s); + s = m_strnextsp(s); + s = skipspaces(s); if (!*s) return 0; } @@ -130,14 +111,16 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp) return 0; /* day */ - s = next_word (s); + s = m_strnextsp(s); + s = skipspaces(s); if (!*s) return 0; if (sscanf (s, "%d", &tm.tm_mday) != 1) return 0; /* time */ - s = next_word (s); + s = m_strnextsp(s); + s = skipspaces(s); if (!*s) return 0; @@ -148,13 +131,15 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp) else return 0; - s = next_word (s); + s = m_strnextsp(s); + s = skipspaces(s); if (!*s) return 0; /* timezone? */ if (isalpha ((unsigned char) *s) || *s == '+' || *s == '-') { - s = next_word (s); + s = m_strnextsp(s); + s = skipspaces(s); if (!*s) return 0; @@ -163,7 +148,8 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp) * From xxxx@yyyyyyy.fr Wed Aug 2 00:39:12 MET DST 1995 */ if (isalpha ((unsigned char) *s)) { - s = next_word (s); + s = m_strnextsp(s); + s = skipspaces(s); if (!*s) return 0; } @@ -174,10 +160,6 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp) return 0; tm.tm_year = yr > 1900 ? yr - 1900 : (yr < 70 ? yr + 100 : yr); - debug_print (3, ("month=%d, day=%d, hr=%d, min=%d, sec=%d, yr=%d.\n", - tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec, - tm.tm_year)); - tm.tm_isdst = -1; if (tp)