GNU bug report logs -
#19434
24.4; cl-subseq bounding issues
Previous Next
Reported by: Leo Liu <sdl.web <at> gmail.com>
Date: Wed, 24 Dec 2014 04:15:02 UTC
Severity: minor
Found in version 24.4
Fixed in version 25.1
Done: Leo Liu <sdl.web <at> gmail.com>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 19434 in the body.
You can then email your comments to 19434 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19434
; Package
emacs
.
(Wed, 24 Dec 2014 04:15:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Leo Liu <sdl.web <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Wed, 24 Dec 2014 04:15:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
At the moment (cl-subseq '(1 2 3) 0 5) => (1 2 3 nil nil)
I propose the following fix:
diff --git a/lisp/emacs-lisp/cl-extra.el b/lisp/emacs-lisp/cl-extra.el
index a94dcd33..b50c1e6a 100644
--- a/lisp/emacs-lisp/cl-extra.el
+++ b/lisp/emacs-lisp/cl-extra.el
@@ -524,15 +524,21 @@ (defun cl-subseq (seq start &optional end)
`(progn (cl-replace ,seq ,new :start1 ,start :end1 ,end)
,new))))
(if (stringp seq) (substring seq start end)
- (let (len)
+ (let ((orig-start start) (orig-end end) len)
(and end (< end 0) (setq end (+ end (setq len (length seq)))))
(if (< start 0) (setq start (+ start (or len (setq len (length seq))))))
(cond ((listp seq)
- (if (> start 0) (setq seq (nthcdr start seq)))
+ (when (> start 0)
+ (setq seq (nthcdr (1- start) seq))
+ (or seq
+ (error "Bad bounding indices: %s, %s" orig-start orig-end))
+ (setq seq (cdr seq)))
(if end
(let ((res nil))
- (while (>= (setq end (1- end)) start)
+ (while (and seq (>= (setq end (1- end)) start))
(push (pop seq) res))
+ (or (= start end)
+ (error "Bad bounding indices: %s, %s" orig-start orig-end))
(nreverse res))
(copy-sequence seq)))
(t
diff --git a/test/automated/cl-lib-tests.el b/test/automated/cl-lib-tests.el
index e4c6e914..162f7aeb 100644
--- a/test/automated/cl-lib-tests.el
+++ b/test/automated/cl-lib-tests.el
@@ -245,4 +245,10 @@ (ert-deftest cl-parse-integer ()
(ert-deftest cl-loop-destructuring-with ()
(should (equal (cl-loop with (a b c) = '(1 2 3) return (+ a b c)) 6)))
+(ert-deftest cl-subseq ()
+ (should-error (cl-subseq '(1 2 3) 4))
+ (should-not (cl-subseq '(1 2 3) 3))
+ (should (cl-subseq '(1 2 3) -3))
+ (should-error (cl-subseq '(1 2 3) 1 4)))
+
;;; cl-lib.el ends here
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19434
; Package
emacs
.
(Thu, 01 Jan 2015 16:14:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 19434 <at> debbugs.gnu.org (full text, mbox):
> At the moment (cl-subseq '(1 2 3) 0 5) => (1 2 3 nil nil)
> I propose the following fix:
Fine by me. Can you check if seq-subseq (in seq.el) needs a similar fix?
And/or if cl-subseq can make use of seq-subseq?
Stefan
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#19434
; Package
emacs
.
(Sun, 04 Jan 2015 23:06:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 19434 <at> debbugs.gnu.org (full text, mbox):
On 2015-01-02 03:13 +1100, Stefan Monnier wrote:
> Fine by me. Can you check if seq-subseq (in seq.el) needs a similar fix?
> And/or if cl-subseq can make use of seq-subseq?
I am on the road but I'll take care of this soonish.
Leo
Reply sent
to
Leo Liu <sdl.web <at> gmail.com>
:
You have taken responsibility.
(Sun, 18 Jan 2015 06:22:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Leo Liu <sdl.web <at> gmail.com>
:
bug acknowledged by developer.
(Sun, 18 Jan 2015 06:22:02 GMT)
Full text and
rfc822 format available.
Message #16 received at 19434-done <at> debbugs.gnu.org (full text, mbox):
Version: 25.1
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sun, 15 Feb 2015 12:24:04 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 185 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.