fix parsing issues in slurp_newsrc
authorPierre Habouzit <madcoder@debian.org>
Mon, 28 May 2007 12:00:22 +0000 (14:00 +0200)
committerPierre Habouzit <madcoder@debian.org>
Mon, 28 May 2007 12:00:22 +0000 (14:00 +0200)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
nntp.c

diff --git a/nntp.c b/nntp.c
index a533933..d3bf60f 100644 (file)
--- a/nntp.c
+++ b/nntp.c
@@ -52,7 +52,7 @@ static void mutt_newsgroup_stat(nntp_data_t *data)
     }
 }
 
-static int nntp_parse_newsrc_line(nntp_server_t * news, const char *line)
+static int nntp_parse_newsrc_line(nntp_server_t *news, const char *line)
 {
     nntp_data_t *data;
     char group[LONG_STRING];
@@ -86,18 +86,19 @@ static int nntp_parse_newsrc_line(nntp_server_t * news, const char *line)
     data->entries = p_new(NEWSRC_ENTRY, x * 2);
     data->max = x * 2;
     data->subscribed = (*p++ == ':');
+    p = skipspaces(p);
 
     for (x = 0; *p; p++) {
-        p = skipspaces(p);
         data->entries[x].first = strtol(p, (char **)&p, 10);
-        p = skipspaces(p);
+        p += strcspn(p, "-,");
         if (*p == '-') {
+            if (!*p)
+                break;
             data->entries[x].last = strtol(p + 1, (char **)&p, 10);
         } else {
             data->entries[x].last = data->entries[x].first;
+            p = strchrnul(p, ',');
         }
-
-        p  = strchrnul(p, ',');
         x += data->entries[x].last != 0;
     }