From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#7595: Infinite loop in cc-mode, or the coming of autumn Date: Thu, 16 Dec 2010 21:39:16 +0000 Message-ID: <20101216213915.GA3442__49696.8405823738$1292537376$gmane$org@muc.de> References: <4D000FF1.10307@gmail.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1292537376 31475 80.91.229.12 (16 Dec 2010 22:09:36 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 16 Dec 2010 22:09:36 +0000 (UTC) Cc: 7595@debbugs.gnu.org To: Daniel Colascione Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Dec 16 23:09:30 2010 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PTM0u-0003Dd-15 for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Dec 2010 23:09:28 +0100 Original-Received: from localhost ([127.0.0.1]:50565 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTLkk-0007pU-8P for geb-bug-gnu-emacs@m.gmane.org; Thu, 16 Dec 2010 16:52:46 -0500 Original-Received: from [140.186.70.92] (port=40168 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PTLkg-0007pN-7k for bug-gnu-emacs@gnu.org; Thu, 16 Dec 2010 16:52:43 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PTLkf-0001NK-6z for bug-gnu-emacs@gnu.org; Thu, 16 Dec 2010 16:52:42 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40926) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PTLkd-0001Mz-MQ; Thu, 16 Dec 2010 16:52:39 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PTLE6-0004Mq-OZ; Thu, 16 Dec 2010 16:19:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Thu, 16 Dec 2010 21:19:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 7595 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 7595-submit@debbugs.gnu.org id=B7595.129253431116751 (code B ref 7595); Thu, 16 Dec 2010 21:19:02 +0000 Original-Received: (at 7595) by debbugs.gnu.org; 16 Dec 2010 21:18:31 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PTLDa-0004M8-R7 for submit@debbugs.gnu.org; Thu, 16 Dec 2010 16:18:31 -0500 Original-Received: from colin.muc.de ([193.149.48.1] helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PTLDY-0004Lv-QG for 7595@debbugs.gnu.org; Thu, 16 Dec 2010 16:18:29 -0500 Original-Received: (qmail 77691 invoked by uid 3782); 16 Dec 2010 21:24:47 -0000 Original-Received: from acm.muc.de (pD9E52048.dip.t-dialin.net [217.229.32.72]) by colin2.muc.de (tmda-ofmipd) with ESMTP; Thu, 16 Dec 2010 22:24:45 +0100 Original-Received: (qmail 3539 invoked by uid 1000); 16 Dec 2010 21:39:16 -0000 Content-Disposition: inline In-Reply-To: <4D000FF1.10307@gmail.com> User-Agent: Mutt/1.5.9i X-Delivery-Agent: TMDA/1.1.5 (Fettercairn) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 16 Dec 2010 16:19:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:42569 Archived-At: Hi again, Daniel! On Wed, Dec 08, 2010 at 03:08:33PM -0800, Daniel Colascione wrote: > In a c-mode buf, > press pound, then back, then M-e > See eternal loop > Would you try out the following patch, please, which I hope fixes the problem. (The line numbers will be a little different, but don't worry about that.) Let me know how well it works! Thanks. *** orig/cc-cmds.el 2010-12-12 21:08:40.000000000 +0000 --- cc-cmds.el 2010-12-16 20:55:30.778431600 +0000 *************** *** 2422,2434 **** (goto-char last) (throw 'done '(nil . nil))) ! ;; Stop if we encounter a preprocessor line. ! ((and (not macro-end) (eq (char-after) ?#) (= (point) (c-point 'boi))) ! (goto-char last) ! ;(throw 'done (cons (eq (point) here) 'macro-boundary))) ; Changed 2003/3/26 ! (throw 'done '(t . macro-boundary))) ;; Stop after a ';', '}', or "};" ((looking-at ";\\|};?") --- 2422,2435 ---- (goto-char last) (throw 'done '(nil . nil))) ! ;; Stop if we encounter a preprocessor line. Continue if we hit a naked # ! ((and c-opt-cpp-prefix ! (not macro-end) (eq (char-after) ?#) (= (point) (c-point 'boi))) ! (if (= (point) here) ; Not a macro, therefore naked #. ! (forward-char) ! (throw 'done '(t . macro-boundary)))) ;; Stop after a ';', '}', or "};" ((looking-at ";\\|};?") *************** *** 2627,2640 **** ;; Are we about to move forward into or out of a ;; preprocessor command? (when (eq (cdr res) 'macro-boundary) ! (save-excursion ! (end-of-line) ! (setq macro-fence ! (and (not (eobp)) ! (progn (c-skip-ws-forward) ! (c-beginning-of-macro)) ! (progn (c-end-of-macro) ! (point)))))) ;; Are we about to move forward into a literal? (when (memq (cdr res) '(macro-boundary literal)) (setq range (c-ascertain-following-literal))) --- 2628,2646 ---- ;; Are we about to move forward into or out of a ;; preprocessor command? (when (eq (cdr res) 'macro-boundary) ! (setq macro-fence ! (save-excursion ! (if macro-fence ! (progn ! (end-of-line) ! (and (not (eobp)) ! (progn (c-skip-ws-forward) ! (c-beginning-of-macro)) ! (progn (c-end-of-macro) ! (point)))) ! (and (not (eobp)) ! (c-beginning-of-macro) ! (progn (c-end-of-macro) (point))))))) ;; Are we about to move forward into a literal? (when (memq (cdr res) '(macro-boundary literal)) (setq range (c-ascertain-following-literal))) All the best! -- Alan Mackenzie (Nuremberg, Germany).