[gnu.emacs.bug] Possible infinite loop in forward-paragraph

trinkle@PURDUE.EDU (01/24/89)

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

tower@WHEATIES.AI.MIT.EDU (Leonard H. Tower Jr.) (01/27/89)

   Organization: SRI International, Menlo Park, CA
   Phone: Office--415/859-3759  Home--415/941-0238
   Date: Fri, 27 Jan 89 00:06:08 PST
   From: Bill Wohler <wohler@spam.istc.sri.com>

     so how many times are we going to see this message?   5, and
     counting... 

						   --bw

This looks to be a loop at one of the re-dist addresses.  They are off
the list until they fix it.

enjoy -len 

wohler@SPAM.ISTC.SRI.COM (Bill Wohler) (01/27/89)

  so how many times are we going to see this message?   5, and
  counting... 

						--bw