use memset to clear the msgstats in folder_realloc
[mmh] / sbr / seq_read.c
index e76bcc6..4cc4223 100644 (file)
@@ -55,9 +55,9 @@ seq_read(struct msgs *mp)
 static void
 seq_public(struct msgs *mp)
 {
-       int state;
-       char *cp, seqfile[PATH_MAX];
-       char name[NAMESZ], field[BUFSIZ];
+       enum state state;
+       struct field f = {{0}};
+       char seqfile[PATH_MAX];
        FILE *fp;
 
        /*
@@ -74,37 +74,27 @@ seq_public(struct msgs *mp)
                return;
 
        /* Use m_getfld to scan sequence file */
-       for (state = FLD;;) {
-               switch (state = m_getfld(state, name, field, sizeof(field),
-                               fp)) {
-               case FLD:
-               case FLDPLUS:
-                       if (state == FLDPLUS) {
-                               cp = mh_xstrdup(field);
-                               while (state == FLDPLUS) {
-                                       state = m_getfld(state, name, field,
-                                                       sizeof(field), fp);
-                                       cp = add(field, cp);
-                               }
-                               seq_init(mp, mh_xstrdup(name), trimcpy(cp));
-                               mh_free0(&cp);
-                       } else {
-                               seq_init(mp, mh_xstrdup(name), trimcpy(field));
-                       }
+       for (state = FLD2;;) {
+               switch (state = m_getfld2(state, &f, fp)) {
+               case LENERR2:
+                       state = FLD2;
+                       /* FALL */
+               case FLD2:
+                       seq_init(mp, mh_xstrdup(f.name), trimcpy(f.value));
                        continue;
 
-               case BODY:
+               case BODY2:
                        adios(EX_CONFIG, NULL, "no blank lines are permitted in %s",
                                        seqfile);
-                       /* fall */
+                       /* FALL */
 
-               case FILEEOF:
+               case FILEEOF2:
                        break;
 
                default:
                        adios(EX_CONFIG, NULL, "%s is poorly formatted", seqfile);
                }
-               break;  /* break from for loop */
+               break;
        }
 
        lkfclose(fp, seqfile);
@@ -220,9 +210,14 @@ seq_init(struct msgs *mp, char *name, char *field)
                        ** We iterate through messages in this range
                        ** and flip on bit for this sequence.
                        */
+                       if (k > mp->hghoff) {
+                               if (!(mp = folder_realloc(mp, mp->lowoff, k))) {
+                                       adios(EX_OSERR, NULL, "unable to allocate folder storage");
+                               }
+                               mp->hghoff = k;
+                       }
                        for (; j <= k; j++) {
-                               if (j >= mp->lowmsg && j <= mp->hghmsg &&
-                                               does_exist(mp, j))
+                               if (j >= mp->lowmsg && j <= mp->hghoff)
                                        add_sequence(mp, i, j);
                        }
                }