Eric Allman's fixes to remove VAX and VMUNIX dependencies
authorKurt A. Shoens <kurt@ucbvax.Berkeley.EDU>
Tue, 16 Mar 1982 01:34:16 +0000 (17:34 -0800)
committerKurt A. Shoens <kurt@ucbvax.Berkeley.EDU>
Tue, 16 Mar 1982 01:34:16 +0000 (17:34 -0800)
SCCS-vsn: usr.bin/mail/cmd1.c 2.2.1.1
SCCS-vsn: usr.bin/mail/collect.c 2.7.1.2
SCCS-vsn: usr.bin/mail/fio.c 2.3.1.1
SCCS-vsn: usr.bin/mail/lex.c 2.5.1.1
SCCS-vsn: usr.bin/mail/popen.c 1.2.1.2
SCCS-vsn: usr.bin/mail/tty.c 2.1.1.1

usr/src/usr.bin/mail/cmd1.c
usr/src/usr.bin/mail/collect.c
usr/src/usr.bin/mail/fio.c
usr/src/usr.bin/mail/lex.c
usr/src/usr.bin/mail/popen.c
usr/src/usr.bin/mail/tty.c

index e92c695..733e892 100644 (file)
@@ -8,7 +8,7 @@
  * User commands.
  */
 
  * User commands.
  */
 
-static char *SccsId = "@(#)cmd1.c      2.5 %G%";
+static char *SccsId = "@(#)cmd1.c      2.2.1.1 %G%";
 
 /*
  * Print the current active headings.
 
 /*
  * Print the current active headings.
@@ -293,8 +293,11 @@ type(msgvec)
 
 brokpipe()
 {
 
 brokpipe()
 {
-
+# ifdef VMUNIX
        sigrelse(SIGPIPE);
        sigrelse(SIGPIPE);
+# else
+       signal(SIGPIPE, brokpipe);
+# endif
        longjmp(pipestop, 1);
 }
 
        longjmp(pipestop, 1);
 }
 
index 6bdf1ae..9126912 100644 (file)
@@ -7,7 +7,7 @@
  * ~ escapes.
  */
 
  * ~ escapes.
  */
 
-static char *SccsId = "@(#)collect.c   2.7.1.1 %G%";
+static char *SccsId = "@(#)collect.c   2.7.1.2 %G%";
 
 #include "rcv.h"
 #include <sys/stat.h>
 
 #include "rcv.h"
 #include <sys/stat.h>
@@ -27,7 +27,9 @@ static char *SccsId = "@(#)collect.c  2.7.1.1 %G%";
 
 static int     (*savesig)();           /* Previous SIGINT value */
 static int     (*savehup)();           /* Previous SIGHUP value */
 
 static int     (*savesig)();           /* Previous SIGINT value */
 static int     (*savehup)();           /* Previous SIGHUP value */
+# ifdef VMUNIX
 static int     (*savecont)();          /* Previous SIGCONT value */
 static int     (*savecont)();          /* Previous SIGCONT value */
+# endif VMUNIX
 static FILE    *newi;                  /* File for saving away */
 static FILE    *newo;                  /* Output side of same */
 static int     hf;                     /* Ignore interrups */
 static FILE    *newi;                  /* File for saving away */
 static FILE    *newo;                  /* Output side of same */
 static int     hf;                     /* Ignore interrups */
@@ -45,6 +47,7 @@ collect(hp)
        char linebuf[LINESIZE], *cp;
        extern char tempMail[];
        int notify();
        char linebuf[LINESIZE], *cp;
        extern char tempMail[];
        int notify();
+       extern collintsig(), collhupsig();
 
        noreset++;
        ibuf = obuf = NULL;
 
        noreset++;
        ibuf = obuf = NULL;
@@ -53,11 +56,16 @@ collect(hp)
        else
                hf = 0;
        hadintr = 0;
        else
                hf = 0;
        hadintr = 0;
+# ifdef VMUNIX
        if ((savesig = sigset(SIGINT, SIG_IGN)) != SIG_IGN)
                sigset(SIGINT, hf ? intack : collrub), sighold(SIGINT);
        if ((savehup = sigset(SIGHUP, SIG_IGN)) != SIG_IGN)
        if ((savesig = sigset(SIGINT, SIG_IGN)) != SIG_IGN)
                sigset(SIGINT, hf ? intack : collrub), sighold(SIGINT);
        if ((savehup = sigset(SIGHUP, SIG_IGN)) != SIG_IGN)
-               sigset(SIGHUP, collrub), sighold(SIGINT);
+               sigset(SIGHUP, collrub), sighold(SIGHUP);
        savecont = sigset(SIGCONT, collcont);
        savecont = sigset(SIGCONT, collcont);
+# else VMUNIX
+       savesig = signal(SIGINT, SIG_IGN);
+       savehup = signal(SIGHUP, SIG_IGN);
+# endif VMUNIX
        newi = NULL;
        newo = NULL;
        if ((obuf = fopen(tempMail, "w")) == NULL) {
        newi = NULL;
        newo = NULL;
        if ((obuf = fopen(tempMail, "w")) == NULL) {
@@ -96,8 +104,15 @@ collect(hp)
        eof = 0;
        for (;;) {
                setjmp(coljmp);
        eof = 0;
        for (;;) {
                setjmp(coljmp);
+# ifdef VMUNIX
                sigrelse(SIGINT);
                sigrelse(SIGHUP);
                sigrelse(SIGINT);
                sigrelse(SIGHUP);
+# else VMUNIX
+               if (savesig != SIG_IGN)
+                       signal(SIGINT, hf ? intack : collintsig);
+               if (savehup != SIG_IGN)
+                       signal(SIGHUP, collhupsig);
+# endif VMUNIX
                flush();
                if (readline(stdin, linebuf) <= 0) {
                        if (intty && value("ignoreeof") != NOSTR) {
                flush();
                if (readline(stdin, linebuf) <= 0) {
                        if (intty && value("ignoreeof") != NOSTR) {
@@ -166,7 +181,7 @@ collect(hp)
                        /*
                         * Simulate end of file on input.
                         */
                        /*
                         * Simulate end of file on input.
                         */
-                       goto eof;
+                       goto eofl;
 
                case 'q':
                case 'Q':
 
                case 'q':
                case 'Q':
@@ -376,12 +391,14 @@ collect(hp)
                        break;
                }
        }
                        break;
                }
        }
-eof:
+eofl:
        fclose(obuf);
        rewind(ibuf);
        sigset(SIGINT, savesig);
        sigset(SIGHUP, savehup);
        fclose(obuf);
        rewind(ibuf);
        sigset(SIGINT, savesig);
        sigset(SIGHUP, savehup);
+# ifdef VMUNIX
        sigset(SIGCONT, savecont);
        sigset(SIGCONT, savecont);
+# endif VMUNIX
        noreset = 0;
        return(ibuf);
 
        noreset = 0;
        return(ibuf);
 
@@ -392,7 +409,9 @@ err:
                fclose(obuf);
        sigset(SIGINT, savesig);
        sigset(SIGHUP, savehup);
                fclose(obuf);
        sigset(SIGINT, savesig);
        sigset(SIGHUP, savehup);
+# ifdef VMUNIX
        sigset(SIGCONT, savecont);
        sigset(SIGCONT, savecont);
+# endif VMUNIX
        noreset = 0;
        return(NULL);
 }
        noreset = 0;
        return(NULL);
 }
@@ -478,7 +497,9 @@ mesedit(ibuf, obuf, c)
        register char *edit;
 
        sig = sigset(SIGINT, SIG_IGN);
        register char *edit;
 
        sig = sigset(SIGINT, SIG_IGN);
+# ifdef VMUNIX
        scont = sigset(SIGCONT, foonly);
        scont = sigset(SIGCONT, foonly);
+# endif VMUNIX
        if (stat(tempEdit, &sbuf) >= 0) {
                printf("%s: file exists\n", tempEdit);
                goto out;
        if (stat(tempEdit, &sbuf) >= 0) {
                printf("%s: file exists\n", tempEdit);
                goto out;
@@ -548,7 +569,9 @@ mesedit(ibuf, obuf, c)
 fix:
        perror(tempEdit);
 out:
 fix:
        perror(tempEdit);
 out:
+# ifdef VMUNIX
        sigset(SIGCONT, scont);
        sigset(SIGCONT, scont);
+# endif VMUNIX
        sigset(SIGINT, sig);
        newi = ibuf;
        return(obuf);
        sigset(SIGINT, sig);
        newi = ibuf;
        return(obuf);
@@ -752,6 +775,20 @@ collcont(s)
  * were previously set anyway.
  */
 
  * were previously set anyway.
  */
 
+# ifndef VMUNIX
+collintsig()
+{
+       signal(SIGINT, SIG_IGN);
+       collrub(SIGINT);
+}
+
+collhupsig()
+{
+       signal(SIGHUP, SIG_IGN);
+       collrub(SIGHUP);
+}
+# endif VMUNIX
+
 collrub(s)
 {
        register FILE *dbuf;
 collrub(s)
 {
        register FILE *dbuf;
@@ -761,7 +798,9 @@ collrub(s)
                hadintr++;
                clrbuf(stdout);
                printf("\n(Interrupt -- one more to kill letter)\n");
                hadintr++;
                clrbuf(stdout);
                printf("\n(Interrupt -- one more to kill letter)\n");
+# ifdef VMUNIX
                sigrelse(s);
                sigrelse(s);
+# endif VMUNIX
                longjmp(coljmp, 1);
        }
        fclose(newo);
                longjmp(coljmp, 1);
        }
        fclose(newo);
@@ -779,7 +818,9 @@ done:
        fclose(newi);
        sigset(SIGINT, savesig);
        sigset(SIGHUP, savehup);
        fclose(newi);
        sigset(SIGINT, savesig);
        sigset(SIGHUP, savehup);
+# ifdef VMUNIX
        sigset(SIGCONT, savecont);
        sigset(SIGCONT, savecont);
+# endif VMUNIX
        if (rcvmode) {
                if (s == SIGHUP)
                        hangup(SIGHUP);
        if (rcvmode) {
                if (s == SIGHUP)
                        hangup(SIGHUP);
index 0f6e602..d95b181 100644 (file)
@@ -10,7 +10,7 @@
  * File I/O.
  */
 
  * File I/O.
  */
 
-static char *SccsId = "@(#)fio.c       2.7 %G%";
+static char *SccsId = "@(#)fio.c       2.3.1.1 %G%";
 
 /*
  * Set up the input pointers while copying the mail file into
 
 /*
  * Set up the input pointers while copying the mail file into
@@ -392,6 +392,10 @@ done:
        relsesigs();
 }
 
        relsesigs();
 }
 
+# ifndef VMUNIX
+static int     SaveSigs[32];
+# endif VMUNIX
+
 /*
  * Hold signals SIGHUP - SIGQUIT.
  */
 /*
  * Hold signals SIGHUP - SIGQUIT.
  */
@@ -400,7 +404,11 @@ holdsigs()
        register int i;
 
        for (i = SIGHUP; i <= SIGQUIT; i++)
        register int i;
 
        for (i = SIGHUP; i <= SIGQUIT; i++)
+# ifdef VMUNIX
                sighold(i);
                sighold(i);
+# else
+               SaveSigs[i] = signal(i, SIG_IGN);
+# endif
 }
 
 /*
 }
 
 /*
@@ -411,7 +419,11 @@ relsesigs()
        register int i;
 
        for (i = SIGHUP; i <= SIGQUIT; i++)
        register int i;
 
        for (i = SIGHUP; i <= SIGQUIT; i++)
+# ifdef VMUNIX
                sigrelse(i);
                sigrelse(i);
+# else
+               signal(i, SaveSigs[i]);
+# endif
 }
 
 /*
 }
 
 /*
index 2c2053e..9501294 100644 (file)
@@ -8,7 +8,7 @@
  * Lexical processing of commands.
  */
 
  * Lexical processing of commands.
  */
 
-static char *SccsId = "@(#)lex.c       2.7 %G%";
+static char *SccsId = "@(#)lex.c       2.5.1.1 %G%";
 
 char   *prompt = "& ";
 
 
 char   *prompt = "& ";
 
@@ -103,7 +103,9 @@ commands()
        char linebuf[LINESIZE];
        int hangup(), contin();
 
        char linebuf[LINESIZE];
        int hangup(), contin();
 
+# ifdef VMUNIX
        sigset(SIGCONT, SIG_DFL);
        sigset(SIGCONT, SIG_DFL);
+# endif VMUNIX
        if (rcvmode && !sourcing) {
                if (sigset(SIGINT, SIG_IGN) != SIG_IGN)
                        sigset(SIGINT, stop);
        if (rcvmode && !sourcing) {
                if (sigset(SIGINT, SIG_IGN) != SIG_IGN)
                        sigset(SIGINT, stop);
@@ -125,6 +127,7 @@ commands()
 top:
                if (shudprompt) {
                        sigset(SIGCONT, contin);
 top:
                if (shudprompt) {
                        sigset(SIGCONT, contin);
+# endif VMUNIX
                        printf(prompt);
                }
                flush();
                        printf(prompt);
                }
                flush();
@@ -163,7 +166,9 @@ top:
                                break;
                        linebuf[n++] = ' ';
                }
                                break;
                        linebuf[n++] = ' ';
                }
+# ifdef VMUNIX
                sigset(SIGCONT, SIG_DFL);
                sigset(SIGCONT, SIG_DFL);
+# endif VMUNIX
                if (execute(linebuf, 0))
                        return;
 more:          ;
                if (execute(linebuf, 0))
                        return;
 more:          ;
@@ -491,6 +496,9 @@ stop(s)
 {
        register FILE *fp;
 
 {
        register FILE *fp;
 
+# ifndef VMUNIX
+       s = SIGINT;
+# endif VMUNIX
        noreset = 0;
        if (!inithdr)
                sawcom++;
        noreset = 0;
        if (!inithdr)
                sawcom++;
@@ -518,7 +526,11 @@ stop(s)
        }
        clrbuf(stdout);
        printf("Interrupt\n");
        }
        clrbuf(stdout);
        printf("Interrupt\n");
+# ifdef VMUNIX
        sigrelse(s);
        sigrelse(s);
+# else
+       signal(s, stop);
+# endif
        reset(0);
 }
 
        reset(0);
 }
 
index 829245e..d8fdf01 100644 (file)
@@ -1,10 +1,15 @@
 #include <stdio.h>
 #include <signal.h>
 #include <stdio.h>
 #include <signal.h>
+#include <errno.h>
 #define        tst(a,b)        (*mode == 'r'? (b) : (a))
 #define        RDR     0
 #define        WTR     1
 static int     popen_pid[20];
 #define        tst(a,b)        (*mode == 'r'? (b) : (a))
 #define        RDR     0
 #define        WTR     1
 static int     popen_pid[20];
-static char    *sccsid = "@(#)popen.c  1.2.1.1 %G%";
+static char    *sccsid = "@(#)popen.c  1.2.1.2 %G%";
+
+# ifndef VMUNIX
+# define vfork fork
+# endif VMUNIX
 
 FILE *
 popen(cmd,mode)
 
 FILE *
 popen(cmd,mode)
@@ -38,18 +43,23 @@ FILE *ptr;
 {
        register f, r;
        int status;
 {
        register f, r;
        int status;
+       extern int errno;
 
        f = fileno(ptr);
        fclose(ptr);
 
        f = fileno(ptr);
        fclose(ptr);
+# ifdef VMUNIX
        sighold(SIGINT);
        sighold(SIGQUIT);
        sighold(SIGHUP);
        sighold(SIGINT);
        sighold(SIGQUIT);
        sighold(SIGHUP);
-       while((r = wait(&status)) != popen_pid[f] && r != -1)
+# endif VMUNIX
+       while((r = wait(&status)) != popen_pid[f] && r != -1 && errno != EINTR)
                ;
        if(r == -1)
                status = -1;
                ;
        if(r == -1)
                status = -1;
+# ifdef VMUNIX
        sigrelse(SIGINT);
        sigrelse(SIGQUIT);
        sigrelse(SIGHUP);
        sigrelse(SIGINT);
        sigrelse(SIGQUIT);
        sigrelse(SIGHUP);
+# endif VMUNIX
        return(status);
 }
        return(status);
 }
index a4f4e43..c0816e5 100644 (file)
@@ -8,7 +8,7 @@
 
 #include "rcv.h"
 
 
 #include "rcv.h"
 
-static char *SccsId = "@(#)tty.c       2.2 %G%";
+static char *SccsId = "@(#)tty.c       2.1.1.1 %G%";
 
 static int     c_erase;                /* Current erase char */
 static int     c_kill;                 /* Current kill char */
 
 static int     c_erase;                /* Current erase char */
 static int     c_kill;                 /* Current kill char */
@@ -34,7 +34,9 @@ grabh(hp, gflags)
        register int s;
        int errs;
 
        register int s;
        int errs;
 
+# ifdef VMUNIX
        savecont = sigset(SIGCONT, signull);
        savecont = sigset(SIGCONT, signull);
+# endif VMUNIX
        errs = 0;
 #ifndef TIOCSTI
        ttyset = 0;
        errs = 0;
 #ifndef TIOCSTI
        ttyset = 0;
@@ -88,7 +90,9 @@ grabh(hp, gflags)
                if (hp->h_bcc != NOSTR)
                        hp->h_seq++;
        }
                if (hp->h_bcc != NOSTR)
                        hp->h_seq++;
        }
+# ifdef VMUNIX
        sigset(SIGCONT, savecont);
        sigset(SIGCONT, savecont);
+# endif VMUNIX
 #ifndef TIOCSTI
        ttybuf.sg_erase = c_erase;
        ttybuf.sg_kill = c_kill;
 #ifndef TIOCSTI
        ttybuf.sg_erase = c_erase;
        ttybuf.sg_kill = c_kill;
@@ -146,7 +150,9 @@ readtty(pr, src)
        cp2 = cp;
        if (setjmp(rewrite))
                goto redo;
        cp2 = cp;
        if (setjmp(rewrite))
                goto redo;
+# ifdef VMUNIX
        sigset(SIGCONT, ttycont);
        sigset(SIGCONT, ttycont);
+# endif VMUNIX
        while (cp2 < canonb + BUFSIZ) {
                c = getc(stdin);
                if (c == EOF || c == '\n')
        while (cp2 < canonb + BUFSIZ) {
                c = getc(stdin);
                if (c == EOF || c == '\n')
@@ -154,7 +160,9 @@ readtty(pr, src)
                *cp2++ = c;
        }
        *cp2 = 0;
                *cp2++ = c;
        }
        *cp2 = 0;
+# ifdef VMUNIX
        sigset(SIGCONT, signull);
        sigset(SIGCONT, signull);
+# endif VMUNIX
        if (c == EOF && ferror(stdin) && hadcont) {
 redo:
                hadcont = 0;
        if (c == EOF && ferror(stdin) && hadcont) {
 redo:
                hadcont = 0;
@@ -163,9 +171,9 @@ redo:
                return(readtty(pr, cp));
        }
 #ifndef TIOCSTI
                return(readtty(pr, cp));
        }
 #ifndef TIOCSTI
-       if (cp2 == NOSTR || *cp2 == '\0')
+       if (cp == NOSTR || *cp == '\0')
                return(src);
                return(src);
-       cp = cp2;
+       cp2 = cp;
        if (!ttyset)
                return(strlen(canonb) > 0 ? savestr(canonb) : NOSTR);
        while (*cp != '\0') {
        if (!ttyset)
                return(strlen(canonb) > 0 ? savestr(canonb) : NOSTR);
        while (*cp != '\0') {
@@ -199,6 +207,7 @@ redo:
        return(savestr(canonb));
 }
 
        return(savestr(canonb));
 }
 
+# ifdef VMUNIX
 /*
  * Receipt continuation.
  */
 /*
  * Receipt continuation.
  */
@@ -209,6 +218,7 @@ ttycont(s)
        sigrelse(SIGCONT);
        longjmp(rewrite, 1);
 }
        sigrelse(SIGCONT);
        longjmp(rewrite, 1);
 }
+# endif VMUNIX
 
 /*
  * Null routine to satisfy
 
 /*
  * Null routine to satisfy