2002-01-11  Katsumi Yamaoka  <yamaoka@jpl.org>
 
+       * lisp/gnus-clfns.el (butlast): Fix a serious bug that it behaved
+       like `nbutlast'.  Special thanks to Keiichi-san for the great
+       discovery.
+       (last, butlast): Use the native function if Emacs 21+ is used.
+
        * lisp/gnus.el (gnus-product-variable-file-list): Add a check for
        the value of `gnus-use-correct-string-widths' in the forms.
 
 
 ;;; gnus-clfns.el --- compiler macros for emulating cl functions
-;; Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+
+;; Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
 
 ;; Author: Kastsumi Yamaoka <yamaoka@jpl.org>
 ;; Keywords: cl, compile
 
   (define-compiler-macro butlast (&whole form x &optional n)
     (if (and (fboundp 'butlast)
-            (subrp (symbol-function 'butlast)))
+            (or (>= emacs-major-version 21)
+                (subrp (symbol-function 'butlast))))
        form
       (if n
          `(let ((x ,x)
                 (or n (setq n 1))
                 (and (< n m)
                      (progn
-                       (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
+                       (if (> n 0)
+                           (progn
+                             (setq x (copy-sequence x))
+                             (setcdr (nthcdr (- (1- m) n) x) nil)))
                        x)))))
        `(let* ((x ,x)
                (m (length x)))
           (and (< 1 m)
                (progn
+                 (setq x (copy-sequence x))
                  (setcdr (nthcdr (- m 2) x) nil)
                  x))))))
 
 
   (define-compiler-macro last (&whole form x &optional n)
     (if (and (fboundp 'last)
-            (subrp (symbol-function 'last)))
+            (or (>= emacs-major-version 21)
+                (subrp (symbol-function 'last))))
        form
       (if n
          `(let* ((x ,x)