Fix spelling and encoding errors in manpages and an error message
[mmh] / uip / send.c
index ec9b76d..619ff62 100644 (file)
@@ -162,7 +162,7 @@ main(int argc, char **argv)
                for (nmsgs = 0, msgnum = mp->lowsel;
                                msgnum <= mp->hghsel; msgnum++) {
                        if (is_selected(mp, msgnum)) {
-                               files[nfiles++] = getcpy(m_name(msgnum));
+                               files[nfiles++] = mh_xstrdup(m_name(msgnum));
                                unset_exists(mp, msgnum);
                        }
                }
@@ -196,7 +196,7 @@ main(int argc, char **argv)
                        adios(EX_IOERR, altmsg, "unable to open for reading");
                }
                fstat(in, &st2);
-               distfile = getcpy(m_mktemp2(NULL, invo_name, NULL, NULL));
+               distfile = mh_xstrdup(m_mktemp2(NULL, invo_name, NULL, NULL));
                if ((out = creat(distfile, (int)st2.st_mode & 0777))==NOTOK) {
                        adios(EX_IOERR, distfile, "unable to open for writing");
                }
@@ -320,13 +320,26 @@ sendsbr(char **vec, int vecp, char *drft, struct stat *st)
 }
 
 static int
+contains_non_ascii(char *str)
+{
+       unsigned char *cp;
+
+       for (cp = str; *cp; cp++) {
+               if (*cp > 127) {
+                       return 1;
+               }
+       }
+       return 0;
+}
+
+static int
 attach(char *draft_file_name)
 {
        char buf[MAXPATHLEN + 6];
        int c;
        int has_attachment;
-       int has_body;
-       int non_ascii; /* msg body contains non-ASCII chars */
+       int has_body = 0;
+       int non_ascii = 0; /* msg body or hdr contains non-ASCII chars */
        int length;  /* length of attachment header field name */
        char *p;
 
@@ -335,7 +348,7 @@ attach(char *draft_file_name)
        }
 
        /* We'll grow the buffer as needed. */
-       field = (char *)mh_xmalloc(field_size = 256);
+       field = mh_xcalloc(field_size = 256, sizeof(char));
 
        /*
        ** Scan the draft file for an attachment header field name.
@@ -347,6 +360,9 @@ attach(char *draft_file_name)
                                field[length] == ':') {
                        has_attachment = 1;
                }
+               if (contains_non_ascii(field)) {
+                       non_ascii = 1;
+               }
        }
 
        /*
@@ -355,16 +371,14 @@ attach(char *draft_file_name)
        ** Check if body contains at least one non-blank (= not empty)
        ** and if it contains any non-ASCII chars (= need MIME).
        */
-       has_body = 0;
-       non_ascii = 0;
        while (get_line() != EOF) {
-               for (p = field; *p != '\0'; p++) {
-                       if (*p != ' ' && *p != '\t') {
+               if (contains_non_ascii(field)) {
+                       non_ascii = 1;
+               }
+               for (p = field; *p; p++) {
+                       if (isgraph(*p)) {
                                has_body = 1;
                        }
-                       if (*p > 127 || *p < 0) {
-                               non_ascii = 1;
-                       }
                }
                if (has_body && non_ascii) {
                        break;  /* that's been already enough information */
@@ -470,7 +484,7 @@ signandenc(char *draft_file_name)
        }
 
        /* We'll grow the buffer as needed. */
-       field = (char *)mh_xmalloc(field_size = 256);
+       field = mh_xcalloc(field_size = 256, sizeof(char));
 
        /* Scan the draft file for an attachment header field name. */
        while (get_line() != EOF && *field != '\0' && *field != '-') {
@@ -539,7 +553,7 @@ get_line(void)
                        break;
                }
                if (++n >= field_size - 1) {
-                       field = (char *)mh_xrealloc(field, field_size += 256);
+                       field = mh_xrealloc(field, field_size += 256);
                        p = field + n - 1;
                }
        }