install correct aliases file
[unix-history] / usr / src / usr.bin / mail / lex.c
index a24a64a..64a8f05 100644 (file)
@@ -1,12 +1,23 @@
 /*
  * Copyright (c) 1980 Regents of the University of California.
 /*
  * Copyright (c) 1980 Regents of the University of California.
- * All rights reserved.  The Berkeley software License Agreement
- * specifies the terms and conditions for redistribution.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char *sccsid = "@(#)lex.c       5.5 (Berkeley) %G%";
-#endif not lint
+static char sccsid[] = "@(#)lex.c      5.16 (Berkeley) %G%";
+#endif /* not lint */
 
 #include "rcv.h"
 #include <sys/stat.h>
 
 #include "rcv.h"
 #include <sys/stat.h>
@@ -34,7 +45,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;
 
@@ -97,8 +107,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);
@@ -129,7 +137,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();
@@ -141,7 +149,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();
 
@@ -154,7 +161,7 @@ commands()
                        return;
                eofloop = 0;
 top:
                        return;
                eofloop = 0;
 top:
-               if (shudprompt) {
+               if (!sourcing && value("interactive") != NOSTR) {
                        setjmp(commjmp);
                        signal(SIGCONT, contin);
                        printf(prompt);
                        setjmp(commjmp);
                        signal(SIGCONT, contin);
                        printf(prompt);
@@ -178,7 +185,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;
@@ -241,7 +249,7 @@ execute(linebuf, contxt)
                return(0);
        }
        cp2 = word;
                return(0);
        }
        cp2 = word;
-       while (*cp && !any(*cp, " \t0123456789$^.:/-+*'\""))
+       while (*cp && index(" \t0123456789$^.:/-+*'\"", *cp) == NOSTR)
                *cp2++ = *cp++;
        *cp2 = '\0';
 
                *cp2++ = *cp++;
        *cp2 = '\0';
 
@@ -442,20 +450,13 @@ contin(s)
 }
 
 /*
 }
 
 /*
- * Branch here on hangup signal and simulate quit.
+ * Branch here on hangup signal and simulate "exit".
  */
 /*ARGSUSED*/
 hangup(s)
 {
 
  */
 /*ARGSUSED*/
 hangup(s)
 {
 
-       holdsigs();
-       if (edit) {
-               if (setexit())
-                       exit(0);
-               edstop();
-       }
-       else
-               quit();
+       /* nothing to do? */
        exit(0);
 }
 
        exit(0);
 }
 
@@ -575,20 +576,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;
@@ -661,6 +657,7 @@ newfileinfo()
 /*ARGSUSED*/
 pversion(e)
 {
 /*ARGSUSED*/
 pversion(e)
 {
+       extern char *version;
 
        printf("Version %s\n", version);
        return(0);
 
        printf("Version %s\n", version);
        return(0);