Use good m_ functions, because it smell like a flower, version 2.
[apps/madmutt.git] / from.c
diff --git a/from.c b/from.c
index a53944a..5931789 100644 (file)
--- 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 <ctype.h>
-#include <string.h>
-
-#include <lib-lib/mem.h>
-#include <lib-lib/str.h>
-#include <lib-lib/macros.h>
-#include <lib-lib/debug.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;
@@ -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)