🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.emacs.bug
Article #99488

Probable bug in time.el

#99488
From: Scott D Kalter
Date: Thu, 30 Aug 1990 19:03
63 lines
3357 bytes
While reading the code in time.el I noticed a probable bug.  The code
for display-time-filter does not save and restore match-data even
though it does string-match'es that could conceivably succeed.  I
noticed this only a day after I had read a warning about filters doing
matching in the GNU Emacs Lisp Reference manual on pg. 446 and pg.
480.

I noticed that under normal circumstances display-time-filter's
matches will fail (since it is keeping up with the input).  However,
in the few circumstances where it may get more input and a match
succeeds this could destroy a needed value in match data and cause the
user to see a nearly untraceable bug.

Below is a context diff for one possible fix to display-time-filter.

-Scott D. Kalter  <sdk@twinsun.com>
-Chris D. Houser  <chris@twinsun.com>

----------------------------------------------------------------
[shadow]sdk> rcsdiff -r1.0 -r1.1 -c time.el
===================================================================
RCS file: RCS/time.el,v
retrieving revision 1.0
retrieving revision 1.1
diff -c -r1.0 -r1.1
*** 1.0	1990/08/30 18:49:11
--- 1.1	1990/08/30 18:52:11
***************
*** 64,77 ****
    ;; so save time by flushing the rest.
    ;; This way, if we have many different times all collected at once,
    ;; we can discard all but the last few very fast.
!   (if (> (length string) 30)
!       (setq string (substring string -30)))
!   ;; Now discard all but the very last one.
!   (while (and (> (length string) 4)
! 	      (string-match "[0-9]+:[0-9][0-9].." string 4))
!     (setq string (substring string (match-beginning 0))))
!   (if (string-match "[^0-9][0-9]+:" string)
!       (setq string (substring string 0 (1+ (match-beginning 0)))))
    ;; Append the date if desired.
    (if display-time-day-and-date
        (setq string (concat (substring (current-time-string) 0 11) string)))
--- 64,79 ----
    ;; so save time by flushing the rest.
    ;; This way, if we have many different times all collected at once,
    ;; we can discard all but the last few very fast.
!   (let ((match-info (match-data)))
!     (if (> (length string) 30)
! 	(setq string (substring string -30)))
!     ;; Now discard all but the very last one.
!     (while (and (> (length string) 4)
! 		(string-match "[0-9]+:[0-9][0-9].." string 4))
!       (setq string (substring string (match-beginning 0))))
!     (if (string-match "[^0-9][0-9]+:" string)
! 	(setq string (substring string 0 (1+ (match-beginning 0)))))
!     (store-match-data match-info))
    ;; Append the date if desired.
    (if display-time-day-and-date
        (setq string (concat (substring (current-time-string) 0 11) string)))
[shadow]sdk> 
----------------------------------------------------------------
Technical Details
Message-ID: <9008301903.AA00728@shadow.twinsun.com>
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!twinsun.com!sdk

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fb2f1,33af56de43fc43c,start
X-Google-Attributes: gidfb2f1,public
X-Google-ArrivalTime: 1990-08-30 12:03:03 PST
Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!tut.cis.ohio-state.edu!twinsun.com!sdk
From: sdk@twinsun.com (Scott D Kalter)
Newsgroups: gnu.emacs.bug
Subject: Probable bug in time.el
Message-ID: <9008301903.AA00728@shadow.twinsun.com>
Date: 30 Aug 90 19:03:03 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 63
Posted: Thu Aug 30 20:03:03 1990