some general cleanup
authorEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 18 Jun 1988 06:39:02 +0000 (22:39 -0800)
committerEdward Wang <edward@ucbvax.Berkeley.EDU>
Sat, 18 Jun 1988 06:39:02 +0000 (22:39 -0800)
SCCS-vsn: usr.bin/mail/lex.c 5.13
SCCS-vsn: usr.bin/mail/quit.c 5.8
SCCS-vsn: usr.bin/mail/cmd3.c 5.9
SCCS-vsn: usr.bin/mail/main.c 5.13
SCCS-vsn: usr.bin/mail/fio.c 5.8
SCCS-vsn: usr.bin/mail/cmd1.c 5.9
SCCS-vsn: usr.bin/mail/def.h 5.10

usr/src/usr.bin/mail/cmd1.c
usr/src/usr.bin/mail/cmd3.c
usr/src/usr.bin/mail/def.h
usr/src/usr.bin/mail/fio.c
usr/src/usr.bin/mail/lex.c
usr/src/usr.bin/mail/main.c
usr/src/usr.bin/mail/quit.c

index 4b2e833..761fcb6 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #ifdef notdef
  */
 
 #ifdef notdef
-static char sccsid[] = "@(#)cmd1.c     5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd1.c     5.9 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -391,7 +391,7 @@ top(msgvec)
                mp = &message[mesg-1];
                dot = mp;
                if (value("quiet") == NOSTR)
                mp = &message[mesg-1];
                dot = mp;
                if (value("quiet") == NOSTR)
-                       printf("Message %2d:\n", mesg);
+                       printf("Message %d:\n", mesg);
                ibuf = setinput(mp);
                c = mp->m_lines;
                if (!lineb)
                ibuf = setinput(mp);
                c = mp->m_lines;
                if (!lineb)
index 29ad557..98f3e7a 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #ifdef notdef
  */
 
 #ifdef notdef
-static char sccsid[] = "@(#)cmd3.c     5.8 (Berkeley) %G%";
+static char sccsid[] = "@(#)cmd3.c     5.9 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -590,7 +590,7 @@ file(argv)
                perror(cp);
                return -1;
        }
                perror(cp);
                return -1;
        }
-       announce(0);
+       announce();
        return 0;
 }
 
        return 0;
 }
 
index b0a03e2..0da7e56 100644 (file)
@@ -9,7 +9,7 @@
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
  * software without specific prior written permission. This software
  * is provided ``as is'' without express or implied warranty.
  *
- *     @(#)def.h       5.9 (Berkeley) %G%
+ *     @(#)def.h       5.10 (Berkeley) %G%
  */
 
 #include <sys/param.h>         /* includes <sys/types.h> */
  */
 
 #include <sys/param.h>         /* includes <sys/types.h> */
@@ -273,7 +273,6 @@ char        *name1();
 char   *nameof();
 char   *nextword();
 char   *getenv();
 char   *nameof();
 char   *nextword();
 char   *getenv();
-char   *getfilename();
 char   *findmail();
 char   *ishfield();
 char   *malloc();
 char   *findmail();
 char   *ishfield();
 char   *malloc();
index ebab76e..7142794 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #ifdef notdef
  */
 
 #ifdef notdef
-static char sccsid[] = "@(#)fio.c      5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)fio.c      5.8 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -233,7 +233,7 @@ edstop()
        register struct message *mp;
        FILE *obuf, *ibuf, *readstat;
        struct stat statb;
        register struct message *mp;
        FILE *obuf, *ibuf, *readstat;
        struct stat statb;
-       char tempname[30], *id;
+       char tempname[30];
        char *mktemp();
 
        if (readonly)
        char *mktemp();
 
        if (readonly)
@@ -251,6 +251,8 @@ edstop()
                if (mp->m_flag & (MODIFY|MDELETED|MSTATUS))
                        gotcha++;
                if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
                if (mp->m_flag & (MODIFY|MDELETED|MSTATUS))
                        gotcha++;
                if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
+                       char *id;
+
                        if ((id = hfield("article-id", mp)) != NOSTR)
                                fprintf(readstat, "%s\n", id);
                }
                        if ((id = hfield("article-id", mp)) != NOSTR)
                                fprintf(readstat, "%s\n", id);
                }
@@ -396,7 +398,7 @@ fsize(iob)
  */
 char *
 expand(name)
  */
 char *
 expand(name)
-       char name[];
+       register char *name;
 {
        char xname[BUFSIZ];
        char cmdbuf[BUFSIZ];
 {
        char xname[BUFSIZ];
        char cmdbuf[BUFSIZ];
@@ -408,7 +410,7 @@ expand(name)
 
        switch (*name) {
        case '%':
 
        switch (*name) {
        case '%':
-               return cp = savestr(findmail(name[1] ? name + 1 : myname));
+               return savestr(findmail(name[1] ? name + 1 : myname));
        case '#':
                if (name[1] != 0)
                        break;
        case '#':
                if (name[1] != 0)
                        break;
@@ -416,8 +418,7 @@ expand(name)
                        printf("No previous file\n");
                        return NOSTR;
                }
                        printf("No previous file\n");
                        return NOSTR;
                }
-               cp = savestr(prevfile);
-               return cp;
+               return savestr(prevfile);
        case '&':
                if (name[1] == 0 && (name = value("mbox")) == NOSTR) {
                        sprintf(xname, "%s/mbox", homedir);
        case '&':
                if (name[1] == 0 && (name = value("mbox")) == NOSTR) {
                        sprintf(xname, "%s/mbox", homedir);
@@ -430,10 +431,10 @@ expand(name)
                name = savestr(xname);
        }
        if (!anyof(name, "~{[*?$`'\"\\"))
                name = savestr(xname);
        }
        if (!anyof(name, "~{[*?$`'\"\\"))
-               return(name);
+               return name;
        if (pipe(pivec) < 0) {
                perror("pipe");
        if (pipe(pivec) < 0) {
                perror("pipe");
-               return(name);
+               return name;
        }
        sprintf(cmdbuf, "echo %s", name);
        if ((pid = vfork()) == 0) {
        }
        sprintf(cmdbuf, "echo %s", name);
        if ((pid = vfork()) == 0) {
@@ -452,7 +453,7 @@ expand(name)
                perror("fork");
                close(pivec[0]);
                close(pivec[1]);
                perror("fork");
                close(pivec[0]);
                close(pivec[1]);
-               return(NOSTR);
+               return NOSTR;
        }
        close(pivec[1]);
        l = read(pivec[0], xname, BUFSIZ);
        }
        close(pivec[1]);
        l = read(pivec[0], xname, BUFSIZ);
@@ -461,32 +462,29 @@ expand(name)
                ;
        if (s.w_status != 0 && s.w_termsig != SIGPIPE) {
                fprintf(stderr, "\"Echo\" failed\n");
                ;
        if (s.w_status != 0 && s.w_termsig != SIGPIPE) {
                fprintf(stderr, "\"Echo\" failed\n");
-               goto err;
+               return NOSTR;
        }
        if (l < 0) {
                perror("read");
        }
        if (l < 0) {
                perror("read");
-               goto err;
+               return NOSTR;
        }
        if (l == 0) {
                fprintf(stderr, "\"%s\": No match\n", name);
        }
        if (l == 0) {
                fprintf(stderr, "\"%s\": No match\n", name);
-               goto err;
+               return NOSTR;
        }
        if (l == BUFSIZ) {
                fprintf(stderr, "Buffer overflow expanding \"%s\"\n", name);
        }
        if (l == BUFSIZ) {
                fprintf(stderr, "Buffer overflow expanding \"%s\"\n", name);
-               goto err;
+               return NOSTR;
        }
        xname[l] = 0;
        for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
                ;
        }
        xname[l] = 0;
        for (cp = &xname[l-1]; *cp == '\n' && cp > xname; cp--)
                ;
-       *++cp = '\0';
+       cp[1] = '\0';
        if (any(' ', xname) && stat(xname, &sbuf) < 0) {
                fprintf(stderr, "\"%s\": Ambiguous\n", name);
        if (any(' ', xname) && stat(xname, &sbuf) < 0) {
                fprintf(stderr, "\"%s\": Ambiguous\n", name);
-               goto err;
+               return NOSTR;
        }
        }
-       return(savestr(xname));
-
-err:
-       return(NOSTR);
+       return savestr(xname);
 }
 
 /*
 }
 
 /*
index 06d7d86..55c6754 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #ifdef notdef
  */
 
 #ifdef notdef
-static char sccsid[] = "@(#)lex.c      5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)lex.c      5.13 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -572,13 +572,10 @@ stop(s)
  * give the message count, and print a header listing.
  */
 
  * give the message count, and print a header listing.
  */
 
-announce(pr)
+announce()
 {
        int vec[2], mdot;
 {
        int vec[2], mdot;
-       extern char *version;
 
 
-       if (pr && value("quiet") == NOSTR)
-               printf( "Mail version %s.  Type ? for help.\n", version);
        mdot = newfileinfo();
        vec[0] = mdot;
        vec[1] = 0;
        mdot = newfileinfo();
        vec[0] = mdot;
        vec[1] = 0;
index add7dfe..1c2f095 100644 (file)
@@ -17,7 +17,7 @@ char copyright[] =
 #endif /* notdef */
 
 #ifdef notdef
 #endif /* notdef */
 
 #ifdef notdef
-static char sccsid[] = "@(#)main.c     5.12 (Berkeley) %G%";
+static char sccsid[] = "@(#)main.c     5.13 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -57,12 +57,10 @@ main(argc, argv)
         * Figure out whether we are being run interactively, set up
         * all the temporary files, buffer standard output, and so forth.
         */
         * Figure out whether we are being run interactively, set up
         * all the temporary files, buffer standard output, and so forth.
         */
-
        mypid = getpid();
        if (isatty(0))
                assign("interactive", "");
        image = -1;
        mypid = getpid();
        if (isatty(0))
                assign("interactive", "");
        image = -1;
-
        /*
         * Now, determine how we are being used.
         * We successively pick off instances of -r, -h, -f, and -i.
        /*
         * Now, determine how we are being used.
         * We successively pick off instances of -r, -h, -f, and -i.
@@ -71,7 +69,6 @@ main(argc, argv)
         * of users to mail to.  Argp will be set to point to the
         * first of these users.
         */
         * of users to mail to.  Argp will be set to point to the
         * first of these users.
         */
-
        ef = NOSTR;
        to = NULL;
        cc = NULL;
        ef = NOSTR;
        to = NULL;
        cc = NULL;
@@ -258,9 +255,14 @@ Usage: mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr ...\n\
                exit(1);
        }
        if (setjmp(hdrjmp) == 0) {
                exit(1);
        }
        if (setjmp(hdrjmp) == 0) {
+               extern char *version;
+
                if ((prevint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
                        signal(SIGINT, hdrstop);
                if ((prevint = signal(SIGINT, SIG_IGN)) != SIG_IGN)
                        signal(SIGINT, hdrstop);
-               announce(!0);
+               if (value("quiet") == NOSTR)
+                       printf("Mail version %s.  Type ? for help.\n",
+                               version);
+               announce();
                fflush(stdout);
                signal(SIGINT, prevint);
        }
                fflush(stdout);
                signal(SIGINT, prevint);
        }
index b7fc584..95c8a79 100644 (file)
@@ -11,7 +11,7 @@
  */
 
 #ifdef notdef
  */
 
 #ifdef notdef
-static char sccsid[] = "@(#)quit.c     5.7 (Berkeley) %G%";
+static char sccsid[] = "@(#)quit.c     5.8 (Berkeley) %G%";
 #endif /* notdef */
 
 #include "rcv.h"
 #endif /* notdef */
 
 #include "rcv.h"
@@ -38,7 +38,6 @@ quit()
        register int c;
        extern char tempQuit[], tempResid[];
        struct stat minfo;
        register int c;
        extern char tempQuit[], tempResid[];
        struct stat minfo;
-       char *id;
        char *mbox;
 
        /*
        char *mbox;
 
        /*
@@ -122,18 +121,17 @@ quit()
                if (mp->m_flag & MODIFY)
                        modify++;
                if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
                if (mp->m_flag & MODIFY)
                        modify++;
                if (Tflag != NOSTR && (mp->m_flag & (MREAD|MDELETED)) != 0) {
-                       id = hfield("article-id", mp);
-                       if (id != NOSTR)
+                       char *id;
+
+                       if ((id = hfield("article-id", mp)) != NOSTR)
                                fprintf(readstat, "%s\n", id);
                }
        }
        if (Tflag != NOSTR)
                fclose(readstat);
        if (p == msgCount && !modify && !anystat) {
                                fprintf(readstat, "%s\n", id);
                }
        }
        if (Tflag != NOSTR)
                fclose(readstat);
        if (p == msgCount && !modify && !anystat) {
-               if (p == 1)
-                       printf("Held 1 message in %s\n", mailname);
-               else
-                       printf("Held %2d messages in %s\n", p, mailname);
+               printf("Held %d message%s in %s\n",
+                       p, p == 1 ? "" : "s", mailname);
                fclose(fbuf);
                return;
        }
                fclose(fbuf);
                return;
        }