diff options
| author | Shigeru Fukaya | 2015-07-26 10:43:10 -0700 |
|---|---|---|
| committer | Paul Eggert | 2015-07-26 10:43:28 -0700 |
| commit | 4c55786d9b2a5d571f3e543cc261ce0702c7341e (patch) | |
| tree | 676c9e5a2663ff32c744a45814f82ac3abc23159 | |
| parent | fac8492664246c49ee145802cc124aa9e1636e7b (diff) | |
| download | emacs-4c55786d9b2a5d571f3e543cc261ce0702c7341e.tar.gz emacs-4c55786d9b2a5d571f3e543cc261ce0702c7341e.zip | |
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.
| -rw-r--r-- | lisp/subr.el | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/lisp/subr.el b/lisp/subr.el index e2c1baea442..bfdc0ff4a13 100644 --- a/lisp/subr.el +++ b/lisp/subr.el | |||
| @@ -440,16 +440,16 @@ one is kept." | |||
| 440 | First and last elements are considered consecutive if CIRCULAR is | 440 | First and last elements are considered consecutive if CIRCULAR is |
| 441 | non-nil." | 441 | non-nil." |
| 442 | (let ((tail list) last) | 442 | (let ((tail list) last) |
| 443 | (while (consp tail) | 443 | (while (cdr tail) |
| 444 | (if (equal (car tail) (cadr tail)) | 444 | (if (equal (car tail) (cadr tail)) |
| 445 | (setcdr tail (cddr tail)) | 445 | (setcdr tail (cddr tail)) |
| 446 | (setq last (car tail) | 446 | (setq last tail |
| 447 | tail (cdr tail)))) | 447 | tail (cdr tail)))) |
| 448 | (if (and circular | 448 | (if (and circular |
| 449 | (cdr list) | 449 | last |
| 450 | (equal last (car list))) | 450 | (equal (car tail) (car list))) |
| 451 | (nbutlast list) | 451 | (setcdr last nil))) |
| 452 | list))) | 452 | list) |
| 453 | 453 | ||
| 454 | (defun number-sequence (from &optional to inc) | 454 | (defun number-sequence (from &optional to inc) |
| 455 | "Return a sequence of numbers from FROM to TO (both inclusive) as a list. | 455 | "Return a sequence of numbers from FROM to TO (both inclusive) as a list. |