]> diplodocus.org Git - nmh/blobdiff - uip/mhparse.c
Replace `if (p) free(p)' with `mh_xfree(p)'.
[nmh] / uip / mhparse.c
index 5dae9fd7060a61a54980185b36cdcd3877a5fd82..0c2c17cd49b01e797c50ee3928192f76245ecc2f 100644 (file)
@@ -330,7 +330,15 @@ get_content (FILE *in, char *file, int toplevel)
            continue;
 
        case BODY:
-           ct->c_begin = ftell (in) - strlen (buf);
+           if (name[0] == ':') {
+               /* Special case:  no blank line between header and body.  The
+                  file position indicator is on the newline at the end of the
+                  line, but it needs to be one prior to the beginning of the
+                  line.  So subtract the length of the line, bufsz, plus 1. */
+               ct->c_begin = ftell (in) - (bufsz + 1);
+           } else {
+               ct->c_begin = ftell (in) - (bufsz - 1);
+           }
            break;
 
        case FILEEOF:
@@ -652,8 +660,7 @@ get_ctinfo (char *cp, CT ct, int magic)
 
     /* down case the content type string */
     for (dp = ci->ci_type; *dp; dp++)
-       if (isalpha((unsigned char) *dp) && isupper ((unsigned char) *dp))
-           *dp = tolower ((unsigned char) *dp);
+        *dp = tolower ((unsigned char) *dp);
 
     while (isspace ((unsigned char) *cp))
        cp++;
@@ -691,8 +698,7 @@ get_ctinfo (char *cp, CT ct, int magic)
 
     /* down case the content subtype string */
     for (dp = ci->ci_subtype; *dp; dp++)
-       if (isalpha((unsigned char) *dp) && isupper ((unsigned char) *dp))
-           *dp = tolower ((unsigned char) *dp);
+        *dp = tolower ((unsigned char) *dp);
 
 magic_skip:
     while (isspace ((unsigned char) *cp))
@@ -3291,8 +3297,7 @@ parse_header_attrs (const char *filename, const char *fieldname,
 
        /* down case the attribute name */
        for (dp = cp; istoken ((unsigned char) *dp); dp++)
-           if (isalpha((unsigned char) *dp) && isupper ((unsigned char) *dp))
-               *dp = tolower ((unsigned char) *dp);
+            *dp = tolower ((unsigned char) *dp);
 
        for (up = dp; isspace ((unsigned char) *dp);)
            dp++;
@@ -4243,6 +4248,10 @@ noiconv:
     q = buffer;
     bufsize = sizeof(buffer);
     for (p = pm->pm_value; *p != '\0' && bufsize > 1; p++, q++, bufsize--) {
+        /* FIXME: !iscntrl should perhaps be isprint as that allows all
+         * classes bar cntrl, whereas the cntrl class can include those
+         * in space and blank.
+         * http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html */
        if (isascii((unsigned char) *p) && !iscntrl((unsigned char) *p))
            *q = *p;
        else