From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Konstantin Kharlamov Newsgroups: gmane.emacs.bugs Subject: bug#33163: Adding a " in c++-mode fills the whole file with red Date: Mon, 29 Oct 2018 21:46:50 +0300 Message-ID: <69a4fe02-5538-036e-5f47-3327dfccc80b@yandex.ru> References: <20181028104906.70695.qmail@mail.muc.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1540838768 12022 195.159.176.226 (29 Oct 2018 18:46:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 29 Oct 2018 18:46:08 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 Cc: 33163@debbugs.gnu.org To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 29 19:46:04 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHCY8-00032a-B1 for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Oct 2018 19:46:04 +0100 Original-Received: from localhost ([::1]:48269 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHCaE-0004YN-Nq for geb-bug-gnu-emacs@m.gmane.org; Mon, 29 Oct 2018 14:48:14 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58675) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gHCa7-0004Y8-3D for bug-gnu-emacs@gnu.org; Mon, 29 Oct 2018 14:48:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gHCa6-0003np-21 for bug-gnu-emacs@gnu.org; Mon, 29 Oct 2018 14:48:07 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:47958) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gHCa2-0003kj-Bc; Mon, 29 Oct 2018 14:48:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gHCa2-0007TT-8z; Mon, 29 Oct 2018 14:48:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Konstantin Kharlamov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, bug-cc-mode@gnu.org Resent-Date: Mon, 29 Oct 2018 18:48:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33163 X-GNU-PR-Package: emacs,cc-mode X-GNU-PR-Keywords: Original-Received: via spool by 33163-submit@debbugs.gnu.org id=B33163.154083882728669 (code B ref 33163); Mon, 29 Oct 2018 18:48:02 +0000 Original-Received: (at 33163) by debbugs.gnu.org; 29 Oct 2018 18:47:07 +0000 Original-Received: from localhost ([127.0.0.1]:52216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHCZ8-0007SK-LQ for submit@debbugs.gnu.org; Mon, 29 Oct 2018 14:47:07 -0400 Original-Received: from forward104j.mail.yandex.net ([5.45.198.247]:50989) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHCZ5-0007Rn-TV for 33163@debbugs.gnu.org; Mon, 29 Oct 2018 14:47:05 -0400 Original-Received: from mxback10j.mail.yandex.net (mxback10j.mail.yandex.net [IPv6:2a02:6b8:0:1619::113]) by forward104j.mail.yandex.net (Yandex) with ESMTP id 6046D58057F; Mon, 29 Oct 2018 21:46:57 +0300 (MSK) Original-Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback10j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 5C0iSM4S7B-kvdGIgbB; Mon, 29 Oct 2018 21:46:57 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1540838817; bh=mTIfVmBD/TSv5GFdyw7iYfPWgbD8VQljCGv2+KeOx/o=; h=Subject:From:To:Cc:References:Message-ID:Date:In-Reply-To; b=vR4ABc2+ISDuEmNf0hvavzcDo7Y5wyyYQtsmpovtR1r46gADo5tapAzWCNB+lpMTb LrSo51uQNpxLEds6PTnHWibixSucZ87ntb/fuTMmKGk71SyfJuo3zqBnRUGAZgqhkI A0PBuJeV7gOOHzngaCf/nwroOmFGSwkQOKoRTS5Y= Original-Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 06EN3Bm2RL-kuoOmtQp; Mon, 29 Oct 2018 21:46:56 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client certificate not present) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1540838816; bh=mTIfVmBD/TSv5GFdyw7iYfPWgbD8VQljCGv2+KeOx/o=; h=Subject:From:To:Cc:References:Message-ID:Date:In-Reply-To; b=JhMjJbf53Ix1QEVqPkz3iK6XEVAwOa8A5/bFE/G0421VB//J3863lIOz6d3DKYcb+ G+rambY3EdzcqCaci/igKGBnqJX0V2y7r1M0HI6hqI36U85n9Mm/CfezQ86oMPoD9G UUKeD/EBl6KKK/+GCzK7aSqfr3x67lqEAMM4kXKA= Authentication-Results: smtp1p.mail.yandex.net; dkim=pass header.i=@yandex.ru In-Reply-To: Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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" Xref: news.gmane.org gmane.emacs.bugs:151783 Archived-At: Thank you, so, I've used the patch today for working with a code, and everything seemed to be well :) Tested-by: Konstantin Kharlamov On 10/28/18 2:21 PM, Konstantin Kharlamov wrote: > On 10/28/18 1:49 PM, Alan Mackenzie wrote: >> In article you >> wrote: >>> This long-standing problem appears occasionally, and only disappears if >>> you kill the buffer completely, then reopen the file. I never got to >>> report it because I never could find steps to reproduce it… until now >>> :) Nvm the non-sense code, I reduced testcase as far as I managed. >> >>> # Steps to reproduce: >> >>> 1. Save the following text in `test.cpp` >>>      int main() { >>>              puts(It's"); >>>          auto foo = []()-> void {  }; >>>              puts("It's"); >>>      } >>> 2. Open `emacs -Q ./test.cpp` >>> 3. Now, the text lacks a quote in the first `puts(It's");`. Add it so >>> it looks like `puts("It's");`. Essentially, if you'd compile it with >>> g++, it lacks any syntax error besides `puts` being undeclared. >> >>> # Expected >> >>> The line with `auto foo…` is not red. >> >>> # Actual >> >>> The line with `auto foo…` (in particular) becomes red. >> >> Thanks for taking the trouble to report this bug.  Thanks even more for >> condensing it down to a minimal test case. >> >> The following patch should fix it.  Would you please apply the patch, >> recompile .../lisp/progmodes/cc-mode.el, load the new file in to your >> Emacs (or restart Emacs), then try it out on your real C++ code.  Then >> please let me know whether it's working or not, and if not, how it's >> going wrong.  Thanks! > > Thank you for the quick patch! I tried to do some editing and > navigating, and all seems well. More real testing I can only do on > Monday, so I guess I'll reply somewhere on Monday evening. > >> >>> # Additional information >> >>> Emacs version GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ >>> Version 3.22.30) of 2018-10-01, build with -flto. >> >> >> >> diff -r 2f7029fa229d cc-mode.el >> --- a/cc-mode.el    Sun Oct 14 20:01:07 2018 +0000 >> +++ b/cc-mode.el    Sun Oct 28 10:20:38 2018 +0000 >> @@ -1216,21 +1216,21 @@ >>         (if (eq beg-literal-type 'string) >>         (setq c-new-BEG (min (car beg-limits) c-new-BEG)))) >> -     ((< c-new-END (point-max)) >> -      (goto-char (1+ c-new-END))    ; might be a newline. >> +     ((< end (point-max)) >> +      (goto-char (1+ end))    ; might be a newline. >>         ;; In the following regexp, the initial \n caters for a >> newline getting >>         ;; joined to a preceding \ by the removal of what comes between. >>         (re-search-forward >> "[\n\r]?\\(\\\\\\(.\\|\n\\|\r\\)\\|[^\\\n\r]\\)*" >>                nil t) >>         ;; We're at an EOLL or point-max. >> -      (setq c-new-END (min (1+ (point)) (point-max))) >> -      (goto-char c-new-END) >> -      (if (equal (c-get-char-property (1- (point)) 'syntax-table) '(15)) >> -      (if (memq (char-before) '(?\n ?\r)) >> +      (setq c-new-END (max c-new-END (min (1+ (point)) (point-max)))) >> +      (if (equal (c-get-char-property (point) 'syntax-table) '(15)) >> +      (if (memq (char-after) '(?\n ?\r)) >>             ;; Normally terminated invalid string. >> -          (progn >> +          (let ((eoll-1 (point))) >> +        (forward-char) >>           (backward-sexp) >> -        (c-clear-char-property (1- c-new-END) 'syntax-table) >> +        (c-clear-char-property eoll-1 'syntax-table) >>           (c-clear-char-property (point) 'syntax-table)) >>           ;; Opening " at EOB. >>           (c-clear-char-property (1- (point)) 'syntax-table)) >> @@ -1238,7 +1238,7 @@ >>           ;; Opening " on last line of text (without EOL). >>           (c-clear-char-property (point) 'syntax-table)))) >> -     (t (goto-char c-new-END) >> +     (t (goto-char end)            ; point-max >>       (if (c-search-backward-char-property 'syntax-table '(15) c-new-BEG) >>           (c-clear-char-property (point) 'syntax-table)))) >> @@ -1327,9 +1327,9 @@ >>            (while (progn >>                 (setq s (parse-partial-sexp (point) c-new-END nil >>                             nil s 'syntax-table)) >> -              (and (not (nth 3 s)) >> -               (< (point) c-new-END) >> -               (not (memq (char-before) c-string-delims))))) >> +                      (and (< (point) c-new-END) >> +                           (or (not (nth 3 s)) >> +                               (not (memq (char-before) >> c-string-delims)))))) >>            ;; We're at the start of a string. >>            (memq (char-before) c-string-delims))) >>       (if (c-unescaped-nls-in-string-p (1- (point))) >> >>