]> diplodocus.org Git - nmh/blobdiff - uip/sortm.c
Added context_find_prefix().
[nmh] / uip / sortm.c
index 6e7a74919cf362d7bfd5144a75d48baac291250a..0b8e18534188e3a02932cfefc8cec1b3f2471307 100644 (file)
@@ -78,13 +78,7 @@ main (int argc, char **argv)
     struct smsg **dlist;
     int checksw = 0;
 
     struct smsg **dlist;
     int checksw = 0;
 
-#ifdef LOCALE
-    setlocale(LC_ALL, "");
-#endif
-    invo_name = r1bindex (argv[0], '/');
-
-    /* read user profile/context */
-    context_read();
+    if (nmh_init(argv[0], 1)) { return 1; }
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
 
     arguments = getarguments (invo_name, argc, argv, 1);
     argp = arguments;
@@ -199,7 +193,7 @@ main (int argc, char **argv)
        adios (maildir, "unable to change directory to");
 
     /* read folder and create message structure */
        adios (maildir, "unable to change directory to");
 
     /* read folder and create message structure */
-    if (!(mp = folder_read (folder)))
+    if (!(mp = folder_read (folder, 1)))
        adios (NULL, "unable to read folder %s", folder);
 
     /* check for empty folder */
        adios (NULL, "unable to read folder %s", folder);
 
     /* check for empty folder */
@@ -259,7 +253,7 @@ main (int argc, char **argv)
         * the collection of messages with the same subj
         * given a message number.
         */
         * the collection of messages with the same subj
         * given a message number.
         */
-       il = (struct smsg ***) calloc (mp->hghsel+1, sizeof(*il));
+       il = (struct smsg ***) mh_xcalloc (mp->hghsel+1, sizeof(*il));
        if (! il)
            adios (NULL, "couldn't allocate msg list");
        for (i = 0; i < nmsgs; i++)
        if (! il)
            adios (NULL, "couldn't allocate msg list");
        for (i = 0; i < nmsgs; i++)
@@ -293,6 +287,7 @@ main (int argc, char **argv)
            }
        }
        *fp = 0;
            }
        }
        *fp = 0;
+       free (il);
        free (slist);
        free (dlist);
        dlist = flist;
        free (slist);
        free (dlist);
        dlist = flist;
@@ -323,7 +318,7 @@ read_hdrs (struct msgs *mp, char *datesw)
     twscopy (&tb, dlocaltimenow ());
 
     smsgs = (struct smsg *)
     twscopy (&tb, dlocaltimenow ());
 
     smsgs = (struct smsg *)
-       calloc ((size_t) (mp->hghsel - mp->lowsel + 2),
+       mh_xcalloc ((size_t) (mp->hghsel - mp->lowsel + 2),
            sizeof(*smsgs));
     if (smsgs == NULL)
        adios (NULL, "unable to allocate sort storage");
            sizeof(*smsgs));
     if (smsgs == NULL)
        adios (NULL, "unable to allocate sort storage");
@@ -368,7 +363,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg)
        case FLD:
        case FLDPLUS:
            compnum++;
        case FLD:
        case FLDPLUS:
            compnum++;
-           if (!mh_strcasecmp (nam, datesw)) {
+           if (!strcasecmp (nam, datesw)) {
                datecomp = add (buf, datecomp);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
                datecomp = add (buf, datecomp);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
@@ -377,7 +372,7 @@ get_fields (char *datesw, int msg, struct smsg *smsg)
                }
                if (!subjsort || subjcomp)
                    break;
                }
                if (!subjsort || subjcomp)
                    break;
-           } else if (subjsort && !mh_strcasecmp (nam, subjsort)) {
+           } else if (subjsort && !strcasecmp (nam, subjsort)) {
                subjcomp = add (buf, subjcomp);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
                subjcomp = add (buf, subjcomp);
                while (state == FLDPLUS) {
                    bufsz = sizeof buf;
@@ -565,7 +560,7 @@ static void
 rename_msgs (struct msgs *mp, struct smsg **mlist)
 {
     int i, j, old, new;
 rename_msgs (struct msgs *mp, struct smsg **mlist)
 {
     int i, j, old, new;
-    seqset_t tmpset;
+    bvector_t tmpset = bvector_create (0);
     char f1[BUFSIZ], tmpfil[BUFSIZ];
     char newbuf[PATH_MAX + 1];
     struct smsg *sp;
     char f1[BUFSIZ], tmpfil[BUFSIZ];
     char newbuf[PATH_MAX + 1];
     struct smsg *sp;
@@ -605,7 +600,7 @@ rename_msgs (struct msgs *mp, struct smsg **mlist)
        if (rename (f1, tmpfil) == NOTOK)
            adios (tmpfil, "unable to rename %s to ", f1);
 
        if (rename (f1, tmpfil) == NOTOK)
            adios (tmpfil, "unable to rename %s to ", f1);
 
-       get_msg_flags (mp, &tmpset, old);
+       get_msg_flags (mp, tmpset, old);
 
        rename_chain (mp, mlist, j, i);
 
 
        rename_chain (mp, mlist, j, i);
 
@@ -620,7 +615,9 @@ rename_msgs (struct msgs *mp, struct smsg **mlist)
        if (rename (tmpfil, m_name(new)) == NOTOK)
            adios (m_name(new), "unable to rename %s to", tmpfil);
 
        if (rename (tmpfil, m_name(new)) == NOTOK)
            adios (m_name(new), "unable to rename %s to", tmpfil);
 
-       set_msg_flags (mp, &tmpset, new);
+       set_msg_flags (mp, tmpset, new);
        mp->msgflags |= SEQMOD;
     }
        mp->msgflags |= SEQMOD;
     }
+
+    bvector_free (tmpset);
 }
 }