* bug#20588: [PATCH] 24.5; delete-consecutive-dups may loop infinity
@ 2015-05-16 5:18 Shigeru Fukaya
2015-05-16 8:01 ` Leo Liu
2015-07-26 17:45 ` Paul Eggert
0 siblings, 2 replies; 3+ messages in thread
From: Shigeru Fukaya @ 2015-05-16 5:18 UTC (permalink / raw)
To: 20588
[-- Attachment #1: Type: text/plain, Size: 234 bytes --]
Hello.
delete-consecutive-dups falls into infinite loop if the last element
is nil. The attached code will fix it, and besides, avoid re-scan
(call of nbutlast) of a circular list in deletion of the last element.
Regards,
Shigeru
[-- Attachment #2: subr.diff --]
[-- Type: application/octet-stream, Size: 1122 bytes --]
*** subr.el Thu May 7 12:24:21 2015
--- subr.new.el Sat May 16 13:40:47 2015
***************
*** 440,455 ****
First and last elements are considered consecutive if CIRCULAR is
non-nil."
(let ((tail list) last)
! (while (consp tail)
(if (equal (car tail) (cadr tail))
(setcdr tail (cddr tail))
! (setq last (car tail)
tail (cdr tail))))
(if (and circular
! (cdr list)
! (equal last (car list)))
! (nbutlast list)
! list)))
(defun number-sequence (from &optional to inc)
"Return a sequence of numbers from FROM to TO (both inclusive) as a list.
--- 440,455 ----
First and last elements are considered consecutive if CIRCULAR is
non-nil."
(let ((tail list) last)
! (while (cdr tail)
(if (equal (car tail) (cadr tail))
(setcdr tail (cddr tail))
! (setq last tail
tail (cdr tail))))
(if (and circular
! last
! (equal (car tail) (car list)))
! (setcdr last nil)))
! list)
(defun number-sequence (from &optional to inc)
"Return a sequence of numbers from FROM to TO (both inclusive) as a list.
[-- Attachment #3: ChangeLog --]
[-- Type: application/octet-stream, Size: 87 bytes --]
* subr.el (delete-consecutive-dups): Avoid infinite loop and
invocation of nbutlast.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-07-26 17:45 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-16 5:18 bug#20588: [PATCH] 24.5; delete-consecutive-dups may loop infinity Shigeru Fukaya
2015-05-16 8:01 ` Leo Liu
2015-07-26 17:45 ` Paul Eggert
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).