Path: utzoo!utgpu!watmath!uunet!tut.cis.ohio-state.edu!PURDUE.EDU!trinkle From: trinkle@PURDUE.EDU Newsgroups: gnu.emacs.bug Subject: Possible infinite loop in forward-paragraph (GNU Emacs 18.52) Message-ID: <8901231725.AA03733@bors.cs.purdue.edu> Date: 23 Jan 89 17:25:04 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 83 Index: lisp/paragraphs.el GNU Emacs 18.52 Description: This bug exists in 18.51 and 18.52 GNU Emacs. If, in tex-mode, you have a buffer with nothing by paragraph-separaters, (backward-paragraph) will go into an infinite loop. Repeat-By: Create a file foo.tex with the following contents: ------------------------------cut here------------------------------ \begin{..} \item ... \item ... \item ... \item ... \end{...} \begin{..} \item ... \item ... \item ... \item ... \end{...} \begin{..} \item ... \item ... \item ... \item ... \end{...} ------------------------------cut here------------------------------ Start GNU Emacs and visit foo.tex. This should load tex-mode. Go to the end of the buffer and do a backward-paragraph (probably bound to META-[). GNU Emacs will go into an infinite loop. The problem is in forward-paragraph when doing a backward-paragraph search (arg = -1). If a paragraph-start match is found, then there is a while loop that keeps doing a (forward-line 1) while (looking-at paragraph-separate). Unfortunately there is no check for (eobp). In a file with nothing but paragraph-separate lines, this will cause an infinite loop. Fix: If there is a check for (eobp), things seem to work just fine. This garuantees that the while loop will never be an infinite loop. Replace (not (bobp))) (re-search-backward paragraph-start nil t)) ;; Found one. (progn ! (while (looking-at paragraph-separate) (forward-line 1)) (if (eq (char-after (- (point) 2)) ?\n) (forward-line -1))) ;; No starter or separator line => use buffer beg. (goto-char (point-min)))) (setq arg (1+ arg))) (while (> arg 0) with (not (bobp))) (re-search-backward paragraph-start nil t)) ;; Found one. (progn ! (while (and (looking-at paragraph-separate) (not (eobp))) (forward-line 1)) (if (eq (char-after (- (point) 2)) ?\n) (forward-line -1))) ;; No starter or separator line => use buffer beg. (goto-char (point-min)))) (setq arg (1+ arg))) (while (> arg 0) Daniel Trinkle trinkle@cs.purdue.edu Dept. of Computer Sciences {backbone}!purdue!trinkle Purdue University 317-494-7844 West Lafayette, IN 47907