Mercurial > hg > xemacs-beta
changeset 2353:186992a01a13
[xemacs-hg @ 2004-10-28 10:41:35 by stephent]
fix record-buffer crash <87u0sf2ksj.fsf_-_@tleepslib.sk.tsukuba.ac.jp>
author | stephent |
---|---|
date | Thu, 28 Oct 2004 10:41:40 +0000 |
parents | cae9d7b3fe76 |
children | ec5cb254c826 |
files | src/ChangeLog src/buffer.c |
diffstat | 2 files changed, 44 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/ChangeLog Wed Oct 27 21:52:28 2004 +0000 +++ b/src/ChangeLog Thu Oct 28 10:41:40 2004 +0000 @@ -1,3 +1,10 @@ +2004-09-02 Yoshiki Hayashi <yoshiki@xemacs.org> + + * buffer.c (Frecord_buffer): Make sure the argument is buffer + to fix a crash. Also, check the buffer is live and it + really exists in buffer_list. If the buffer is not in the list, + prepend it. + 2004-10-22 Stephen J. Turnbull <stephen@xemacs.org> * XEmacs 21.5.18 "chestnut" is released.
--- a/src/buffer.c Wed Oct 27 21:52:28 2004 +0000 +++ b/src/buffer.c Thu Oct 28 10:41:40 2004 +0000 @@ -1374,38 +1374,60 @@ { REGISTER Lisp_Object lynk, prev; struct frame *f = selected_frame (); - + int buffer_found = 0; + + CHECK_BUFFER (buffer); + if (!BUFFER_LIVE_P (XBUFFER (buffer))) + return Qnil; prev = Qnil; for (lynk = Vbuffer_alist; CONSP (lynk); lynk = XCDR (lynk)) { if (EQ (XCDR (XCAR (lynk)), buffer)) - break; + { + buffer_found = 1; + break; + } prev = lynk; } - /* Effectively do Vbuffer_alist = delq_no_quit (lynk, Vbuffer_alist) */ - if (NILP (prev)) - Vbuffer_alist = XCDR (Vbuffer_alist); + if (buffer_found) + { + /* Effectively do Vbuffer_alist = delq_no_quit (lynk, Vbuffer_alist) */ + if (NILP (prev)) + Vbuffer_alist = XCDR (Vbuffer_alist); + else + XCDR (prev) = XCDR (XCDR (prev)); + XCDR (lynk) = Vbuffer_alist; + Vbuffer_alist = lynk; + } else - XCDR (prev) = XCDR (XCDR (prev)); - XCDR (lynk) = Vbuffer_alist; - Vbuffer_alist = lynk; + Vbuffer_alist = Fcons (Fcons (Fbuffer_name(buffer), buffer), Vbuffer_alist); /* That was the global one. Now do the same thing for the per-frame buffer-alist. */ + buffer_found = 0; prev = Qnil; for (lynk = f->buffer_alist; CONSP (lynk); lynk = XCDR (lynk)) { if (EQ (XCDR (XCAR (lynk)), buffer)) - break; + { + buffer_found = 1; + break; + } prev = lynk; } - /* Effectively do f->buffer_alist = delq_no_quit (lynk, f->buffer_alist) */ - if (NILP (prev)) - f->buffer_alist = XCDR (f->buffer_alist); + if (buffer_found) + { + /* Effectively do f->buffer_alist = delq_no_quit (lynk, f->buffer_alist) */ + if (NILP (prev)) + f->buffer_alist = XCDR (f->buffer_alist); + else + XCDR (prev) = XCDR (XCDR (prev)); + XCDR (lynk) = f->buffer_alist; + f->buffer_alist = lynk; + } else - XCDR (prev) = XCDR (XCDR (prev)); - XCDR (lynk) = f->buffer_alist; - f->buffer_alist = lynk; + f->buffer_alist = Fcons (Fcons (Fbuffer_name(buffer), buffer), + f->buffer_alist); return Qnil; }