fixed bug of putting Status: line in wrong place for non
authorKurt A. Schoens <kas@ucbvax.Berkeley.EDU>
Sat, 14 Mar 1981 04:44:54 +0000 (20:44 -0800)
committerKurt A. Schoens <kas@ucbvax.Berkeley.EDU>
Sat, 14 Mar 1981 04:44:54 +0000 (20:44 -0800)
Arpanetish messages

SCCS-vsn: usr.bin/mail/send.c 1.4

usr/src/usr.bin/mail/send.c

index 8750dd2..9c128fd 100644 (file)
@@ -4,6 +4,7 @@
 #ifdef VMUNIX
 #include <wait.h>
 #endif
 #ifdef VMUNIX
 #include <wait.h>
 #endif
+#include <ctype.h>
 
 /*
  * Mail -- a mail program
 
 /*
  * Mail -- a mail program
@@ -11,7 +12,7 @@
  * Mail to others.
  */
 
  * Mail to others.
  */
 
-static char *SccsId = "@(#)send.c      1.3 %G%";
+static char *SccsId = "@(#)send.c      1.4 %G%";
 
 /*
  * Send message described by the passed pointer to the
 
 /*
  * Send message described by the passed pointer to the
@@ -29,25 +30,39 @@ send(mailp, obuf)
        unsigned int c;
        FILE *ibuf;
        char line[LINESIZE];
        unsigned int c;
        FILE *ibuf;
        char line[LINESIZE];
-       int lc, ishead;
+       int lc, ishead, infld, fline;
 
        mp = mailp;
        ibuf = setinput(mp);
        c = msize(mp);
        ishead = (mailp->m_flag & MSTATUS) != 0;
 
        mp = mailp;
        ibuf = setinput(mp);
        c = msize(mp);
        ishead = (mailp->m_flag & MSTATUS) != 0;
+       infld = 0;
+       fline = 1;
        lc = 0;
        while (c > 0) {
                fgets(line, LINESIZE, ibuf);
                c -= strlen(line);
                lc++;
                if (ishead) {
        lc = 0;
        while (c > 0) {
                fgets(line, LINESIZE, ibuf);
                c -= strlen(line);
                lc++;
                if (ishead) {
+                       if (fline) {
+                               fline = 0;
+                               goto writeit;
+                       }
                        if (line[0] == '\n') {
                                statusput(mailp, obuf);
                                ishead = 0;
                                goto writeit;
                        }
                        if (line[0] == '\n') {
                                statusput(mailp, obuf);
                                ishead = 0;
                                goto writeit;
                        }
-                       if (index(line, ':') == 0)
+                       if (isspace(line[0]) && infld)
+                               goto writeit;
+                       infld = 0;
+                       if (!headerp(line)) {
+                               statusput(mailp, obuf);
+                               putc('\n', obuf);
+                               ishead = 0;
                                goto writeit;
                                goto writeit;
+                       }
+                       infld++;
                        if (icisname(line, "status", 6)) {
                                statusput(mailp, obuf);
                                ishead = 0;
                        if (icisname(line, "status", 6)) {
                                statusput(mailp, obuf);
                                ishead = 0;
@@ -66,6 +81,21 @@ writeit:
        return(lc);
 }
 
        return(lc);
 }
 
+/*
+ * Test if the passed line is a header line, RFC 733 style.
+ */
+headerp(line)
+       register char *line;
+{
+       register char *cp = line;
+
+       while (*cp && !isspace(*cp) && *cp != ':')
+               cp++;
+       while (*cp && isspace(*cp))
+               cp++;
+       return(*cp == ':');
+}
+
 /*
  * Output a reasonable looking status field.
  */
 /*
  * Output a reasonable looking status field.
  */