written by Kurt Shoens; added Berkeley specific header
[unix-history] / usr / src / usr.bin / mail / list.c
index c3b7ab2..b5c998a 100644 (file)
@@ -1,12 +1,18 @@
 /*
  * 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 this notice is preserved and that due credit is given
+ * to the University of California at 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'' without express or implied warranty.
  */
 
  */
 
-#ifndef lint
-static char sccsid[] = "@(#)list.c     5.1 (Berkeley) %G%";
-#endif not lint
+#ifdef notdef
+static char sccsid[] = "@(#)list.c     5.6 (Berkeley) %G%";
+#endif /* notdef */
 
 #include "rcv.h"
 #include <ctype.h>
 
 #include "rcv.h"
 #include <ctype.h>
@@ -134,22 +140,28 @@ number:
                                printf("Non-numeric second argument\n");
                                return(-1);
                        }
                                printf("Non-numeric second argument\n");
                                return(-1);
                        }
-                       if (valdot < msgCount)
-                               mark(valdot+1);
-                       else {
-                               printf("Referencing beyond EOF\n");
-                               return(-1);
-                       }
+                       i = valdot;
+                       do {
+                               i++;
+                               if (i > msgCount) {
+                                       printf("Referencing beyond EOF\n");
+                                       return(-1);
+                               }
+                       } while ((message[i - 1].m_flag & MDELETED) != f);
+                       mark(i);
                        break;
 
                case TDASH:
                        if (beg == 0) {
                        break;
 
                case TDASH:
                        if (beg == 0) {
-                               if (valdot > 1)
-                                       mark(valdot-1);
-                               else {
-                                       printf("Referencing before 1\n");
-                                       return(-1);
-                               }
+                               i = valdot;
+                               do {
+                                       i--;
+                                       if (i <= 0) {
+                                               printf("Referencing before 1\n");
+                                               return(-1);
+                                       }
+                               } while ((message[i - 1].m_flag & MDELETED) != f);
+                               mark(i);
                        }
                        break;
 
                        }
                        break;
 
@@ -214,7 +226,7 @@ number:
 
        if ((np > namelist || colmod != 0) && mc == 0)
                for (i = 1; i <= msgCount; i++)
 
        if ((np > namelist || colmod != 0) && mc == 0)
                for (i = 1; i <= msgCount; i++)
-                       if ((message[i-1].m_flag & (MSAVED|MDELETED)) == f)
+                       if ((message[i-1].m_flag & MDELETED) == f)
                                mark(i);
 
        /*
                                mark(i);
 
        /*
@@ -336,15 +348,18 @@ check(mesg, f)
  * for a RAWLIST.
  */
 
  * for a RAWLIST.
  */
 
-getrawlist(line, argv)
+getrawlist(line, argv, argc)
        char line[];
        char **argv;
        char line[];
        char **argv;
+       int  argc;
 {
        register char **ap, *cp, *cp2;
        char linebuf[BUFSIZ], quotec;
 {
        register char **ap, *cp, *cp2;
        char linebuf[BUFSIZ], quotec;
+       register char **last;
 
        ap = argv;
        cp = line;
 
        ap = argv;
        cp = line;
+       last = argv + argc - 1;
        while (*cp != '\0') {
                while (any(*cp, " \t"))
                        cp++;
        while (*cp != '\0') {
                while (any(*cp, " \t"))
                        cp++;
@@ -364,6 +379,10 @@ getrawlist(line, argv)
                *cp2 = '\0';
                if (cp2 == linebuf)
                        break;
                *cp2 = '\0';
                if (cp2 == linebuf)
                        break;
+               if (ap >= last) {
+                       printf("Too many elements in the list; excess discarded\n");
+                       break;
+               }
                *ap++ = savestr(linebuf);
        }
        *ap = NOSTR;
                *ap++ = savestr(linebuf);
        }
        *ap = NOSTR;
@@ -401,7 +420,7 @@ scan(sp)
        int quotec;
 
        if (regretp >= 0) {
        int quotec;
 
        if (regretp >= 0) {
-               copy(stringstack[regretp], lexstring);
+               strcpy(lexstring, stringstack[regretp]);
                lexnumber = numberstack[regretp];
                return(regretstack[regretp--]);
        }
                lexnumber = numberstack[regretp];
                return(regretstack[regretp--]);
        }
@@ -545,11 +564,20 @@ sender(str, mesg)
        char *str;
 {
        register struct message *mp;
        char *str;
 {
        register struct message *mp;
-       register char *cp;
+       register char *cp, *cp2, *backup;
 
        mp = &message[mesg-1];
 
        mp = &message[mesg-1];
-       cp = nameof(mp, 0);
-       return(icequal(cp, str));
+       backup = cp2 = nameof(mp, 0);
+       cp = str;
+       while (*cp2) {
+               if (*cp == 0)
+                       return(1);
+               if (raise(*cp++) != raise(*cp2++)) {
+                       cp2 = ++backup;
+                       cp = str;
+               }
+       }
+       return(*cp == 0);
 }
 
 /*
 }
 
 /*