Convert inc and scan from m_getfld() to m_getfld2()
[mmh] / uip / inc.c
index f08fb4f..5f08df4 100644 (file)
--- a/uip/inc.c
+++ b/uip/inc.c
@@ -358,10 +358,25 @@ main(int argc, char **argv)
                fflush(stdout);
        }
 
+       /* check if readable and nonempty */
+       if (!fgets(buf, sizeof(buf), in)) {
+               if (ferror(in)) {
+                       advise("read", "unable to");
+                       incerr = SCNFAT;
+               } else {
+                       incerr = SCNEOF;
+               }
+               goto giveup;
+       }
+       if (strncmp("From ", buf, 5)!=0) {
+               advise(NULL, "not in mbox format");
+               incerr = SCNFAT;
+               goto giveup;
+       }
+
        /*
        ** Get the mail from file (usually mail spool)
        */
-       thisisanmbox(in);
        hghnum = msgnum = mp->hghmsg;
        for (;;) {
                /*
@@ -429,6 +444,7 @@ main(int argc, char **argv)
                */
                break;
        }
+giveup:;
        free(maildir_copy);
 
        if (incerr < 0) {  /* error */