🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.vm.bug
Article #854

Re: [PATCH] teach VM about ISO-8601 dates

#854
From: Tkil
Date: Thu, 13 Mar 2003 03:24
94 lines
5282 bytes
Regarding my patch to add ISO-8601 dates to some aspects of VM:

>>>>> "Kyle" == Kyle Jones <kyle_jones@wonderworks.com> writes:

Kyle> Thanks for the patch.

You're welcome.  Thank *you* for the great mail reader.  :)

Two of the regexes that got split out are just deconstructed and
lightly-commented versions of some from "vm-su-do-date", with two
changes:

1. I added anchors ("^" and "$").  This might have been excess
   paranoia; I don't know precisely how this will be called, but I
   figured that DATE would usually be just the date string proper, and
   not a whole header line, or have extra whitespace around it, etc.

2. To match either the + or - prefix to a time zone, the original
   regexps had:

      "\\(-\\|\\+\\)"

   Since this group was never referenced, and all those backwhacks
   were starting to give me headaches, I replaced it with:

      "[+---]"

   (Which is actually used elsewhere in that file, so I figure it's
   ok.)

   Traditionally, a minus inside a character range is treated as
   non-special if it doesn't actually form a range; thus, we might be
   able to use just "[+-]" and save a bit more visual strain.
   Seems to work with isearch-forward-regexp, at least...

If you like, here's a patch that updates vm-su-do-date to use the
regex constants.  The comments on the date formats are moved up to
where the constants are created.  Please do sanity check the change to
anchored regexps, though!

Patch is incremental; if a full patch off the released 7.11 would work
better, just let me know, and I can generate it easily.

diff -ur vm-7.11p1/vm-summary.el vm-7.11p2/vm-summary.el
--- vm-7.11p1/vm-summary.el	2003-03-12 19:59:08.000000000 -0700
+++ vm-7.11p2/vm-summary.el	2003-03-12 19:58:34.000000000 -0700
@@ -810,6 +810,9 @@
       "")))
 
 (defconst vm-parse-date-rfc822-re
+  ;; The date format recognized here is the one specified in RFC 822.
+  ;; Some slop is allowed e.g. dashes between the monthday, month and
+  ;; year because such malformed headers have been observed.
   (let ((abbrev "[a-z][a-z][a-z]")      ; month and day abbrevs
         (ws     "[ \t\n]*")             ; white space
         (wsd    "[ \t\n---]*"))         ; white space or dashes
@@ -887,6 +890,8 @@
   "Regular expression used to parse `ctime(3)' formatted dates")
 
 (defun vm-parse-date-ctime (date)
+  ;; UNIX ctime(3) format, with slop allowed in the whitespace, and we
+  ;; allow for the possibility of a timezone at the end.
   (if (string-match vm-parse-date-ctime-re date)
       (let ((weekday  (vm-parse-date-get-substring date 1))
             (month    (vm-parse-date-get-substring date 2))
@@ -947,12 +952,7 @@
       (vm-set-year-of m "")
       (vm-set-hour-of m "")
       (vm-set-zone-of m ""))
-     ((string-match
-;; The date format recognized here is the one specified in RFC 822.
-;; Some slop is allowed e.g. dashes between the monthday, month and year
-;; because such malformed headers have been observed.
-"\\(\\([a-z][a-z][a-z]\\),\\)?[ \t\n]*\\([0-9][0-9]?\\)[ \t\n---]*\\([a-z][a-z][a-z]\\)[ \t\n---]*\\([0-9]*[0-9][0-9]\\)[ \t\n]*\\([0-9:]+\\)[ \t\n]*\\([a-z][a-z]?[a-z]?\\|\\(-\\|\\+\\)[01][0-9][0-9][0-9]\\)"
-       date)
+     ((string-match vm-parse-date-rfc822-re date)
       (if (match-beginning 2)
 	  (vm-su-do-weekday m (substring date (match-beginning 2)
 					    (match-end 2)))
@@ -968,11 +968,7 @@
 		   (vm-set-year-of m (concat "19" (vm-year-of m)))))))
       (vm-set-hour-of m (substring date (match-beginning 6) (match-end 6)))
       (vm-set-zone-of m (substring date (match-beginning 7) (match-end 7))))
-     ((string-match
-;; UNIX ctime(3) format, with slop allowed in the whitespace, and we allow for
-;; the possibility of a timezone at the end.
-"\\([a-z][a-z][a-z]\\)[ \t\n]*\\([a-z][a-z][a-z]\\)[ \t\n]*\\([0-9][0-9]?\\)[ \t\n]*\\([0-9:]+\\)[ \t\n]*\\([0-9][0-9][0-9][0-9]\\)[ \t\n]*\\([a-z][a-z]?[a-z]?\\|\\(-\\|\\+\\)[01][0-9][0-9][0-9]\\)?"
-       date)
+     ((string-match vm-parse-date-ctime-re date)
       (vm-su-do-weekday m (substring date (match-beginning 1)
 				     (match-end 1)))
       (vm-su-do-month m (substring date (match-beginning 2) (match-end 2)))
Only in vm-7.11p1: vm-summary.el~
Technical Details
Message-ID: <g3clsgd8j.fsf@brand.scrye.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!not-for-mail
References: <gwuj5jhdd.fsf@brand.scrye.com> <b4o1rp$tct$1@ice.wonderworks.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f6829,609808896b8b38e8
X-Google-Attributes: gidf6829,public
X-Google-ArrivalTime: 2003-03-12 19:30:01 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.frii.net!newsfeed.frii.net!not-for-mail
From: Tkil <tkil@scrye.com>
Newsgroups: gnu.emacs.vm.bug
Subject: Re: [PATCH] teach VM about ISO-8601 dates
Date: 12 Mar 2003 20:24:44 -0700
Organization: Scrye.com
Sender: tkil@brand.scrye.com
Message-ID: <g3clsgd8j.fsf@brand.scrye.com>
References: <gwuj5jhdd.fsf@brand.scrye.com> <b4o1rp$tct$1@ice.wonderworks.com>
Reply-To: Tkil <tkil@scrye.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
X-Complaints-To: news@brand.scrye.com
X-Attribution: Tkil
User-Agent: Gnus/5.0808 (Gnus v5.8.8) XEmacs/21.4 (Honest Recruiter)
Lines: 96
NNTP-Posting-Host: 216.17.180.1
X-Trace: 1047526200 news.frii.net 190 216.17.180.1