From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: John Smith Newsgroups: gmane.emacs.bugs Subject: bug#13046: 23.4; Minimal Example to freeze emacs C++ mode (nasty interaction between templates & windows endline characters ) Date: Mon, 3 Dec 2012 09:54:51 +0100 Message-ID: References: <87txs5fbfo.fsf@gnu.org> <20121202181623.GB12129@acm.acm> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b6049ba07da7d04cfeee7e0 X-Trace: ger.gmane.org 1354524967 16692 80.91.229.3 (3 Dec 2012 08:56:07 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 3 Dec 2012 08:56:07 +0000 (UTC) Cc: Chong Yidong , 13046@debbugs.gnu.org, Vadim K To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Dec 03 09:56:18 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 1TfRp2-00088c-IH for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Dec 2012 09:56:16 +0100 Original-Received: from localhost ([::1]:58679 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfRoq-0002Ar-VR for geb-bug-gnu-emacs@m.gmane.org; Mon, 03 Dec 2012 03:56:04 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33090) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfRoi-00029o-Vp for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2012 03:56:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfRoc-0005Nd-SV for bug-gnu-emacs@gnu.org; Mon, 03 Dec 2012 03:55:56 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:40549) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfRoV-0005Ly-TT; Mon, 03 Dec 2012 03:55:44 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TfRqm-0006uN-L4; Mon, 03 Dec 2012 03:58:04 -0500 X-Loop: help-debbugs@gnu.org Resent-From: John Smith Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 03 Dec 2012 08:58:04 +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.135452503726419 (code B ref 13046); Mon, 03 Dec 2012 08:58:04 +0000 Original-Received: (at 13046) by debbugs.gnu.org; 3 Dec 2012 08:57:17 +0000 Original-Received: from localhost ([127.0.0.1]:50800 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TfRq0-0006s3-Uw for submit@debbugs.gnu.org; Mon, 03 Dec 2012 03:57:17 -0500 Original-Received: from mail-ea0-f172.google.com ([209.85.215.172]:34607) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TfRpy-0006rs-4d for 13046@debbugs.gnu.org; Mon, 03 Dec 2012 03:57:15 -0500 Original-Received: by mail-ea0-f172.google.com with SMTP id a1so1170285eaa.3 for <13046@debbugs.gnu.org>; Mon, 03 Dec 2012 00:54:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:x-google-sender-delegation:in-reply-to :references:date:x-google-sender-auth:message-id:subject:from:to:cc :content-type; bh=zKn9pDBfZ/vkEfuYwr5wPLiSntJv4CbjzhN/KJCbfPg=; b=QRqwl5jw6JN7NV5bWTGNntWtYm/p6DHW/wqR7JILqZT3Z1N/ZNFpI5olmIugkMaOR4 2YBIqigcSc1WKZX0FYWSUPM3/kDhQJTmiWQIyxRBdBudMTuDqRCgvTiK6zCOKtqXVEbu GQam1yD9k6mn6EvabHOV+dYzgUgeZqb5AHGYKExFufuoTH3RxmIArao5d1ooS8Tqv4Gr 6YvjZpMK5rYcVMQTSv6uhDgqeewDfEnLkUBeCgTkku5mqIrENH3AEjFZiX9XN6me3Q2Q hBaQbUwjFaXRZUpoQUAL4fUen0AoUm1kH+u/iaxWNKp8wIVZUehKIZpKgSpb6XUEzZDS 500w== Original-Received: by 10.14.221.9 with SMTP id q9mr34347517eep.3.1354524892060; Mon, 03 Dec 2012 00:54:52 -0800 (PST) X-Google-Sender-Delegation: fdemesmay@gmail.com Original-Received: by 10.223.173.1 with HTTP; Mon, 3 Dec 2012 00:54:51 -0800 (PST) In-Reply-To: <20121202181623.GB12129@acm.acm> X-Google-Sender-Auth: 2JMdtKQzR3QMdQVj4v69uozbMFE 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:67826 Archived-At: --047d7b6049ba07da7d04cfeee7e0 Content-Type: text/plain; charset=ISO-8859-1 Hello all, I'm afraid my limited emacs knowledge will not allow me to test the patch. (Building fresh from source + patching the lisp => too much :) ) I trust however that it does! Thanks for being so responsive. Yours Sincerely, John On Sun, Dec 2, 2012 at 7:16 PM, Alan Mackenzie wrote: > 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). > --047d7b6049ba07da7d04cfeee7e0 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hello all,

I'm afraid my limited emacs knowledge will not allow = me to test the patch. (Building fresh from source + patching the lisp =3D&g= t; too much :) )
I trust however that it does!

Thanks for being s= o responsive.

Yours Sincerely,
John

On Sun, Dec = 2, 2012 at 7:16 PM, Alan Mackenzie <acm@muc.de> wrote:
Hello Yidong, Vadim, John.

On Sun, Dec 02, 2012 at 10:13:47AM +0800, Chong Yidong wrote:
> John Smith <drefleladi@gmail.com> writes:

> > Using emacs -Q,just open the attached minimal example and try typ= ing
> > "std::string" in the body of the function.
> > That should hang emacs forever (or at least it does on my up-to-d= ate
> > ubuntu).

> I think this is a duplicate of Bug#11841.

> The patch posted in Bug#11841 does not completely fix this test case.<= br> > Giving ^M whitespace syntax in CC mode, as Stefan suggested, seems lik= e
> the easiest solution. =A0Alan, could you take another look? =A0It woul= d 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. =A0Please 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. =A0My 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. =A0I've not discovered by what
criterion.



diff -r 1adcc48506f9 cc-engine.el
--- a/cc-engine.el =A0 =A0 =A0Sun Apr 22 09:42:29 2012 +0000
+++ b/cc-engine.el =A0 =A0 =A0Sun Dec 02 17:46:53 2012 +0000
@@ -1454,8 +1454,21 @@
=A0 =A0 =A0 =A0 =A0 =A0 ;; return t when moving backwards at bob.
=A0 =A0 =A0 =A0 =A0 =A0 (not (bobp))

- =A0 =A0 =A0 =A0 =A0 (if (let (open-paren-in-column-0-is-defun-start)
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (forward-comment -1))
+ =A0 =A0 =A0 =A0 =A0 (if (let (open-paren-in-column-0-is-defun-start moved= -comment)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (while
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (and (not (setq moved-comment (fo= rward-comment -1)))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; Cope specifically with ^M^J he= re -
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; forward-comment sometimes gets= stuck after ^Ms,
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; sometimes after ^M^J.
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(or
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (when (eq (char-befor= e) ?\r)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (backward-char) + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (when (and (eq (char-= before) ?\n)
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0(eq (char-before (1- (point))) ?\r))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (backward-char 2)=
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 t))))
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 moved-comment)
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 (if (looking-at "\\*/")
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; Emacs <=3D 20 and XEmacs move= back over the
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ;; closer of a block comment that l= acks an opener.



--
Alan Mackenzie (Nuremberg, Germany).

--047d7b6049ba07da7d04cfeee7e0--