changed alloca to salloc since no alloca on pdp-11's, generally
[unix-history] / usr / src / usr.bin / mail / fio.c
index 7c4a934..8fb39d2 100644 (file)
@@ -10,7 +10,7 @@
  * File I/O.
  */
 
  * File I/O.
  */
 
-static char *SccsId = "@(#)fio.c       2.2 %G%";
+static char *SccsId = "@(#)fio.c       2.10 %G%";
 
 /*
  * Set up the input pointers while copying the mail file into
 
 /*
  * Set up the input pointers while copying the mail file into
@@ -42,7 +42,7 @@ setptr(ibuf)
                cp = linebuf;
                c = getc(ibuf);
                while (c != EOF && c != '\n') {
                cp = linebuf;
                c = getc(ibuf);
                while (c != EOF && c != '\n') {
-                       if (cp - linebuf >= BUFSIZ - 1) {
+                       if (cp - linebuf >= LINESIZE - 1) {
                                ungetc(c, ibuf);
                                *cp = 0;
                                break;
                                ungetc(c, ibuf);
                                *cp = 0;
                                break;
@@ -318,7 +318,7 @@ edstop()
        }
        if (Tflag != NOSTR)
                fclose(readstat);
        }
        if (Tflag != NOSTR)
                fclose(readstat);
-       if (!gotcha)
+       if (!gotcha || Tflag != NOSTR)
                goto done;
        ibuf = NULL;
        if (stat(editfile, &statb) >= 0 && statb.st_size > mailsize) {
                goto done;
        ibuf = NULL;
        if (stat(editfile, &statb) >= 0 && statb.st_size > mailsize) {
@@ -361,7 +361,7 @@ edstop()
                if ((mp->m_flag & MDELETED) != 0)
                        continue;
                c++;
                if ((mp->m_flag & MDELETED) != 0)
                        continue;
                c++;
-               if (send(mp, obuf) < 0) {
+               if (send(mp, obuf, 0) < 0) {
                        perror(editfile);
                        relsesigs();
                        reset(0);
                        perror(editfile);
                        relsesigs();
                        reset(0);
@@ -496,6 +496,10 @@ expand(name)
        int s, pivec[2], (*sigint)();
        struct stat sbuf;
 
        int s, pivec[2], (*sigint)();
        struct stat sbuf;
 
+       if (name[0] == '+' && getfold(cmdbuf) >= 0) {
+               sprintf(xname, "%s/%s", cmdbuf, name + 1);
+               return(expand(savestr(xname)));
+       }
        if (!anyof(name, "~{[*?$`'\"\\"))
                return(name);
        if (pipe(pivec) < 0) {
        if (!anyof(name, "~{[*?$`'\"\\"))
                return(name);
        if (pipe(pivec) < 0) {
@@ -504,6 +508,7 @@ expand(name)
        }
        sprintf(cmdbuf, "echo %s", name);
        if ((pid = vfork()) == 0) {
        }
        sprintf(cmdbuf, "echo %s", name);
        if ((pid = vfork()) == 0) {
+               sigchild();
                Shell = value("SHELL");
                if (Shell == NOSTR)
                        Shell = SHELL;
                Shell = value("SHELL");
                if (Shell == NOSTR)
                        Shell = SHELL;
@@ -557,6 +562,23 @@ err:
        return(NOSTR);
 }
 
        return(NOSTR);
 }
 
+/*
+ * Determine the current folder directory name.
+ */
+getfold(name)
+       char *name;
+{
+       char *folder;
+
+       if ((folder = value("folder")) == NOSTR)
+               return(-1);
+       if (*folder == '/')
+               strcpy(name, folder);
+       else
+               sprintf(name, "%s/%s", homedir, folder);
+       return(0);
+}
+
 /*
  * A nicer version of Fdopen, which allows us to fclose
  * without losing the open file.
 /*
  * A nicer version of Fdopen, which allows us to fclose
  * without losing the open file.