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#13046: 23.4; Minimal Example to freeze emacs C++ mode (nasty interaction between templates & windows endline characters ) Date: Sun, 2 Dec 2012 18:16:23 +0000 Message-ID: <20121202181623.GB12129@acm.acm> References: <87txs5fbfo.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1354472638 2291 80.91.229.3 (2 Dec 2012 18:23:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 2 Dec 2012 18:23:58 +0000 (UTC) Cc: Vadim K , 13046@debbugs.gnu.org, John Smith To: Chong Yidong Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sun Dec 02 19:24:09 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TfECx-0001PI-Cf for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Dec 2012 19:24:03 +0100 Original-Received: from localhost ([::1]:46120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfECl-0002Cb-Oy for geb-bug-gnu-emacs@m.gmane.org; Sun, 02 Dec 2012 13:23:51 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfECi-00028h-OR for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2012 13:23:50 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfECh-0000ws-KL for bug-gnu-emacs@gnu.org; Sun, 02 Dec 2012 13:23:48 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40124) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfECf-0000vc-Mt; Sun, 02 Dec 2012 13:23:45 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TfEEt-00060W-Cz; Sun, 02 Dec 2012 13:26:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Sun, 02 Dec 2012 18:26:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 13046 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 13046-submit@debbugs.gnu.org id=B13046.135447270622982 (code B ref 13046); Sun, 02 Dec 2012 18:26:03 +0000 Original-Received: (at 13046) by debbugs.gnu.org; 2 Dec 2012 18:25:06 +0000 Original-Received: from localhost ([127.0.0.1]:50367 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TfEDy-0005yd-6J for submit@debbugs.gnu.org; Sun, 02 Dec 2012 13:25:06 -0500 Original-Received: from colin.muc.de ([193.149.48.1]:22684 helo=mail.muc.de) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TfEDv-0005yQ-Do for 13046@debbugs.gnu.org; Sun, 02 Dec 2012 13:25:04 -0500 Original-Received: (qmail 19887 invoked by uid 3782); 2 Dec 2012 18:22:44 -0000 Original-Received: from acm.muc.de (pD951B8A7.dip.t-dialin.net [217.81.184.167]) by colin.muc.de (tmda-ofmipd) with ESMTP; Sun, 02 Dec 2012 19:22:43 +0100 Original-Received: (qmail 14593 invoked by uid 1000); 2 Dec 2012 18:16:23 -0000 Content-Disposition: inline In-Reply-To: <87txs5fbfo.fsf@gnu.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Delivery-Agent: TMDA/1.1.12 (Macallan) X-Primary-Address: acm@muc.de X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x 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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:67792 Archived-At: Hello Yidong, Vadim, John. On Sun, Dec 02, 2012 at 10:13:47AM +0800, Chong Yidong wrote: > John Smith writes: > > Using emacs -Q,just open the attached minimal example and try typing > > "std::string" in the body of the function. > > That should hang emacs forever (or at least it does on my up-to-date > > ubuntu). > I think this is a duplicate of Bug#11841. > The patch posted in Bug#11841 does not completely fix this test case. > Giving ^M whitespace syntax in CC mode, as Stefan suggested, seems like > the easiest solution. Alan, could you take another look? It would be > good to have this fixed in Emacs 24.3. On Wed, Jul 25, 2012 at 11:58:22PM +0300, Vadim K wrote: > Hello Alan, > I've tried your patch and it worked fine for the original posted > bad.cpp file. However I have found a variation of that file that still > causes emacs to hang (see attached bad2.cpp). [ Bug #11841 ] I think the enclosed patch fixes these bugs. Please try out the patch and let us know if there are still any problems here. The basic problem is that (forward-comment -1) doesn't recognise a CR character as whitespace. My first attempt to patch this, in July, was only partly successful. The specific problem was that (forward-comment -1) _sometimes_ goes back over the LF in CRLF, sometimes not. I've not discovered by what criterion. diff -r 1adcc48506f9 cc-engine.el --- a/cc-engine.el Sun Apr 22 09:42:29 2012 +0000 +++ b/cc-engine.el Sun Dec 02 17:46:53 2012 +0000 @@ -1454,8 +1454,21 @@ ;; return t when moving backwards at bob. (not (bobp)) - (if (let (open-paren-in-column-0-is-defun-start) - (forward-comment -1)) + (if (let (open-paren-in-column-0-is-defun-start moved-comment) + (while + (and (not (setq moved-comment (forward-comment -1))) + ;; Cope specifically with ^M^J here - + ;; forward-comment sometimes gets stuck after ^Ms, + ;; sometimes after ^M^J. + (or + (when (eq (char-before) ?\r) + (backward-char) + t) + (when (and (eq (char-before) ?\n) + (eq (char-before (1- (point))) ?\r)) + (backward-char 2) + t)))) + moved-comment) (if (looking-at "\\*/") ;; Emacs <= 20 and XEmacs move back over the ;; closer of a block comment that lacks an opener. -- Alan Mackenzie (Nuremberg, Germany).