cleaned up edit1, use a file in /tmp, not in current directory, and more
[unix-history] / usr / src / usr.bin / mail / lex.c
index c15e921..55c6754 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #ifdef notdef
  */
 
 #ifdef notdef
-static char sccsid[] = "@(#)lex.c      5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c      5.13 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -40,7 +40,6 @@ setfile(name, isedit)
        int i;
        struct stat stb;
        static int shudclob;
        int i;
        struct stat stb;
        static int shudclob;
-       static char efile[128];
        extern char tempMesg[];
        extern int errno;
 
        extern char tempMesg[];
        extern int errno;
 
@@ -103,8 +102,6 @@ setfile(name, isedit)
        }
        shudclob = 1;
        edit = isedit;
        }
        shudclob = 1;
        edit = isedit;
-       strncpy(efile, name, 128);
-       editfile = efile;
        if (name != mailname)
                strcpy(mailname, name);
        mailsize = fsize(ibuf);
        if (name != mailname)
                strcpy(mailname, name);
        mailsize = fsize(ibuf);
@@ -135,7 +132,7 @@ jmp_buf     commjmp;
 
 commands()
 {
 
 commands()
 {
-       int eofloop, shudprompt, stop();
+       int eofloop, stop();
        register int n;
        char linebuf[LINESIZE];
        int hangup(), contin();
        register int n;
        char linebuf[LINESIZE];
        int hangup(), contin();
@@ -147,7 +144,6 @@ commands()
                if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
                        signal(SIGHUP, hangup);
        }
                if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
                        signal(SIGHUP, hangup);
        }
-       shudprompt = intty && !sourcing;
        for (;;) {
                setexit();
 
        for (;;) {
                setexit();
 
@@ -160,13 +156,14 @@ commands()
                        return;
                eofloop = 0;
 top:
                        return;
                eofloop = 0;
 top:
-               if (shudprompt) {
+               if (!sourcing && value("interactive") != NOSTR) {
                        setjmp(commjmp);
                        signal(SIGCONT, contin);
                        printf(prompt);
                }
                fflush(stdout);
                        setjmp(commjmp);
                        signal(SIGCONT, contin);
                        printf(prompt);
                }
                fflush(stdout);
-               sreset();
+               if (!sourcing)
+                       sreset();
 
                /*
                 * Read a line of commands from the current input
 
                /*
                 * Read a line of commands from the current input
@@ -184,7 +181,8 @@ top:
                                        unstack();
                                        goto more;
                                }
                                        unstack();
                                        goto more;
                                }
-                               if (value("ignoreeof") != NOSTR && shudprompt) {
+                               if (value("interactive") != NOSTR &&
+                                   value("ignoreeof") != NOSTR) {
                                        if (++eofloop < 25) {
                                                printf("Use \"quit\" to quit.\n");
                                                goto top;
                                        if (++eofloop < 25) {
                                                printf("Use \"quit\" to quit.\n");
                                                goto top;
@@ -574,20 +572,15 @@ stop(s)
  * give the message count, and print a header listing.
  */
 
  * give the message count, and print a header listing.
  */
 
-char   *greeting       = "Mail version %s.  Type ? for help.\n";
-
-announce(pr)
+announce()
 {
        int vec[2], mdot;
 {
        int vec[2], mdot;
-       extern char *version;
 
 
-       if (pr && value("quiet") == NOSTR)
-               printf(greeting, version);
        mdot = newfileinfo();
        vec[0] = mdot;
        vec[1] = 0;
        dot = &message[mdot - 1];
        mdot = newfileinfo();
        vec[0] = mdot;
        vec[1] = 0;
        dot = &message[mdot - 1];
-       if (msgCount > 0 && !noheader) {
+       if (msgCount > 0 && value("noheader") == NOSTR) {
                inithdr++;
                headers(vec);
                inithdr = 0;
                inithdr++;
                headers(vec);
                inithdr = 0;