]> diplodocus.org Git - nmh/blobdiff - uip/scansbr.c
sbr/mts.c: Delete mmdlm2; use same-valued mmdlm1 instead.
[nmh] / uip / scansbr.c
index 8d2a46d2e1921d90692dcfe91044d19d913cc08a..569991ec8ee569f81540d6fea3af3e606bf46ab8 100644 (file)
@@ -1,6 +1,4 @@
-
-/*
- * scansbr.c -- routines to help scan along...
+/* scansbr.c -- routines to help scan along...
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
  *
  * This code is Copyright (c) 2002, by the authors of nmh.  See the
  * COPYRIGHT file in the root directory of the nmh distribution for
 #include <h/tws.h>
 #include <h/utils.h>
 
 #include <h/tws.h>
 #include <h/utils.h>
 
-/*
- * Buffer size for content part of header fields.  We want this
- * to be large enough so that we don't do a lot of extra FLDPLUS
- * calls on m_getfld but small enough so that we don't snarf
- * the entire message body when we're only going to display 30
- * characters of it.
- */
-#define SBUFSIZ 512
-
 static struct format *fmt;
 static struct comp *datecomp;          /* pntr to "date" comp             */
 static struct comp *bodycomp;          /* pntr to "body" pseudo-comp      *
 static struct format *fmt;
 static struct comp *datecomp;          /* pntr to "date" comp             */
 static struct comp *bodycomp;          /* pntr to "body" pseudo-comp      *
@@ -38,15 +27,10 @@ static m_getfld_state_t gstate;             /* for accessor functions below    */
 #define DIEWRERR() adios (scnmsg, "write error on")
 
 #define FPUTS(buf) {\
 #define DIEWRERR() adios (scnmsg, "write error on")
 
 #define FPUTS(buf) {\
-               if (mh_fputs(buf,scnout) == EOF)\
+               if (fputs(buf,scnout) == EOF)\
                    DIEWRERR();\
                }
 
                    DIEWRERR();\
                }
 
-/*
- * prototypes
- */
-static int mh_fputs(char *, FILE *);
-
 int
 scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
       int unseen, char *folder, long size, int noisy, charstring_t *scanl)
 int
 scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
       int unseen, char *folder, long size, int noisy, charstring_t *scanl)
@@ -75,7 +59,7 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
            width = INT_MAX;
        }
        dat[3] = slwidth = width;
            width = INT_MAX;
        }
        dat[3] = slwidth = width;
-       *scanl = charstring_create (width < NMH_BUFSIZ ? width : NMH_BUFSIZ);
+        *scanl = charstring_create (min(width, NMH_BUFSIZ));
        if (outnum)
            umask(~m_gmprot());
 
        if (outnum)
            umask(~m_gmprot());
 
@@ -129,9 +113,7 @@ scan (FILE *inb, int innum, int outnum, char *nfs, int width, int curflg,
        nxtbuf = compbuffers = mh_xcalloc(ncomps, sizeof *nxtbuf);
        used_buf = mh_xcalloc(ncomps + 1, sizeof *used_buf);
        used_buf += ncomps+1; *--used_buf = 0;
        nxtbuf = compbuffers = mh_xcalloc(ncomps, sizeof *nxtbuf);
        used_buf = mh_xcalloc(ncomps + 1, sizeof *used_buf);
        used_buf += ncomps+1; *--used_buf = 0;
-       rlwidth = bodycomp && (width > SBUFSIZ)
-           ? min (width, NMH_BUFSIZ)
-           : SBUFSIZ;
+       rlwidth = NMH_BUFSIZ;
        for (i = ncomps; i--; )
            *nxtbuf++ = mh_xmalloc(rlwidth);
     }
        for (i = ncomps; i--; )
            *nxtbuf++ = mh_xmalloc(rlwidth);
     }
@@ -278,7 +260,7 @@ body:;
                    state = BODY;
                    goto body;
                }
                    state = BODY;
                    goto body;
                }
-               /* fall through */
+               goto finished;
 
            case FILEEOF:
                goto finished;
 
            case FILEEOF:
                goto finished;
@@ -352,20 +334,9 @@ finished:
 }
 
 
 }
 
 
-static int
-mh_fputs(char *s, FILE *stream)
-{
-    char c;
-
-    while ((c = *s++)) 
-       if (putc (c,stream) == EOF )
-           return(EOF);
-    return (0);
-}
-
 /* The following two functions allow access to the global gstate above. */
 void
 /* The following two functions allow access to the global gstate above. */
 void
-scan_finished () {
+scan_finished(void) {
     m_getfld_state_destroy (&gstate);
 }
 
     m_getfld_state_destroy (&gstate);
 }