[gnu.emacs.bug] undo destroys circluar queue

enami@ptgd.sony.co.jp (enami tsugutomo) (02/23/90)

Hello,

In GNU Emacs 18.55.0 of Fri Feb 23 1990 on chihaya (berkeley-unix)

  Undo sometimes destroys own circluar queue and leaves garbage in
buffer.

  For example, let's think following 2 functions (they are just a sample):

(defun undo-bug-1 ()
  ""
  (interactive)
  (insert (make-string 4100 ?a)) )

(defun undo-bug-2 ()
  ""
  (interactive)
  (delete-region (point-min) (point-max))
  (insert (make-string 4100 ?b)) )

  First make an empty buffer and do M-x undo-bug-1 and M-x undo-bug-2.

  Then, do C-_ (undo).  It seems undone correctly, but you probably
  find garbage at beginning of buffer.

  I think there is several way to fix this.  For example, following
patch will fix this problem with telling us an error.


enami.

*** /tmp/,RCSt1022610	Fri Feb 23 19:05:29 1990
--- undo.c	Fri Feb 23 18:55:06 1990
***************
*** 328,333 ****
--- 328,337 ----
    chars = LastUndoneC;
    while (--n >= 0)
      {
+ #if defined(CHECK_NCharsLeft)
+       if (NCharsLeft < 0)
+ 	error ("Next undo information may be lost");
+ #endif
        if (!i)
  	i = u->num_undorecs;
        i--;