Xref: utzoo comp.sources.bugs:2145 comp.mail.elm:2225 Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!dcl-cs!aber-cs!pcg From: pcg@aber-cs.UUCP (Piercarlo Grandi) Newsgroups: comp.sources.bugs,comp.mail.elm Subject: Patches to Summary: Unofficial patch to elm2.2 for improved sorting etc... Keywords: patch bug elm 2.2 sort Message-ID: <1566@aber-cs.UUCP> Date: 5 Jan 90 17:29:50 GMT Reply-To: pcg@cs.aber.ac.uk (Piercarlo Grandi) Organization: Dept of CS, UCW Aberystwyth (Disclaimer: my statements are purely personal) Lines: 1408 This is a patch to elm2.2 PL14 for improved sorting functionality, speed, etc... Here it is: A description of some changes to elm 2.2 PL14 I use elm to maintain a large number of folders of archived news articles, and of electronic mail. Each folder may well contain several hundred messages and be well over a mmegabyte lonf, and contain many different threads. To me elm should be as efficient as cataologing system as possible. I have modified elm to handler with greater efficiency very large folders, and to presents their contents in sorted order. Th major change ffected has been to sorting; the standard elm keeps two dates for each message, sent and received. The sent date is kept as a set of strings, and the received one as a set of binary numbers. I have inverted this, as most often one wants to manipulate the message by its sent date, which is essential to its character, rather than the received date, which depends only on transport. I have also added code that adds the sent date as the secondary sorting criterion if the primary sort criterion is another. I have also improved the subject sort code. Since I keep my news folders sorted by subject, these changes mean that within each subject articles will be efficiently sorted by date written, thus automatically in the right order to follow the devwelopment of the thread. I keep my mail folders sorted by date sent, because their "urgency" seems to me more dependent on when they were written than on when they were delivered. Occasionally I sort my mail folders by sender, and again it is useful to have messages from the same sender sorted by date written. Other changes have been improved parsing of envelope (the delivered date), and enabling RFC822 date parsing for the date written. Here is a comment on the various files modified: hdrs/defs.h added field 'second' to struct 'date_rec', and swapped the storage method of the received date and the sent date. utils/from.c corrected a bug evident when frm'ing from several folders, that the folder's FILE was not closed, eventually running out of filedescriptors. src/addr_util.c Changed the parsing of the envelope to cope with the two main different format for the envelope date, and to store the envelope date as strings in the message descriptor. Made the RFC822 parse_arpa_date the default and only one, and made it store the parsed date into the binary 'sent' substruct of the message descriptor. src/aliadb.c src/conn_to.c src/domains.c src/init.c src/opt_utils.c src/strings.c Now compiles certain code only when really needed. Saves a little space in the executable. src/elm.c Changes made necessary because now the received date is stored as strings, and the sent date as binary numbers. src/leavembox.c Nullified the code that on exit resorts the folder as it was when we opened it. We want to have the mailbox physically sorted as we have it when we clsoe it, so that typically examining it with other tools (e.g. frm) gives us messages in the same order as when we look at it with elm. src/newmbox.c Changed the logic used to allocate the array of message headers. We initally allocate it 3 clicks long, grow it by 1 klick every time it needs expanding, and when we change mailbox we free the headers in excess. Another small correction also is because we now parse the written date with parse_arpa_date into a binary record. src/read_rc.c The default weedlist, which *cannot be overriden* by the user, has been made more sensible, both for saved news articles and regular mail. We weed out all fields that are either already present in elm's message index or message pager (e.g. From, To, ...), or are only relevant to transport or other mail handling programs and not the user (e.g. Message-Id, Received, ...). src/screen.c A couple of changes because now the sent date is binary and no longer symbolic. src/sort.c A couple of changes. First of all now we have SENT_DATE as a default, secondary sort criterion. This is virtually always appropriate, and very inexpensive, given that now it is the sent date that is stored in binary form. Second, the code that strips any leading "Re: " type prefix from the subject has been completely rewritten (it was quite bad), and made more efficient and general, and a few pitfalls avoided. =================================================================== RCS file: hdrs/defs.h,v retrieving revision 1.1 diff -c -r1.1 hdrs/defs.h *** /tmp/,RCSt1a22140 Sun Dec 24 16:43:51 1989 --- hdrs/defs.h Sun Dec 24 16:41:22 1989 *************** *** 271,276 **** --- 268,274 ---- int year; /** time... **/ int hour; int minute; + int second; }; struct header_rec { *************** *** 281,287 **** int exit_disposition; /** whether to keep, store, delete **/ int status_chgd; /** whether became read or old, etc. **/ long offset; /** offset in bytes of message **/ ! struct date_rec received;/** when elm received here **/ char from[STRING]; /** who sent the message? **/ char to[STRING]; /** who it was sent to **/ char messageid[STRING]; /** the Message-ID: value **/ --- 279,285 ---- int exit_disposition; /** whether to keep, store, delete **/ int status_chgd; /** whether became read or old, etc. **/ long offset; /** offset in bytes of message **/ ! struct date_rec sent; /** when the msg was sent **/ char from[STRING]; /** who sent the message? **/ char to[STRING]; /** who it was sent to **/ char messageid[STRING]; /** the Message-ID: value **/ *************** *** 288,294 **** char dayname[8]; /** when the **/ char month[10]; /** message **/ char day[3]; /** was **/ ! char year[5]; /** sent **/ char time[NLEN]; /** to you! **/ char subject[STRING]; /** The subject of the mail **/ char mailx_status[WLEN];/** mailx status flags (RO...) **/ --- 286,292 ---- char dayname[8]; /** when the **/ char month[10]; /** message **/ char day[3]; /** was **/ ! char year[5]; /** delivered **/ char time[NLEN]; /** to you! **/ char subject[STRING]; /** The subject of the mail **/ char mailx_status[WLEN];/** mailx status flags (RO...) **/ =================================================================== RCS file: utils/from.c,v retrieving revision 1.1 diff -c -r1.1 utils/from.c *** /tmp/,RCSt1a22140 Sun Dec 24 16:43:52 1989 --- utils/from.c Sun Dec 24 14:48:08 1989 *************** *** 117,127 **** --- 114,127 ---- } } else + { if (read_headers(optind+1 == argc)==0) if (optind+1 == argc) printf("No mail\n"); else printf("No messages in that folder!\n"); + fclose(mailfile); + } optind++; } =================================================================== RCS file: src/addr_util.c,v retrieving revision 1.1 diff -c -r1.1 addr_util.c *** /tmp/,RCSt1a22077 Sun Dec 24 16:28:04 1989 --- src/addr_util.c Sat Dec 23 22:38:26 1989 *************** *** 434,444 **** timebuff[0] = '\0'; junk[0] = '\0'; ! /* From */ ! sscanf(buffer, "%*s %*s %*s %*s %*s %s %*s %s", timebuff, junk); ! if (strlen(timebuff) < 3) { dprint(3,(debugfile, "Real_from returns FAIL [no time field] on\n-> %s\n", buffer)); --- 433,458 ---- timebuff[0] = '\0'; junk[0] = '\0'; ! ! ! /* ! From ! ! | ! ! | !