unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: emacs-devel@gnu.org
Subject: Re: Fwd: Emacs hangs when "foo\\|\\|bar" is in `font-lock-keywords'
Date: Mon, 11 Jul 2005 17:44:01 -0400	[thread overview]
Message-ID: <jwvy88dow6r.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <E1Dn7XW-0000lP-3Q@fencepost.gnu.org> (Richard M. Stallman's message of "Tue, 28 Jun 2005 00:17:38 -0400")

> 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))))

      reply	other threads:[~2005-07-11 21:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-28  4:17 [daniel@brockman.se: Emacs hangs when "foo\\|\\|bar" is in `font-lock-keywords'] Richard M. Stallman
2005-07-11 21:44 ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvy88dow6r.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).