diff options
author | Christopher Schmidt <christopher@ch.ristopher.com> | 2012-05-06 11:38:30 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-05-06 11:38:30 -0400 |
commit | e129292c44b6392adadb27bbd4bce94893316ff9 (patch) | |
tree | ba16b85e97be381c3166836e8db98b03bad73e66 /lisp/emacs-lisp/cl-macs.el | |
parent | 491503ddd21cae26d3e349e39ee2e139680a220f (diff) | |
download | emacs-e129292c44b6392adadb27bbd4bce94893316ff9.tar.gz emacs-e129292c44b6392adadb27bbd4bce94893316ff9.tar.bz2 emacs-e129292c44b6392adadb27bbd4bce94893316ff9.zip |
* lisp/emacs-lisp/cl-macs.el (cl-expr-contains): Handle cons cells
whose cdr is not a cons cell correctly.
Fixes: debbugs:11038
Diffstat (limited to 'lisp/emacs-lisp/cl-macs.el')
-rw-r--r-- | lisp/emacs-lisp/cl-macs.el | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el index 35cda8cfcf6..8050da400fe 100644 --- a/lisp/emacs-lisp/cl-macs.el +++ b/lisp/emacs-lisp/cl-macs.el @@ -143,11 +143,16 @@ ;;; Count number of times X refers to Y. Return nil for 0 times. (defun cl-expr-contains (x y) + ;; FIXME: This is naive, and it will count Y as referred twice in + ;; (let ((Y 1)) Y) even though it should be 0. Also it is often called on + ;; non-macroexpanded code, so it may also miss some occurrences that would + ;; only appear in the expanded code. (cond ((equal y x) 1) ((and (consp x) (not (memq (car-safe x) '(quote function function*)))) (let ((sum 0)) - (while x + (while (consp x) (setq sum (+ sum (or (cl-expr-contains (pop x) y) 0)))) + (setq sum (+ sum (or (cl-expr-contains x y) 0))) (and (> sum 0) sum))) (t nil))) |