From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daniel Colascione Newsgroups: gmane.emacs.bugs Subject: bug#7595: Infinite loop in cc-mode, or the coming of autumn Date: Sun, 06 Mar 2011 15:35:28 -0800 Message-ID: <4D741A40.7090204@gmail.com> References: <4D000FF1.10307@gmail.com> <20101216213915.GA3442__49696.8405823738$1292537376$gmane$org@muc.de> <4D45F34F.8030601@gmail.com> <87tygo3c4q.fsf__35531.9466595121$1296517007$gmane$org@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: dough.gmane.org 1299454637 8611 80.91.229.12 (6 Mar 2011 23:37:17 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 6 Mar 2011 23:37:17 +0000 (UTC) Cc: 7595@debbugs.gnu.org, acm@muc.de To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Mar 07 00:37:12 2011 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 1PwNVf-00021B-C4 for geb-bug-gnu-emacs@m.gmane.org; Mon, 07 Mar 2011 00:37:11 +0100 Original-Received: from localhost ([127.0.0.1]:41295 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwNVe-0007OU-KN for geb-bug-gnu-emacs@m.gmane.org; Sun, 06 Mar 2011 18:37:10 -0500 Original-Received: from [140.186.70.92] (port=45802 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PwNVP-0007M1-91 for bug-gnu-emacs@gnu.org; Sun, 06 Mar 2011 18:36:57 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PwNVN-0007Zi-Gh for bug-gnu-emacs@gnu.org; Sun, 06 Mar 2011 18:36:54 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:49195) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PwNVL-0007ZQ-Qt; Sun, 06 Mar 2011 18:36:51 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PwNUY-0007G7-DG; Sun, 06 Mar 2011 18:36:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Daniel Colascione 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: Sun, 06 Mar 2011 23:36: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.129945454127860 (code B ref 7595); Sun, 06 Mar 2011 23:36:02 +0000 Original-Received: (at 7595) by debbugs.gnu.org; 6 Mar 2011 23:35:41 +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 1PwNUC-0007FI-K0 for submit@debbugs.gnu.org; Sun, 06 Mar 2011 18:35:41 -0500 Original-Received: from mail-pw0-f44.google.com ([209.85.160.44]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PwNUA-0007F2-0h for 7595@debbugs.gnu.org; Sun, 06 Mar 2011 18:35:38 -0500 Original-Received: by pwi5 with SMTP id 5so729463pwi.3 for <7595@debbugs.gnu.org>; Sun, 06 Mar 2011 15:35:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version :newsgroups:to:cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=mHqmFGzfZ37F3toh5jjU4d63NU0tAZNhS8TpnFIz2Uo=; b=BmoZ+fr6bFSQR7p1n9RH2TWD/dTA16HqLAterwpgPnE7QEmM+3eXpj0/D1B3JdVaWU HJPG44BZdqXuUBz0J0WWdCnMJfYbVrTBTY13JPlCrAErlFjEPFQztTRHJaqKAumgGRR6 rFNq2wRkVH+3L8BHzuxB/vyUnC9Bx0WOWZHkU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:newsgroups:to:cc :subject:references:in-reply-to:content-type :content-transfer-encoding; b=P4H6Zh7i/i6AastDaPrMfjObvUwYyLZC/GkyI7jUHh01dXpSnHzewsA+MKTEH+4VGq BUpBMeUikz7xFSVIQZIMI0qUk9nWIwS4323caGaAoutQqyEskEdwbnzZbWxIezqPUveG gyMC79h4I1dtWywqLhCxCwdhhjx+E5H/0gPac= Original-Received: by 10.142.253.20 with SMTP id a20mr2796002wfi.190.1299454531968; Sun, 06 Mar 2011 15:35:31 -0800 (PST) Original-Received: from [0.0.0.0] (c-67-183-23-114.hsd1.wa.comcast.net [67.183.23.114]) by mx.google.com with ESMTPS id n4sm3477961wfl.14.2011.03.06.15.35.29 (version=SSLv3 cipher=OTHER); Sun, 06 Mar 2011 15:35:30 -0800 (PST) User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9 Original-Newsgroups: gmane.emacs.bugs In-Reply-To: <87tygo3c4q.fsf__35531.9466595121$1296517007$gmane$org@stupidchicken.com> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Sun, 06 Mar 2011 18:36:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 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:44718 Archived-At: On 1/31/2011 3:08 PM, Chong Yidong wrote: > Daniel Colascione writes: > >> Hi Alan, >> >> On 12/16/10 1:39 PM, Alan Mackenzie wrote: >>> 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. >> >> The patch seems to work well so far. I've replaced my workaround with >> it, and I'll let you know whether I see any problems. > > I've committed Alan's patch to the branch, so that it will be in the > forthcoming pretest. The following patch repairs a defect in the original that results in an infinite loop in c-beginning-of-statement under the following circumstance: 1 #define some_macro value 2 3 [P] 4 Where [P] denotes the point. === modified file 'lisp/progmodes/cc-cmds.el' --- lisp/progmodes/cc-cmds.el 2011-03-04 03:53:00 +0000 +++ lisp/progmodes/cc-cmds.el 2011-03-06 06:20:02 +0000 @@ -2518,6 +2518,8 @@ (c-save-buffer-state ((count (or count 1)) last ; start point for going back ONE chunk. Updated each chunk movement. + + ;; Beginning of current or previous macro (macro-fence (save-excursion (and (not (bobp)) (c-beginning-of-macro) (point)))) res ; result from sub-function call @@ -2580,19 +2582,15 @@ ;; Are we about to move backwards into or out of a ;; preprocessor command? If so, locate its beginning. (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))))))) + ;; c-back-over-illiterals stopped at the + ;; first non-whitespace character after + ;; the macro end, so the previous nonblank + ;; line should be the macro. + (setq macro-fence + (save-excursion + (c-backward-comments) + (point)))) + ;; Are we about to move backwards into a literal? (when (memq (cdr res) '(macro-boundary literal)) (setq range (c-ascertain-preceding-literal)))