emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 4c55786: Fix infinite loop in delete-consecutive-du


From: Paul Eggert
Subject: [Emacs-diffs] master 4c55786: Fix infinite loop in delete-consecutive-dups
Date: Sun, 26 Jul 2015 17:43:35 +0000

branch: master
commit 4c55786d9b2a5d571f3e543cc261ce0702c7341e
Author: Shigeru Fukaya <address@hidden>
Commit: Paul Eggert <address@hidden>

    Fix infinite loop in delete-consecutive-dups
    
    * lisp/subr.el (delete-consecutive-dups): Work even if the last
    element is nil (Bug#20588).  Avoid rescan of a circular list in
    deletion of last element.
---
 lisp/subr.el |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lisp/subr.el b/lisp/subr.el
index e2c1bae..bfdc0ff 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -440,16 +440,16 @@ one is kept."
 First and last elements are considered consecutive if CIRCULAR is
 non-nil."
   (let ((tail list) last)
-    (while (consp tail)
+    (while (cdr tail)
       (if (equal (car tail) (cadr tail))
          (setcdr tail (cddr tail))
-       (setq last (car tail)
+       (setq last tail
              tail (cdr tail))))
     (if (and circular
-            (cdr list)
-            (equal last (car list)))
-       (nbutlast list)
-      list)))
+            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.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]