Modified to use perror() to report open failure on THELPFILE
[unix-history] / usr / src / usr.bin / mail / cmd2.c
index c6320dd..35dedb0 100644 (file)
@@ -9,7 +9,7 @@
  * More user commands.
  */
 
  * More user commands.
  */
 
-static char *SccsId = "@(#)cmd2.c      2.7 %G%";
+static char *SccsId = "@(#)cmd2.c      2.10 %G%";
 
 /*
  * If any arguments were given, go to the next applicable argument
 
 /*
  * If any arguments were given, go to the next applicable argument
@@ -122,7 +122,8 @@ save1(str, mark)
        register int *ip, mesg;
        register struct message *mp;
        char *file, *disp, *cmd;
        register int *ip, mesg;
        register struct message *mp;
        char *file, *disp, *cmd;
-       int f, *msgvec, lc, cc, t;
+       int f, *msgvec, lc, t;
+       long cc;
        FILE *obuf;
        struct stat statb;
 
        FILE *obuf;
        struct stat statb;
 
@@ -152,7 +153,8 @@ save1(str, mark)
                perror(NOSTR);
                return(1);
        }
                perror(NOSTR);
                return(1);
        }
-       cc = lc = 0;
+       cc = 0L;
+       lc = 0;
        for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
                mesg = *ip;
                touch(mesg);
        for (ip = msgvec; *ip && ip-msgvec < msgCount; ip++) {
                mesg = *ip;
                touch(mesg);
@@ -163,7 +165,7 @@ save1(str, mark)
                        return(1);
                }
                lc += t;
                        return(1);
                }
                lc += t;
-               cc += msize(mp);
+               cc += mp->m_size;
                if (mark)
                        mp->m_flag |= MSAVED;
        }
                if (mark)
                        mp->m_flag |= MSAVED;
        }
@@ -171,7 +173,7 @@ save1(str, mark)
        if (ferror(obuf))
                perror(file);
        fclose(obuf);
        if (ferror(obuf))
                perror(file);
        fclose(obuf);
-       printf("%s %d/%d\n", disp, lc, cc);
+       printf("%s %d/%ld\n", disp, lc, cc);
        return(0);
 }
 
        return(0);
 }
 
@@ -458,6 +460,8 @@ igfield(list)
        if (argcount(list) == 0)
                return(igshow());
        for (ap = list; *ap != 0; ap++) {
        if (argcount(list) == 0)
                return(igshow());
        for (ap = list; *ap != 0; ap++) {
+               if (isign(*ap))
+                       continue;
                istrcpy(field, *ap);
                h = hash(field);
                igp = (struct ignore *) calloc(1, sizeof (struct ignore));
                istrcpy(field, *ap);
                h = hash(field);
                igp = (struct ignore *) calloc(1, sizeof (struct ignore));
@@ -474,16 +478,37 @@ igfield(list)
  */
 igshow()
 {
  */
 igshow()
 {
-       register int h, did;
+       register int h, count;
        struct ignore *igp;
        struct ignore *igp;
+       char **ap, **ring;
+       int igcomp();
 
 
-       did = 0;
+       count = 0;
        for (h = 0; h < HSHSIZE; h++)
        for (h = 0; h < HSHSIZE; h++)
-               for (igp = ignore[h]; igp != 0; igp = igp->i_link) {
-                       printf("%s\n", igp->i_field);
-                       did++;
-               }
-       if (!did)
+               for (igp = ignore[h]; igp != 0; igp = igp->i_link)
+                       count++;
+       if (count == 0) {
                printf("No fields currently being ignored.\n");
                printf("No fields currently being ignored.\n");
+               return(0);
+       }
+       ring = (char **) salloc((count + 1) * sizeof (char *));
+       ap = ring;
+       for (h = 0; h < HSHSIZE; h++)
+               for (igp = ignore[h]; igp != 0; igp = igp->i_link)
+                       *ap++ = igp->i_field;
+       *ap = 0;
+       qsort(ring, count, sizeof (char *), igcomp);
+       for (ap = ring; *ap != 0; ap++)
+               printf("%s\n", *ap);
        return(0);
 }
        return(0);
 }
+
+/*
+ * Compare two names for sorting ignored field list.
+ */
+igcomp(l, r)
+       char **l, **r;
+{
+
+       return(strcmp(*l, *r));
+}