]> diplodocus.org Git - nmh/blobdiff - sbr/seq_read.c
Added const qualifier to arguments of concat() and copy().
[nmh] / sbr / seq_read.c
index f36edb56cfb8cf5cc9f79d0b0d45088fd9dced2e..a807ef7d6169b0b000c57535c163590f8e190fd5 100644 (file)
@@ -3,14 +3,13 @@
  * seq_read.c -- read the .mh_sequence file and
  *            -- initialize sequence information
  *
- * $Id$
- *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  * complete copyright information.
  */
 
 #include <h/mh.h>
+#include <h/utils.h>
 
 /*
  * static prototypes
@@ -60,6 +59,7 @@ seq_public (struct msgs *mp)
     char *cp, seqfile[PATH_MAX];
     char name[NAMESZ], field[BUFSIZ];
     FILE *fp;
+    m_getfld_state_t gstate = 0;
 
     /*
      * If mh_seq == NULL (such as if nmh been compiled with
@@ -77,15 +77,16 @@ 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)) {
+    for (;;) {
+       int fieldsz = sizeof field;
+       switch (state = m_getfld (&gstate, name, field, &fieldsz, fp)) {
            case FLD: 
            case FLDPLUS:
-           case FLDEOF: 
                if (state == FLDPLUS) {
                    cp = getcpy (field);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, field, sizeof(field), fp);
+                       fieldsz = sizeof field;
+                       state = m_getfld (&gstate, name, field, &fieldsz, fp);
                        cp = add (field, cp);
                    }
                    seq_init (mp, getcpy (name), trimcpy (cp));
@@ -93,12 +94,9 @@ seq_public (struct msgs *mp)
                } else {
                    seq_init (mp, getcpy (name), trimcpy (field));
                }
-               if (state == FLDEOF)
-                   break;
                continue;
 
            case BODY: 
-           case BODYEOF: 
                adios (NULL, "no blank lines are permitted in %s", seqfile);
                /* fall */
 
@@ -110,6 +108,7 @@ seq_public (struct msgs *mp)
        }
        break;  /* break from for loop */
     }
+    m_getfld_state_destroy (&gstate);
 
     lkfclose (fp, seqfile);
 }
@@ -159,7 +158,8 @@ seq_private (struct msgs *mp)
 static int
 seq_init (struct msgs *mp, char *name, char *field)
 {
-    int i, j, k, is_current;
+    unsigned int i;
+    int j, k, is_current;
     char *cp, **ap;
 
     /*