]> diplodocus.org Git - nmh/blobdiff - uip/mhbuildsbr.c
Expanded mhpath(1) man page discussion of its handling of out-of-range
[nmh] / uip / mhbuildsbr.c
index d96e0d540293f450b1e05ca5a7c65d5e454ccfdf..df9bf5b75dd07ff6dc04d868837b469b3beb68fa 100644 (file)
@@ -129,7 +129,7 @@ static void directive_pop(void)
  */
 
 CT
-build_mime (char *infile, int directives, int header_encoding)
+build_mime (char *infile, int autobuild, int directives, int header_encoding)
 {
     int        compnum, state;
     char buf[BUFSIZ], name[NAMESZ];
@@ -176,13 +176,16 @@ build_mime (char *infile, int directives, int header_encoding)
        case FLDPLUS:
            compnum++;
 
-           /* abort if draft has Mime-Version header field */
-           if (!strcasecmp (name, VRSN_FIELD))
-               adios (NULL, "draft shouldn't contain %s: field", VRSN_FIELD);
-
-           /* abort if draft has Content-Transfer-Encoding header field */
-           if (!strcasecmp (name, ENCODING_FIELD))
-               adios (NULL, "draft shouldn't contain %s: field", ENCODING_FIELD);
+           /* abort if draft has Mime-Version or C-T-E header field */
+           if (strcasecmp (name, VRSN_FIELD) == 0 ||
+               strcasecmp (name, ENCODING_FIELD) == 0) {
+               if (autobuild) {
+                   fclose(in);
+                   return NULL;
+               } else {
+                   adios (NULL, "draft shouldn't contain %s: field", name);
+               }
+           }
 
            /* ignore any Content-Type fields in the header */
            if (!strcasecmp (name, TYPE_FIELD)) {
@@ -248,12 +251,10 @@ finish_field:
            /* if this wasn't the last header field, then continue */
            continue;
 
-       case FILEEOF:
-           adios (NULL, "draft has empty body -- no directives!");
-           /* NOTREACHED */
-
        case BODY:
            fseek (in, (long) (-strlen (buf)), SEEK_CUR);
+           /* fall through */
+       case FILEEOF:
            break;
 
        case LENERR: