Use m_tempfile and better errors msg
[apps/madmutt.git] / from.c
diff --git a/from.c b/from.c
index 7122052..5931789 100644 (file)
--- a/from.c
+++ b/from.c
@@ -7,27 +7,10 @@
  * please see the file GPL in the top level source directory.
  */
 
-#if HAVE_CONFIG_H
-# include "config.h"
-#endif
-
-#include <ctype.h>
-#include <string.h>
-
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-#include <lib-lib/macros.h>
+#include <lib-lib/lib-lib.h>
 
 #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;
@@ -67,7 +50,8 @@ 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;
 
@@ -106,7 +90,8 @@ int is_from (const char *s, char *path, ssize_t pathlen, time_t * tp)
     }
   }
 
-  s = next_word (s);
+  s = m_strnextsp(s);
+  s = skipspaces(s);
   if (!*s)
     return 0;
 
@@ -115,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;
   }
@@ -125,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;
 
@@ -143,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;
 
@@ -158,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;
     }