]> diplodocus.org Git - nmh/commitdiff
Changed bufsz argument of m_getfld() to be in-out instead of in.
authorDavid Levine <levinedl@acm.org>
Sat, 22 Dec 2012 17:51:21 +0000 (11:51 -0600)
committerDavid Levine <levinedl@acm.org>
Sat, 22 Dec 2012 17:51:21 +0000 (11:51 -0600)
This allowed removal of the msg_count global, in turn allowing
removal of sbr/m_msgdef.c

27 files changed:
Makefile.am
h/mh.h
h/prototypes.h
sbr/m_getfld.c
sbr/m_msgdef.c [deleted file]
sbr/readconfig.c
sbr/seq_read.c
uip/distsbr.c
uip/forwsbr.c
uip/mhbuildsbr.c
uip/mhcachesbr.c
uip/mhlsbr.c
uip/mhparse.c
uip/msh.c
uip/mshcmds.c
uip/new.c
uip/picksbr.c
uip/post.c
uip/prompter.c
uip/rcvdist.c
uip/replsbr.c
uip/scansbr.c
uip/sendsbr.c
uip/show.c
uip/slocal.c
uip/sortm.c
uip/whatnowsbr.c

index 27ffdfbb14311aface874238f45020d338e31e5e..54d37c2c7ee1c899b58b63f7e809f40f2471b0e8 100644 (file)
@@ -499,7 +499,7 @@ sbr_libmh_a_SOURCES = sbr/addrsbr.c sbr/ambigsw.c sbr/atooi.c sbr/base64.c \
                      sbr/showfile.c sbr/signals.c sbr/smatch.c \
                      sbr/snprintb.c sbr/ssequal.c sbr/strcasecmp.c \
                      sbr/strindex.c sbr/trimcpy.c sbr/uprf.c sbr/vfgets.c \
                      sbr/showfile.c sbr/signals.c sbr/smatch.c \
                      sbr/snprintb.c sbr/ssequal.c sbr/strcasecmp.c \
                      sbr/strindex.c sbr/trimcpy.c sbr/uprf.c sbr/vfgets.c \
-                     sbr/fmt_def.c sbr/m_msgdef.c sbr/mf.c sbr/utils.c \
+                     sbr/fmt_def.c sbr/mf.c sbr/utils.c \
                      sbr/m_mktemp.c sbr/getansreadline.c config/config.c \
                      config/version.c
 
                      sbr/m_mktemp.c sbr/getansreadline.c config/config.c \
                      config/version.c
 
diff --git a/h/mh.h b/h/mh.h
index f29379eae06d75938a278d0b29689ca1e8d0efa9..fb05fa7d8b9b46b5a8fb1ca70faac494cf575dc7 100644 (file)
--- a/h/mh.h
+++ b/h/mh.h
@@ -251,8 +251,6 @@ struct msgs {
 #define        MS_MMDF         3       /* string mmdlm2              */
 #define        MS_MSH          4       /* whacko msh                 */
 
 #define        MS_MMDF         3       /* string mmdlm2              */
 #define        MS_MSH          4       /* whacko msh                 */
 
-extern int msg_count;          /* m_getfld() indicators */
-
 #define        NOUSE   0               /* draft being re-used */
 
 #define TFOLDER 0              /* path() given a +folder */
 #define        NOUSE   0               /* draft being re-used */
 
 #define TFOLDER 0              /* path() given a +folder */
index c40e563487ee4f894ce7f0b7036e5b5f901ea7e0..619be9104d8b6548561982a454f09054c1ac4cf8 100644 (file)
@@ -76,7 +76,7 @@ char *m_backup (char *);
 int m_convert (struct msgs *, char *);
 char *m_draft (char *, char *, int, int *);
 void m_eomsbr (int (*)(int));
 int m_convert (struct msgs *, char *);
 char *m_draft (char *, char *, int, int *);
 void m_eomsbr (int (*)(int));
-int m_getfld (int, unsigned char[NAMESZ], unsigned char *, int, FILE *);
+int m_getfld (int, unsigned char[NAMESZ], unsigned char *, int *, FILE *);
 int m_gmprot (void);
 char *m_maildir (char *);
 char *m_mailpath (char *);
 int m_gmprot (void);
 char *m_maildir (char *);
 char *m_mailpath (char *);
index 91a1d8ccc141fd3deff3be3aad45cd2366300322..e80da57be5a69bd490ac91faf87ec1dd67af8f62 100644 (file)
@@ -151,8 +151,8 @@ Outputs
 =======
 name:  header field name (array of size NAMESZ=999)
 buf:  either a header field body or message body
 =======
 name:  header field name (array of size NAMESZ=999)
 buf:  either a header field body or message body
+bufsz:  number of characters loaded into buf
 (return value):  message parse state on return from function
 (return value):  message parse state on return from function
-(global) int msg_count:  number of characters loaded into buf
 
 Functions (part of Inputs, really)
 =========
 
 Functions (part of Inputs, really)
 =========
@@ -212,18 +212,11 @@ Subsequent calls provide the state returned by the previous call.
 Along the way, I thought of these possible interface changes that we
 might want to consider before rototilling the internals:
 
 Along the way, I thought of these possible interface changes that we
 might want to consider before rototilling the internals:
 
-1) To remove a global:
-   Change bufsz to be in-out instead of in, and therefore int * instead of
-   int, and use that instead of global msg_count.  There are only 3 call
-   sites that use msg_count so it wouldn't take much effort to remove use of
-   it.  Of course, all call sites would have to change to provide an int *
-   instead of an int.  Some now pass constants.
-
-2) To remove the state argument from the signature:
+1) To remove the state argument from the signature:
    Given the Current usage and Restriction above, the state variable could
    be removed from the signature and just retained internally.
 
    Given the Current usage and Restriction above, the state variable could
    be removed from the signature and just retained internally.
 
-3) To remove the Restriction above:
+2) To remove the Restriction above:
    One approach would be for m_getfld() to retain multiple copies of that
    state, one per iob that it sees.  Another approach would be for the
    caller to store it in an opaque struct, the address of which is passed
    One approach would be for m_getfld() to retain multiple copies of that
    state, one per iob that it sees.  Another approach would be for the
    caller to store it in an opaque struct, the address of which is passed
@@ -244,14 +237,6 @@ static unsigned char *locc(int, unsigned char *, unsigned char);
 
 static unsigned char **pat_map;
 
 
 static unsigned char **pat_map;
 
-/*
- * defined in sbr/m_msgdef.c = 0
- * This is a disgusting hack for "inc" so it can know how many
- * characters were stuffed in the buffer on the last call
- * (see comments in uip/scansbr.c).
- */
-extern int msg_count;
-
 static int msg_style = MS_DEFAULT;
 
 /*
 static int msg_style = MS_DEFAULT;
 
 /*
@@ -294,13 +279,13 @@ extern int  _filbuf(FILE*);
 
 int
 m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
 
 int
 m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
-          int bufsz, FILE *iob)
+          int *bufsz, FILE *iob)
 {
     register unsigned char  *bp, *cp, *ep, *sp;
     register int cnt, c, i, j;
 
     if ((c = Getc(iob)) < 0) {
 {
     register unsigned char  *bp, *cp, *ep, *sp;
     register int cnt, c, i, j;
 
     if ((c = Getc(iob)) < 0) {
-       msg_count = 0;
+       *bufsz = 0;
        *buf = 0;
        return FILEEOF;
     }
        *buf = 0;
        return FILEEOF;
     }
@@ -312,7 +297,7 @@ m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
            if (c >= 0)
                ungetc(c, iob);
        }
            if (c >= 0)
                ungetc(c, iob);
        }
-       msg_count = 0;
+       *bufsz = 0;
        *buf = 0;
        return FILEEOF;
     }
        *buf = 0;
        return FILEEOF;
     }
@@ -334,7 +319,7 @@ m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
                        if (c >= 0)
                            ungetc(c, iob);
                    }
                        if (c >= 0)
                            ungetc(c, iob);
                    }
-                   msg_count = 0;
+                   *bufsz = 0;
                    *buf = 0;
                    return FILEEOF;
                }
                    *buf = 0;
                    return FILEEOF;
                }
@@ -411,7 +396,7 @@ m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
                    /* See if buf can hold this line, since we were assuming
                     * we had a buffer of NAMESZ, not bufsz. */
                    /* + 1 for the newline */
                    /* See if buf can hold this line, since we were assuming
                     * we had a buffer of NAMESZ, not bufsz. */
                    /* + 1 for the newline */
-                   if (bufsz < j + 1) {
+                   if (*bufsz < j + 1) {
                        /* No, it can't.  Oh well, guess we'll blow up. */
                        *cp = *buf = 0;
                        advise (NULL, "eol encountered in field \"%s\"", name);
                        /* No, it can't.  Oh well, guess we'll blow up. */
                        *cp = *buf = 0;
                        advise (NULL, "eol encountered in field \"%s\"", name);
@@ -450,7 +435,7 @@ m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
             * characters up to the end of this field (newline
             * followed by non-blank) or bufsz-1 characters.
             */
             * characters up to the end of this field (newline
             * followed by non-blank) or bufsz-1 characters.
             */
-           cp = buf; i = bufsz-1;
+           cp = buf; i = *bufsz-1;
            for (;;) {
 #ifdef LINUX_STDIO
                cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr;
            for (;;) {
 #ifdef LINUX_STDIO
                cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr;
@@ -565,7 +550,7 @@ m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
             * we assume that we were called to copy directly into
             * the output buffer and we don't add an eos.
             */
             * we assume that we were called to copy directly into
             * the output buffer and we don't add an eos.
             */
-           i = (bufsz < 0) ? -bufsz : bufsz-1;
+           i = (*bufsz < 0) ? -*bufsz : *bufsz-1;
 #ifdef LINUX_STDIO
            bp = (unsigned char *) --iob->_IO_read_ptr;
            cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr;
 #ifdef LINUX_STDIO
            bp = (unsigned char *) --iob->_IO_read_ptr;
            cnt = (long) iob->_IO_read_end - (long) iob->_IO_read_ptr;
@@ -654,8 +639,8 @@ m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
            iob->_cnt -= c;
            iob->_ptr += c;
 #endif
            iob->_cnt -= c;
            iob->_ptr += c;
 #endif
-           if (bufsz < 0) {
-               msg_count = c;
+           if (*bufsz < 0) {
+               *bufsz = c;
                return (state);
            }
            cp = buf + c;
                return (state);
            }
            cp = buf + c;
@@ -666,7 +651,7 @@ m_getfld (int state, unsigned char name[NAMESZ], unsigned char *buf,
     }
 finish:
     *cp = 0;
     }
 finish:
     *cp = 0;
-    msg_count = cp - buf;
+    *bufsz = cp - buf;
     return (state);
 }
 
     return (state);
 }
 
diff --git a/sbr/m_msgdef.c b/sbr/m_msgdef.c
deleted file mode 100644 (file)
index 9520012..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-
-/*
- * m_msgdef.c -- some defines for sbr/m_getfld.c
- *
- * 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>
-
-/*
- * disgusting hack for "inc" so it can know how many characters
- * were stuffed in the buffer on the last call (see comments
- * in uip/scansbr.c)
- */
-int msg_count = 0;
index 1ddd648f9feeef1563452102578e9e9fd89774e6..0efc9a5ec057366bd714aea70bb2a6190b366796 100644 (file)
@@ -59,7 +59,8 @@ readconfig (struct node **npp, FILE *ib, char *file, int ctx)
     }
 
     for (state = FLD;;) {
     }
 
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, field, sizeof(field), ib)) {
+       int fieldsz = sizeof field;
+       switch (state = m_getfld (state, name, field, &fieldsz, ib)) {
            case FLD:
            case FLDPLUS:
            case FLDEOF:
            case FLD:
            case FLDPLUS:
            case FLDEOF:
@@ -70,7 +71,8 @@ readconfig (struct node **npp, FILE *ib, char *file, int ctx)
                if (state == FLDPLUS) {
                    cp = getcpy (field);
                    while (state == FLDPLUS) {
                if (state == FLDPLUS) {
                    cp = getcpy (field);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, field, sizeof(field), ib);
+                       fieldsz = sizeof field;
+                       state = m_getfld (state, name, field, &fieldsz, ib);
                        cp = add (field, cp);
                    }
                    np->n_field = trimcpy (cp);
                        cp = add (field, cp);
                    }
                    np->n_field = trimcpy (cp);
index 985c61e843a9813890e7bad71a6bcf8e0fe5c572..3cf8ad89ceed44715dadaac7e5f97f7d325d3024 100644 (file)
@@ -77,14 +77,16 @@ seq_public (struct msgs *mp)
 
     /* Use m_getfld to scan sequence file */
     for (state = FLD;;) {
 
     /* Use m_getfld to scan sequence file */
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+       int fieldsz = sizeof field;
+       switch (state = m_getfld (state, name, field, &fieldsz, fp)) {
            case FLD: 
            case FLDPLUS:
            case FLDEOF: 
                if (state == FLDPLUS) {
                    cp = getcpy (field);
                    while (state == FLDPLUS) {
            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 (state, name, field, &fieldsz, fp);
                        cp = add (field, cp);
                    }
                    seq_init (mp, getcpy (name), trimcpy (cp));
                        cp = add (field, cp);
                    }
                    seq_init (mp, getcpy (name), trimcpy (cp));
index afd4e419122a09255a9d469913b8eec2a3c9f170..bbaeaf51980a940ad792a94aeb75a6ec2c904fcb 100644 (file)
@@ -46,9 +46,9 @@ distout (char *drft, char *msgnam, char *backup)
     lseek (hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
     cpydata (hdrfd, fileno (ofp), msgnam, drft);
 
     lseek (hdrfd, (off_t) 0, SEEK_SET); /* msgnam not accurate */
     cpydata (hdrfd, fileno (ofp), msgnam, drft);
 
-    for (state = FLD, resent = NULL;;)
-       switch (state =
-               m_getfld (state, name, buffer, sizeof buffer, ifp)) {
+    for (state = FLD, resent = NULL;;) {
+       int buffersz = sizeof buffer;
+       switch (state = m_getfld (state, name, buffer, &buffersz, ifp)) {
            case FLD: 
            case FLDPLUS: 
            case FLDEOF: 
            case FLD: 
            case FLDPLUS: 
            case FLDEOF: 
@@ -65,8 +65,8 @@ distout (char *drft, char *msgnam, char *backup)
                resent = add (buffer, resent);
                fprintf (ofp, "%s: %s", name, buffer);
                while (state == FLDPLUS) {
                resent = add (buffer, resent);
                fprintf (ofp, "%s: %s", name, buffer);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name,
-                           buffer, sizeof buffer, ifp);
+                   buffersz = sizeof buffer;
+                   state = m_getfld (state, name, buffer, &buffersz, ifp);
                    resent = add (buffer, resent);
                    fputs (buffer, ofp);
                }
                    resent = add (buffer, resent);
                    fputs (buffer, ofp);
                }
@@ -99,6 +99,7 @@ distout (char *drft, char *msgnam, char *backup)
            default: 
                adios (NULL, "getfld() returned %d", state);
        }
            default: 
                adios (NULL, "getfld() returned %d", state);
        }
+    }
 process: ;
     fclose (ifp);
     fflush (ofp);
 process: ;
     fclose (ifp);
     fflush (ofp);
@@ -151,9 +152,9 @@ ready_msg (char *msgnam)
        adios (NULL, "no file descriptors -- you lose big");
     unlink (tmpfil);
 
        adios (NULL, "no file descriptors -- you lose big");
     unlink (tmpfil);
 
-    for (state = FLD;;)
-       switch (state =
-               m_getfld (state, name, buffer, sizeof buffer, ifp)) {
+    for (state = FLD;;) {
+       int buffersz = sizeof buffer;
+       switch (state = m_getfld (state, name, buffer, &buffersz, ifp)) {
            case FLD: 
            case FLDPLUS: 
            case FLDEOF: 
            case FLD: 
            case FLDPLUS: 
            case FLDEOF: 
@@ -161,8 +162,8 @@ ready_msg (char *msgnam)
                    fprintf (ofp, "Prev-");
                fprintf (ofp, "%s: %s", name, buffer);
                while (state == FLDPLUS) {
                    fprintf (ofp, "Prev-");
                fprintf (ofp, "%s: %s", name, buffer);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name,
-                           buffer, sizeof buffer, ifp);
+                   buffersz = sizeof buffer;
+                   state = m_getfld (state, name, buffer, &buffersz, ifp);
                    fputs (buffer, ofp);
                }
                if (state == FLDEOF)
                    fputs (buffer, ofp);
                }
                if (state == FLDEOF)
@@ -185,8 +186,8 @@ ready_msg (char *msgnam)
                unlink (tmpfil);
                fprintf (ofp, "\n%s", buffer);
                while (state == BODY) {
                unlink (tmpfil);
                fprintf (ofp, "\n%s", buffer);
                while (state == BODY) {
-                   state = m_getfld (state, name,
-                           buffer, sizeof buffer, ifp);
+                   buffersz = sizeof buffer;
+                   state = m_getfld (state, name, buffer, &buffersz, ifp);
                    fputs (buffer, ofp);
                }
            case FILEEOF: 
                    fputs (buffer, ofp);
                }
            case FILEEOF: 
@@ -199,6 +200,7 @@ ready_msg (char *msgnam)
            default: 
                adios (NULL, "getfld() returned %d", state);
        }
            default: 
                adios (NULL, "getfld() returned %d", state);
        }
+    }
 process: ;
     fclose (ifp);
     fclose (ofp);
 process: ;
     fclose (ifp);
     fclose (ofp);
index 86255857cecac7d9b85050485118fab8e7700d61..534c2b05f95e7539d8307a6fbda3b66d273e7fa0 100644 (file)
@@ -87,7 +87,8 @@ build_form (char *form, char *digest, int *dat, char *from, char *to,
      */
 
     for (state = FLD;;) {
      */
 
     for (state = FLD;;) {
-       state = m_getfld(state, name, msgbuf, sizeof(msgbuf), tmp);
+       int msg_count = sizeof msgbuf;
+       state = m_getfld(state, name, msgbuf, &msg_count, tmp);
        switch (state) {
            case FLD:
            case FLDPLUS:
        switch (state) {
            case FLD:
            case FLDPLUS:
@@ -101,14 +102,15 @@ build_form (char *form, char *digest, int *dat, char *from, char *to,
                if (i != -1) {
                    char_read += msg_count;
                    while (state == FLDPLUS) {
                if (i != -1) {
                    char_read += msg_count;
                    while (state == FLDPLUS) {
-                       state = m_getfld(state, name, msgbuf,
-                                        sizeof(msgbuf), tmp);
+                       msg_count = sizeof msgbuf;
+                       state = m_getfld(state, name, msgbuf, &msg_count, tmp);
                        fmt_appendcomp(i, name, msgbuf);
                        char_read += msg_count;
                    }
                }
                while (state == FLDPLUS)
                        fmt_appendcomp(i, name, msgbuf);
                        char_read += msg_count;
                    }
                }
                while (state == FLDPLUS)
-                   state = m_getfld(state, name, msgbuf, sizeof(msgbuf), tmp);
+                   msg_count = sizeof msgbuf;
+                   state = m_getfld(state, name, msgbuf, &msg_count, tmp);
                break;
 
            case LENERR:
                break;
 
            case LENERR:
index ec2c195a2c6a7ed85b05beb96e5718e24ac95531..c7164b32e457ac4c293c5caad9097007c26fe5d7 100644 (file)
@@ -163,7 +163,8 @@ build_mime (char *infile, int directives)
      * the new MIME message.
      */
     for (compnum = 1, state = FLD;;) {
      * the new MIME message.
      */
     for (compnum = 1, state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, in)) {
        case FLD:
        case FLDPLUS:
        case FLDEOF:
        case FLD:
        case FLDPLUS:
        case FLDEOF:
@@ -179,8 +180,10 @@ build_mime (char *infile, int directives)
 
            /* ignore any Content-Type fields in the header */
            if (!mh_strcasecmp (name, TYPE_FIELD)) {
 
            /* ignore any Content-Type fields in the header */
            if (!mh_strcasecmp (name, TYPE_FIELD)) {
-               while (state == FLDPLUS)
-                   state = m_getfld (state, name, buf, sizeof(buf), in);
+               while (state == FLDPLUS) {
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, in);
+               }
                goto finish_field;
            }
 
                goto finish_field;
            }
 
@@ -190,7 +193,8 @@ build_mime (char *infile, int directives)
 
            /* if necessary, get rest of field */
            while (state == FLDPLUS) {
 
            /* if necessary, get rest of field */
            while (state == FLDPLUS) {
-               state = m_getfld (state, name, buf, sizeof(buf), in);
+               bufsz = sizeof buf;
+               state = m_getfld (state, name, buf, &bufsz, in);
                vp = add (buf, vp);     /* add to previous value */
            }
 
                vp = add (buf, vp);     /* add to previous value */
            }
 
index 5f7777d0035e17a035d60685758c2a8789807272..59e27914905c3c5c4ef16021a2faef751c00c2e7 100644 (file)
@@ -383,8 +383,9 @@ find_cache_aux2 (char *mapfile, char *id, char *mapname, int namelen)
     for (state = FLD;;) {
        int result;
        char *cp, *dp;
     for (state = FLD;;) {
        int result;
        char *cp, *dp;
+       int bufsz = sizeof buf;
 
 
-       switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+       switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
            case FLD:
            case FLDPLUS:
            case FLDEOF:
            case FLD:
            case FLDPLUS:
            case FLDEOF:
@@ -394,7 +395,8 @@ find_cache_aux2 (char *mapfile, char *id, char *mapname, int namelen)
                else {
                    cp = add (buf, NULL);
                    while (state == FLDPLUS) {
                else {
                    cp = add (buf, NULL);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buf, sizeof(buf), fp);
+                       bufsz = sizeof buf;
+                       state = m_getfld (state, name, buf, &bufsz, fp);
                        cp = add (buf, cp);
                    }
                }
                        cp = add (buf, cp);
                    }
                }
index 45d99b037d1f1e585d34187dfd881ce2c7ac6661..2c24171437e4a6d826a3e445156935c4553b1bf0 100644 (file)
@@ -1015,14 +1015,16 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec)
     }
 
     for (state = FLD;;) {
     }
 
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
            case FLD: 
            case FLDPLUS: 
                bucket = fmt_addcomptext(name, buf);
                for (ip = ignores; *ip; ip++)
                    if (!mh_strcasecmp (name, *ip)) {
                        while (state == FLDPLUS) {
            case FLD: 
            case FLDPLUS: 
                bucket = fmt_addcomptext(name, buf);
                for (ip = ignores; *ip; ip++)
                    if (!mh_strcasecmp (name, *ip)) {
                        while (state == FLDPLUS) {
-                           state = m_getfld (state, name, buf, sizeof(buf), fp);
+                           bufsz = sizeof buf;
+                           state = m_getfld (state, name, buf, &bufsz, fp);
                            fmt_appendcomp(bucket, name, buf);
                        }
                        break;
                            fmt_appendcomp(bucket, name, buf);
                        }
                        break;
@@ -1044,7 +1046,8 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec)
                if (c1 == NULL)
                    c1 = add_queue (&msghd, &msgtl, name, buf, 0);
                while (state == FLDPLUS) {
                if (c1 == NULL)
                    c1 = add_queue (&msghd, &msgtl, name, buf, 0);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof(buf), fp);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, fp);
                    c1->c_text = add (buf, c1->c_text);
                    fmt_appendcomp(bucket, name, buf);
                }
                    c1->c_text = add (buf, c1->c_text);
                    fmt_appendcomp(bucket, name, buf);
                }
@@ -1083,8 +1086,9 @@ mhlfile (FILE *fp, char *mname, int ofilen, int ofilec)
                            strncpy (holder.c_text, buf, sizeof(buf));
                            while (state == BODY) {
                                putcomp (c1, &holder, BODYCOMP);
                            strncpy (holder.c_text, buf, sizeof(buf));
                            while (state == BODY) {
                                putcomp (c1, &holder, BODYCOMP);
+                               bufsz = sizeof buf;
                                state = m_getfld (state, name, holder.c_text,
                                state = m_getfld (state, name, holder.c_text,
-                                           sizeof(buf), fp);
+                                           &bufsz, fp);
                            }
                            free (holder.c_text);
                            holder.c_text = NULL;
                            }
                            free (holder.c_text);
                            holder.c_text = NULL;
@@ -1838,8 +1842,9 @@ filterbody (struct mcomp *c1, char *buf, int bufsz, int state, FILE *fp)
         */
 
        while (state == BODY) {
         */
 
        while (state == BODY) {
+           int bufsz2 = bufsz;
            write(fdinput[1], buf, strlen(buf));
            write(fdinput[1], buf, strlen(buf));
-           state = m_getfld(state, name, buf, bufsz, fp);
+           state = m_getfld(state, name, buf, &bufsz2, fp);
        }
 
        /*
        }
 
        /*
index 8cfa89980ee9e37d8fee9a61104ab107124f5aaa..ea5400e07ed2194fb50e84b37075e7ed9011de48 100644 (file)
@@ -276,7 +276,8 @@ get_content (FILE *in, char *file, int toplevel)
      * content into a linked list.
      */
     for (compnum = 1, state = FLD;;) {
      * content into a linked list.
      */
     for (compnum = 1, state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, in)) {
        case FLD:
        case FLDPLUS:
        case FLDEOF:
        case FLD:
        case FLDPLUS:
        case FLDEOF:
@@ -288,7 +289,8 @@ get_content (FILE *in, char *file, int toplevel)
 
            /* if necessary, get rest of field */
            while (state == FLDPLUS) {
 
            /* if necessary, get rest of field */
            while (state == FLDPLUS) {
-               state = m_getfld (state, name, buf, sizeof(buf), in);
+               bufsz = sizeof buf;
+               state = m_getfld (state, name, buf, &bufsz, in);
                vp = add (buf, vp);     /* add to previous value */
            }
 
                vp = add (buf, vp);     /* add to previous value */
            }
 
index b3aa3a107aec077ce57472d8c129851b197ccdca..36286e0b1d2478aad8832dd29b3b017be741b8a2 100644 (file)
--- a/uip/msh.c
+++ b/uip/msh.c
@@ -1005,15 +1005,17 @@ readid (int msgnum)
        return Msgs[msgnum].m_bboard_id;
 
     zp = msh_ready (msgnum, 0);
        return Msgs[msgnum].m_bboard_id;
 
     zp = msh_ready (msgnum, 0);
-    for (state = FLD;;)
-       switch (state = m_getfld (state, name, buf, sizeof(buf), zp)) {
+    for (state = FLD;;) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, zp)) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                if (!mh_strcasecmp (name, BBoard_ID)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                if (!mh_strcasecmp (name, BBoard_ID)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buf, sizeof(buf), zp);
+                       bufsz = sizeof buf;
+                       state = m_getfld (state, name, buf, &bufsz, zp);
                        bp = add (buf, bp);
                    }
                    i = atoi (bp);
                        bp = add (buf, bp);
                    }
                    i = atoi (bp);
@@ -1024,13 +1026,15 @@ readid (int msgnum)
                        continue;
                }
                while (state == FLDPLUS)
                        continue;
                }
                while (state == FLDPLUS)
-                   state = m_getfld (state, name, buf, sizeof(buf), zp);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, zp);
                if (state != FLDEOF)
                    continue;
 
            default: 
                return 0;
        }
                if (state != FLDEOF)
                    continue;
 
            default: 
                return 0;
        }
+    }
 }
 
 
 }
 
 
index 5f571b49796ff49b5a58467ce7ef44fe70e7d70b..c2a8a3cf53cf081a1b63d6dfca9bff07920ba135 100644 (file)
@@ -2435,8 +2435,9 @@ is_nontext (int msgnum)
 
     fp = msh_ready (msgnum, 1);
 
 
     fp = msh_ready (msgnum, 1);
 
-    for (state = FLD;;)
-       switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
+    for (state = FLD;;) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
        case FLD:
        case FLDPLUS:
        case FLDEOF:
        case FLD:
        case FLDPLUS:
        case FLDEOF:
@@ -2449,7 +2450,8 @@ is_nontext (int msgnum)
 
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
 
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof buf, fp);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, fp);
                    cp = add (buf, cp);
                }
                bp = cp;
                    cp = add (buf, cp);
                }
                bp = cp;
@@ -2552,7 +2554,8 @@ out:
            if (!mh_strcasecmp (name, ENCODING_FIELD)) {
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
            if (!mh_strcasecmp (name, ENCODING_FIELD)) {
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof buf, fp);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, fp);
                    cp = add (buf, cp);
                }
                for (bp = cp; isspace (*bp); bp++)
                    cp = add (buf, cp);
                }
                for (bp = cp; isspace (*bp); bp++)
@@ -2576,8 +2579,10 @@ out:
             * Just skip the rest of this header
             * field and go to next one.
             */
             * Just skip the rest of this header
             * field and go to next one.
             */
-           while (state == FLDPLUS)
-               state = m_getfld (state, name, buf, sizeof(buf), fp);
+           while (state == FLDPLUS) {
+               bufsz = sizeof buf;
+               state = m_getfld (state, name, buf, &bufsz, fp);
+           }
            break;
 
            /*
            break;
 
            /*
@@ -2587,6 +2592,7 @@ out:
        default:
            return 0;
        }
        default:
            return 0;
        }
+    }
 }
 
 
 }
 
 
@@ -2742,14 +2748,16 @@ get_fields (char *datesw, char *subjsw, int msgnum, struct Msg *msgp)
 
     zp = msh_ready (msgnum, 0);
     for (state = FLD;;) {
 
     zp = msh_ready (msgnum, 0);
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof buf, zp)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, zp)) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                if (!mh_strcasecmp (name, datesw)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                if (!mh_strcasecmp (name, datesw)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buf, sizeof buf, zp);
+                       bufsz = sizeof buf;
+                       state = m_getfld (state, name, buf, &bufsz, zp);
                        bp = add (buf, bp);
                    }
                    if ((tw = dparsetime (bp)) == NULL)
                        bp = add (buf, bp);
                    }
                    if ((tw = dparsetime (bp)) == NULL)
@@ -2766,7 +2774,8 @@ get_fields (char *datesw, char *subjsw, int msgnum, struct Msg *msgp)
                else if (subjsw && !mh_strcasecmp(name, subjsw)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
                else if (subjsw && !mh_strcasecmp(name, subjsw)) {
                    bp = getcpy (buf);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buf, sizeof buf, zp);
+                       bufsz = sizeof buf;
+                       state = m_getfld (state, name, buf, &bufsz, zp);
                        bp = add (buf, bp);
                    }
                    msgp->m_scanl = sosmash(subjsw, bp);
                        bp = add (buf, bp);
                    }
                    msgp->m_scanl = sosmash(subjsw, bp);
@@ -2775,8 +2784,10 @@ get_fields (char *datesw, char *subjsw, int msgnum, struct Msg *msgp)
                    else
                        subjsw = (char *)0;/* subject done, need date */
                } else {
                    else
                        subjsw = (char *)0;/* subject done, need date */
                } else {
-                   while (state == FLDPLUS)    /* flush this one */
-                       state = m_getfld (state, name, buf, sizeof buf, zp);
+                   while (state == FLDPLUS) {  /* flush this one */
+                       bufsz = sizeof buf;
+                       state = m_getfld (state, name, buf, &bufsz, zp);
+                   }
                }
                continue;
 
                }
                continue;
 
index 10854dc98ea5a4ec800248152cd41d6163520479..198207a86aef01bc467dbd328c2d12049a5a8a9d 100644 (file)
--- a/uip/new.c
+++ b/uip/new.c
@@ -105,15 +105,16 @@ get_msgnums(char *folder, char *sequences[])
 
     /* copied from seq_read.c:seq_public */
     for (state = FLD;;) {
 
     /* copied from seq_read.c:seq_public */
     for (state = FLD;;) {
-        switch (state = m_getfld (state, name, field, sizeof(field), fp)) {
+       int fieldsz = sizeof field;
+       switch (state = m_getfld (state, name, field, &fieldsz, fp)) {
             case FLD:
             case FLDPLUS:
             case FLDEOF:
                 if (state == FLDPLUS) {
                     cp = getcpy (field);
                     while (state == FLDPLUS) {
             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 (state, name, field, &fieldsz, fp);
                         cp = add (field, cp);
                     }
 
                         cp = add (field, cp);
                     }
 
index 91893e3cbf89f71138e39b0405d785bddf51a94b..d03e72be7b5f2e238bb222dc5e7624e6b23203b1 100644 (file)
@@ -947,7 +947,8 @@ plist
 
     fseek (fp, start, SEEK_SET);
     for (state = FLD, bp = NULL;;) {
 
     fseek (fp, start, SEEK_SET);
     for (state = FLD, bp = NULL;;) {
-       switch (state = m_getfld (state, name, buf, sizeof buf, fp)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
@@ -955,7 +956,8 @@ plist
                    free (bp), bp = NULL;
                bp = add (buf, NULL);
                while (state == FLDPLUS) {
                    free (bp), bp = NULL;
                bp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof buf, fp);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, fp);
                    bp = add (buf, bp);
                }
                if (!mh_strcasecmp (name, n->n_datef))
                    bp = add (buf, bp);
                }
                if (!mh_strcasecmp (name, n->n_datef))
index 6b0786192c4be04df52d3dcc1346b03a4097d3af..ffc9de803fe63ff8dee4067f83d3f31153413e44 100644 (file)
@@ -579,14 +579,16 @@ main (int argc, char **argv)
     hdrtab = msgstate == NORMAL ? NHeaders : RHeaders;
 
     for (compnum = 1, state = FLD;;) {
     hdrtab = msgstate == NORMAL ? NHeaders : RHeaders;
 
     for (compnum = 1, state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), in)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, in)) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                compnum++;
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                compnum++;
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof(buf), in);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, in);
                    cp = add (buf, cp);
                }
                putfmt (name, cp, out);
                    cp = add (buf, cp);
                }
                putfmt (name, cp, out);
@@ -603,7 +605,8 @@ main (int argc, char **argv)
                    break;
                fprintf (out, "\n%s", buf);
                while (state == BODY) {
                    break;
                fprintf (out, "\n%s", buf);
                while (state == BODY) {
-                   state = m_getfld (state, name, buf, sizeof(buf), in);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, in);
                    fputs (buf, out);
                }
                break;
                    fputs (buf, out);
                }
                break;
index 795e4724d4966061c274ef7423606896a15ad555..6b540dbca49ee5e12a336d949b4e3bd5464cddcb 100644 (file)
@@ -209,7 +209,8 @@ main (int argc, char **argv)
      * Loop through the lines of the draft skeleton.
      */
     for (state = FLD;;) {
      * Loop through the lines of the draft skeleton.
      */
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, field, sizeof(field), in)) {
+       int fieldsz = sizeof field;
+       switch (state = m_getfld (state, name, field, &fieldsz, in)) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
@@ -226,8 +227,8 @@ main (int argc, char **argv)
                    printf ("%s:%s", name, field);
                    fprintf (out, "%s:%s", name, field);
                    while (state == FLDPLUS) {
                    printf ("%s:%s", name, field);
                    fprintf (out, "%s:%s", name, field);
                    while (state == FLDPLUS) {
-                       state =
-                           m_getfld (state, name, field, sizeof(field), in);
+                       fieldsz = sizeof field;
+                       state = m_getfld (state, name, field, &fieldsz, in);
                        printf ("%s", field);
                        fprintf (out, "%s", field);
                    }
                        printf ("%s", field);
                        fprintf (out, "%s", field);
                    }
@@ -293,7 +294,8 @@ abort:
                        if (!rapid && !sigint)
                            printf ("%s", field);
                    } while (state == BODY &&
                        if (!rapid && !sigint)
                            printf ("%s", field);
                    } while (state == BODY &&
-                           (state = m_getfld (state, name, field, sizeof(field), in)));
+                           (fieldsz = sizeof field,
+                            state = m_getfld (state, name, field, &fieldsz, in)));
                    if (prepend || !body)
                        break;
                    else
                    if (prepend || !body)
                        break;
                    else
index d3f36caa594f7734c105c8a376e3b243c74013cf..fd58396a3874c0a4433bfc1403af1ce8ccdbf9d4 100644 (file)
@@ -193,21 +193,25 @@ rcvdistout (FILE *inb, char *form, char *addrs)
        cptr->c_text = addrs;
 
     for (state = FLD;;) {
        cptr->c_text = addrs;
 
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb)) {
+       int msg_count = SBUFSIZ;
+       switch (state = m_getfld (state, name, tmpbuf, &msg_count, inb)) {
            case FLD: 
            case FLDPLUS: 
                i = fmt_addcomptext(name, tmpbuf);
                if (i != -1) {
                    char_read += msg_count;
                    while (state == FLDPLUS) {
            case FLD: 
            case FLDPLUS: 
                i = fmt_addcomptext(name, tmpbuf);
                if (i != -1) {
                    char_read += msg_count;
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+                       msg_count = SBUFSIZ;
+                       state = m_getfld (state, name, tmpbuf, &msg_count, inb);
                        fmt_appendcomp(i, name, tmpbuf);
                        char_read += msg_count;
                    }
                }
 
                        fmt_appendcomp(i, name, tmpbuf);
                        char_read += msg_count;
                    }
                }
 
-               while (state == FLDPLUS)
-                   state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+               while (state == FLDPLUS) {
+                   msg_count = SBUFSIZ;
+                   state = m_getfld (state, name, tmpbuf, &msg_count, inb);
+               }
                break;
 
            case LENERR: 
                break;
 
            case LENERR: 
index 3dbc3031ee614874f3a941ea45dd048321b4590c..dc3c4f8c36c5ccda1a3effd29a4a21a501effe88 100644 (file)
@@ -132,7 +132,8 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
      * pick any interesting stuff out of msg "inb"
      */
     for (state = FLD;;) {
      * pick any interesting stuff out of msg "inb"
      */
     for (state = FLD;;) {
-       state = m_getfld (state, name, tmpbuf, sizeof(tmpbuf), inb);
+       int msg_count = sizeof tmpbuf;
+       state = m_getfld (state, name, tmpbuf, &msg_count, inb);
        switch (state) {
            case FLD: 
            case FLDPLUS: 
        switch (state) {
            case FLD: 
            case FLDPLUS: 
@@ -147,15 +148,17 @@ replout (FILE *inb, char *msg, char *drft, struct msgs *mp, int outputlinelen,
                if (i != -1) {
                    char_read += msg_count;
                    while (state == FLDPLUS) {
                if (i != -1) {
                    char_read += msg_count;
                    while (state == FLDPLUS) {
-                       state = m_getfld(state, name, tmpbuf,
-                                        sizeof(tmpbuf), inb);
+                       msg_count= sizeof tmpbuf;
+                       state = m_getfld(state, name, tmpbuf, &msg_count, inb);
                        fmt_appendcomp(i, name, tmpbuf);
                        char_read += msg_count;
                    }
                }
 
                        fmt_appendcomp(i, name, tmpbuf);
                        char_read += msg_count;
                    }
                }
 
-               while (state == FLDPLUS)
-                   state = m_getfld (state, name, tmpbuf, SBUFSIZ, inb);
+               while (state == FLDPLUS) {
+                   msg_count= sizeof tmpbuf;
+                   state = m_getfld (state, name, tmpbuf, &msg_count, inb);
+               }
                break;
 
            case LENERR: 
                break;
 
            case LENERR: 
index 232a41906e99d4524e68440a240ff0d50a44914c..a023e9146d9fb0346c26fcce71647ac60240235c 100644 (file)
@@ -68,6 +68,7 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
     char *scnmsg = NULL;
     FILE *scnout = NULL;
     char name[NAMESZ];
     char *scnmsg = NULL;
     FILE *scnout = NULL;
     char name[NAMESZ];
+    int bufsz;
     static int rlwidth, slwidth;
     static size_t scanl_size;
 
     static int rlwidth, slwidth;
     static size_t scanl_size;
 
@@ -162,7 +163,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
      * Get the first field.  If the message is non-empty
      * and we're doing an "inc", open the output file.
      */
      * Get the first field.  If the message is non-empty
      * and we're doing an "inc", open the output file.
      */
-    if ((state = m_getfld (FLD, name, tmpbuf, rlwidth, inb)) == FILEEOF) {
+    bufsz = rlwidth;
+    if ((state = m_getfld (FLD, name, tmpbuf, &bufsz, inb)) == FILEEOF) {
        if (ferror(inb)) {
            advise("read", "unable to"); /* "read error" */
            return SCNFAT;
        if (ferror(inb)) {
            advise("read", "unable to"); /* "read error" */
            return SCNFAT;
@@ -184,7 +186,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
     }
 
     /* scan - main loop */
     }
 
     /* scan - main loop */
-    for (compnum = 1; ; state = m_getfld (state, name, tmpbuf, rlwidth, inb)) {
+    for (compnum = 1; ;
+        bufsz = rlwidth, state = m_getfld (state, name, tmpbuf, &bufsz, inb)) {
        switch (state) {
            case FLD: 
            case FLDPLUS: 
        switch (state) {
            case FLD: 
            case FLDPLUS: 
@@ -215,7 +218,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
                }
 
                while (state == FLDPLUS) {
                }
 
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, tmpbuf, rlwidth, inb);
+                   bufsz = rlwidth;
+                   state = m_getfld (state, name, tmpbuf, &bufsz, inb);
                    if (outnum)
                        FPUTS (tmpbuf);
                }
                    if (outnum)
                        FPUTS (tmpbuf);
                }
@@ -229,8 +233,8 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
                 */
 
                if ((i = strlen(tmpbuf)) < rlwidth) {
                 */
 
                if ((i = strlen(tmpbuf)) < rlwidth) {
-                   state = m_getfld (state, name, tmpbuf + i,
-                                     rlwidth - i, inb);
+                   bufsz = rlwidth - i;
+                   state = m_getfld (state, name, tmpbuf + i, &bufsz, inb);
                }
 
                if (! outnum) {
                }
 
                if (! outnum) {
@@ -264,7 +268,8 @@ body:;
                }
 
                while (state == BODY) {
                }
 
                while (state == BODY) {
-                   state = m_getfld(state, name, tmpbuf, rlwidth, inb);
+                   bufsz = rlwidth;
+                   state = m_getfld(state, name, tmpbuf, &bufsz, inb);
                    FPUTS(tmpbuf);
                }
                goto finished;
                    FPUTS(tmpbuf);
                }
                goto finished;
index dfd974f481694c9b9d6763cd450038ab2caa884f..a7dc0ea50fa3677baa2df09152aa052609fd67a9 100644 (file)
@@ -603,7 +603,8 @@ splitmsg (char **vec, int vecp, char *drft, struct stat *st, int delay)
      * as well as locate the beginning of the message body.
      */
     for (compnum = 1, state = FLD;;) {
      * as well as locate the beginning of the message body.
      */
     for (compnum = 1, state = FLD;;) {
-       switch (state = m_getfld (state, name, buffer, sizeof(buffer), in)) {
+       int bufsz = sizeof buffer;
+       switch (state = m_getfld (state, name, buffer, &bufsz, in)) {
            case FLD:
            case FLDPLUS:
            case FLDEOF:
            case FLD:
            case FLDPLUS:
            case FLDEOF:
@@ -613,8 +614,10 @@ splitmsg (char **vec, int vecp, char *drft, struct stat *st, int delay)
                 * This header field is discarded.
                 */
                if (!mh_strcasecmp (name, "Message-ID")) {
                 * This header field is discarded.
                 */
                if (!mh_strcasecmp (name, "Message-ID")) {
-                   while (state == FLDPLUS)
-                       state = m_getfld (state, name, buffer, sizeof(buffer), in);
+                   while (state == FLDPLUS) {
+                       bufsz = sizeof buffer;
+                       state = m_getfld (state, name, buffer, &bufsz, in);
+                   }
                } else if (uprf (name, XXX_FIELD_PRF)
                        || !mh_strcasecmp (name, VRSN_FIELD)
                        || !mh_strcasecmp (name, "Subject")
                } else if (uprf (name, XXX_FIELD_PRF)
                        || !mh_strcasecmp (name, VRSN_FIELD)
                        || !mh_strcasecmp (name, "Subject")
@@ -638,7 +641,8 @@ splitmsg (char **vec, int vecp, char *drft, struct stat *st, int delay)
 
                    dp = add (concat (name, ":", buffer, NULL), dp);
                    while (state == FLDPLUS) {
 
                    dp = add (concat (name, ":", buffer, NULL), dp);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buffer, sizeof(buffer), in);
+                       bufsz = sizeof buffer;
+                       state = m_getfld (state, name, buffer, &bufsz, in);
                        dp = add (buffer, dp);
                    }
                } else {
                        dp = add (buffer, dp);
                    }
                } else {
@@ -648,7 +652,8 @@ splitmsg (char **vec, int vecp, char *drft, struct stat *st, int delay)
                     */
                    cp = add (concat (name, ":", buffer, NULL), cp);
                    while (state == FLDPLUS) {
                     */
                    cp = add (concat (name, ":", buffer, NULL), cp);
                    while (state == FLDPLUS) {
-                       state = m_getfld (state, name, buffer, sizeof(buffer), in);
+                       bufsz = sizeof buffer;
+                       state = m_getfld (state, name, buffer, &bufsz, in);
                        cp = add (buffer, cp);
                    }
                }
                        cp = add (buffer, cp);
                    }
                }
index 849421647bcb4d8420a2663be9ca6142effa6cbe..ad7504623352f21723bdf186f79dce3b1631d7ea 100644 (file)
@@ -353,7 +353,8 @@ is_nontext (char *msgnam)
        return 0;
 
     for (state = FLD;;) {
        return 0;
 
     for (state = FLD;;) {
-       switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
        case FLD:
        case FLDPLUS:
        case FLDEOF:
        case FLD:
        case FLDPLUS:
        case FLDEOF:
@@ -366,7 +367,8 @@ is_nontext (char *msgnam)
 
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
 
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof(buf), fp);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, fp);
                    cp = add (buf, cp);
                }
                bp = cp;
                    cp = add (buf, cp);
                }
                bp = cp;
@@ -469,7 +471,8 @@ out:
            if (!mh_strcasecmp (name, ENCODING_FIELD)) {
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
            if (!mh_strcasecmp (name, ENCODING_FIELD)) {
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof(buf), fp);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, fp);
                    cp = add (buf, cp);
                }
                for (bp = cp; isspace (*bp); bp++)
                    cp = add (buf, cp);
                }
                for (bp = cp; isspace (*bp); bp++)
@@ -493,8 +496,10 @@ out:
             * Just skip the rest of this header
             * field and go to next one.
             */
             * Just skip the rest of this header
             * field and go to next one.
             */
-           while (state == FLDPLUS)
-               state = m_getfld (state, name, buf, sizeof(buf), fp);
+           while (state == FLDPLUS) {
+               bufsz = sizeof buf;
+               state = m_getfld (state, name, buf, &bufsz, fp);
+           }
            break;
 
            /*
            break;
 
            /*
index 869fa17f81a3a4ca51816059451d6e597e44af33..5eadea45fee8885a6df489eefd41f1f4c0face07 100644 (file)
@@ -740,13 +740,15 @@ parse (int fd)
      * a lookup table.
      */
     for (i = 0, state = FLD;;) {
      * a lookup table.
      */
     for (i = 0, state = FLD;;) {
-       switch (state = m_getfld (state, name, field, sizeof(field), in)) {
+       int fieldsz = sizeof field;
+       switch (state = m_getfld (state, name, field, &fieldsz, in)) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                lp = add (field, NULL);
                while (state == FLDPLUS) {
            case FLD: 
            case FLDEOF: 
            case FLDPLUS: 
                lp = add (field, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, field, sizeof(field), in);
+                   fieldsz = sizeof field;
+                   state = m_getfld (state, name, field, &fieldsz, in);
                    lp = add (field, lp);
                }
                for (p = hdrs; p->p_name; p++) {
                    lp = add (field, lp);
                }
                for (p = hdrs; p->p_name; p++) {
@@ -1424,21 +1426,25 @@ suppress_duplicates (int fd, char *file)
     rewind (in);
 
     for (state = FLD;;) {
     rewind (in);
 
     for (state = FLD;;) {
-       state = m_getfld (state, name, buf, sizeof(buf), in);
+       int bufsz = sizeof buf;
+       state = m_getfld (state, name, buf, &bufsz, in);
        switch (state) {
            case FLD:
            case FLDPLUS:
            case FLDEOF:
                /* Search for the message ID */
                if (mh_strcasecmp (name, "Message-ID")) {
        switch (state) {
            case FLD:
            case FLDPLUS:
            case FLDEOF:
                /* Search for the message ID */
                if (mh_strcasecmp (name, "Message-ID")) {
-                   while (state == FLDPLUS)
-                       state = m_getfld (state, name, buf, sizeof(buf), in);
+                   while (state == FLDPLUS) {
+                       bufsz = sizeof buf;
+                       state = m_getfld (state, name, buf, &bufsz, in);
+                   }
                    continue;
                }
 
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
                    continue;
                }
 
                cp = add (buf, NULL);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, name, buf, sizeof(buf), in);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, in);
                    cp = add (buf, cp);
                }
                key.dptr = trimcpy (cp);
                    cp = add (buf, cp);
                }
                key.dptr = trimcpy (cp);
index 024fcf5c4c20643633a52cd8395b56fd9ffc6d14..95c76b5f8d2e6eba51d43dd62a4038ea138b8d88 100644 (file)
@@ -371,7 +371,8 @@ get_fields (char *datesw, int msg, struct smsg *smsg)
        return (0);
     }
     for (compnum = 1, state = FLD;;) {
        return (0);
     }
     for (compnum = 1, state = FLD;;) {
-       switch (state = m_getfld (state, nam, buf, sizeof(buf), in)) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, nam, buf, &bufsz, in)) {
        case FLD:
        case FLDEOF:
        case FLDPLUS:
        case FLD:
        case FLDEOF:
        case FLDPLUS:
@@ -379,7 +380,8 @@ get_fields (char *datesw, int msg, struct smsg *smsg)
            if (!mh_strcasecmp (nam, datesw)) {
                datecomp = add (buf, datecomp);
                while (state == FLDPLUS) {
            if (!mh_strcasecmp (nam, datesw)) {
                datecomp = add (buf, datecomp);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, nam, buf, sizeof(buf), in);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, nam, buf, &bufsz, in);
                    datecomp = add (buf, datecomp);
                }
                if (!subjsort || subjcomp)
                    datecomp = add (buf, datecomp);
                }
                if (!subjsort || subjcomp)
@@ -387,15 +389,18 @@ get_fields (char *datesw, int msg, struct smsg *smsg)
            } else if (subjsort && !mh_strcasecmp (nam, subjsort)) {
                subjcomp = add (buf, subjcomp);
                while (state == FLDPLUS) {
            } else if (subjsort && !mh_strcasecmp (nam, subjsort)) {
                subjcomp = add (buf, subjcomp);
                while (state == FLDPLUS) {
-                   state = m_getfld (state, nam, buf, sizeof(buf), in);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, nam, buf, &bufsz, in);
                    subjcomp = add (buf, subjcomp);
                }
                if (datecomp)
                    break;
            } else {
                /* just flush this guy */
                    subjcomp = add (buf, subjcomp);
                }
                if (datecomp)
                    break;
            } else {
                /* just flush this guy */
-               while (state == FLDPLUS)
-                   state = m_getfld (state, nam, buf, sizeof(buf), in);
+               while (state == FLDPLUS) {
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, nam, buf, &bufsz, in);
+               }
            }
            continue;
 
            }
            continue;
 
index 389053727c45213dcdfc0c525e39c41a2a5c358f..a56446f8c6f482375ea802c9153a5b7f12bc94b4 100644 (file)
@@ -941,8 +941,9 @@ check_draft (char *msgnam)
 
     if ((fp = fopen (msgnam, "r")) == NULL)
        return 0;
 
     if ((fp = fopen (msgnam, "r")) == NULL)
        return 0;
-    for (state = FLD;;)
-       switch (state = m_getfld (state, name, buf, sizeof(buf), fp)) {
+    for (state = FLD;;) {
+       int bufsz = sizeof buf;
+       switch (state = m_getfld (state, name, buf, &bufsz, fp)) {
            case FLD:
            case FLDPLUS:
            case FLDEOF:
            case FLD:
            case FLDPLUS:
            case FLDEOF:
@@ -955,8 +956,10 @@ check_draft (char *msgnam)
                    fclose (fp);
                    return 0;
                }
                    fclose (fp);
                    return 0;
                }
-               while (state == FLDPLUS)
-                   state = m_getfld (state, name, buf, sizeof(buf), fp);
+               while (state == FLDPLUS) {
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, fp);
+               }
                break;
 
            case BODY:
                break;
 
            case BODY:
@@ -969,7 +972,8 @@ check_draft (char *msgnam)
                            return 1;
                        }
 
                            return 1;
                        }
 
-                   state = m_getfld (state, name, buf, sizeof(buf), fp);
+                   bufsz = sizeof buf;
+                   state = m_getfld (state, name, buf, &bufsz, fp);
                } while (state == BODY);
                /* and fall... */
 
                } while (state == BODY);
                /* and fall... */
 
@@ -977,6 +981,7 @@ check_draft (char *msgnam)
                fclose (fp);
                return 0;
        }
                fclose (fp);
                return 0;
        }
+    }
 }
 
 
 }