From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Fwd: Emacs hangs when "foo\\|\\|bar" is in `font-lock-keywords' Date: Mon, 11 Jul 2005 17:44:01 -0400 Message-ID: References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1121118974 7520 80.91.229.2 (11 Jul 2005 21:56:14 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 11 Jul 2005 21:56:14 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Jul 11 23:56:06 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1Ds6FA-0002Hk-Vt for ged-emacs-devel@m.gmane.org; Mon, 11 Jul 2005 23:55:17 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ds6Gl-0006x0-9p for ged-emacs-devel@m.gmane.org; Mon, 11 Jul 2005 17:56:55 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Ds6De-0005N3-Gw for emacs-devel@gnu.org; Mon, 11 Jul 2005 17:53:43 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Ds6DT-0005GX-DT for emacs-devel@gnu.org; Mon, 11 Jul 2005 17:53:35 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Ds6DR-0005E8-KF for emacs-devel@gnu.org; Mon, 11 Jul 2005 17:53:29 -0400 Original-Received: from [132.204.24.67] (helo=mercure.iro.umontreal.ca) by monty-python.gnu.org with esmtp (Exim 4.34) id 1Ds6Bn-0003iD-Tw; Mon, 11 Jul 2005 17:51:48 -0400 Original-Received: from hidalgo.iro.umontreal.ca (hidalgo.iro.umontreal.ca [132.204.27.50]) by mercure.iro.umontreal.ca (Postfix) with ESMTP id B52302CF43E; Mon, 11 Jul 2005 17:44:05 -0400 (EDT) Original-Received: from asado.iro.umontreal.ca (asado.iro.umontreal.ca [132.204.24.84]) by hidalgo.iro.umontreal.ca (Postfix) with ESMTP id 95E1E4AC00A; Mon, 11 Jul 2005 17:44:01 -0400 (EDT) Original-Received: by asado.iro.umontreal.ca (Postfix, from userid 20848) id 7ABB2E6C1D; Mon, 11 Jul 2005 17:44:01 -0400 (EDT) Original-To: rms@gnu.org In-Reply-To: (Richard M. Stallman's message of "Tue, 28 Jun 2005 00:17:38 -0400") User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) X-DIRO-MailScanner-Information: Please contact the ISP for more information X-DIRO-MailScanner: Found to be clean X-DIRO-MailScanner-SpamCheck: n'est pas un polluriel, SpamAssassin (score=-2.798, requis 5, AWL -2.00, BAYES_00 -4.90, SUBJ_HAS_SPACES 4.10) X-MailScanner-From: monnier@iro.umontreal.ca X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:40801 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:40801 > You could describe this as user-error, but I think it might be easy > to make Font Lock bulletproof against null-matches in the regexps, > at least enough to avoid infinite loops. > Could someone please look at this and ack to me? Would that do the trick, Stefan Index: lisp/font-lock.el =================================================================== RCS file: /cvsroot/emacs/emacs/lisp/font-lock.el,v retrieving revision 1.268 diff -u -r1.268 font-lock.el --- lisp/font-lock.el 4 Jul 2005 23:08:54 -0000 1.268 +++ lisp/font-lock.el 11 Jul 2005 21:43:36 -0000 @@ -1473,8 +1473,12 @@ (while (and (< (point) end) (if (stringp matcher) (re-search-forward matcher end t) - (funcall matcher end))) - (when (and font-lock-multiline + (funcall matcher end)) + ;; Beware empty string matches since they will + ;; loop indefinitely. + (or (> (point) (match-beginning 0)) + (progn (forward-char 1) t))) + (when (and font-lock-multiline (>= (point) (save-excursion (goto-char (match-beginning 0)) (forward-line 1) (point))))