From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 26 10:05:47 2018 Received: (at submit) by debbugs.gnu.org; 26 Oct 2018 14:05:47 +0000 Received: from localhost ([127.0.0.1]:44212 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gG2kF-0003FL-4g for submit@debbugs.gnu.org; Fri, 26 Oct 2018 10:05:47 -0400 Received: from eggs.gnu.org ([208.118.235.92]:36739) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gG2kD-0003F8-Kr for submit@debbugs.gnu.org; Fri, 26 Oct 2018 10:05:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gG2k2-0004NU-8p for submit@debbugs.gnu.org; Fri, 26 Oct 2018 10:05:40 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:59181) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gG2k2-0004NI-4o for submit@debbugs.gnu.org; Fri, 26 Oct 2018 10:05:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gG2k1-0002Hw-7s for bug-gnu-emacs@gnu.org; Fri, 26 Oct 2018 10:05:33 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gG2k0-0004M9-HI for bug-gnu-emacs@gnu.org; Fri, 26 Oct 2018 10:05:33 -0400 Received: from forward103o.mail.yandex.net ([2a02:6b8:0:1a2d::606]:39870) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gG2jy-0004Gy-8S for bug-gnu-emacs@gnu.org; Fri, 26 Oct 2018 10:05:32 -0400 Received: from mxback5o.mail.yandex.net (mxback5o.mail.yandex.net [IPv6:2a02:6b8:0:1a2d::1f]) by forward103o.mail.yandex.net (Yandex) with ESMTP id 4F18A5883DCB for ; Fri, 26 Oct 2018 17:05:17 +0300 (MSK) Received: from smtp4j.mail.yandex.net (smtp4j.mail.yandex.net [2a02:6b8:0:1619::15:6]) by mxback5o.mail.yandex.net (nwsmtp/Yandex) with ESMTP id t0JI7jTsrZ-5H5COukm; Fri, 26 Oct 2018 17:05:17 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1540562717; bh=NUQvRWrT6c6mOJyWxUwKekG5xMM35XMnZjU7vEWsjOE=; h=To:From:Subject:Message-ID:Date; b=egzFmQYVSyP+m+JmxKnT38AvHYp0twNquARz02GDfnpUo3gY0qKVRoI3eXobZXlLG 4OrWDkBpq263kyW0ZrZSBbhvou4tRUIzd5JwXE43N9zxyeTTT1S1NyaF2e0Lxd/Fhr cQ2fClJLEkj54Xj6Ev0irrPWMAx9noNzPrz2jf0Q= Received: by smtp4j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id kNIXaBQQyK-5GZeO5p7; Fri, 26 Oct 2018 17:05:16 +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=1540562716; bh=NUQvRWrT6c6mOJyWxUwKekG5xMM35XMnZjU7vEWsjOE=; h=To:From:Subject:Message-ID:Date; b=fVcGKMhPOGNPrbSRyK7VPEi6gltq8aa2mARkTSKfvtt5X+jr1wZvg1ehihyScD8M3 NEOfIQBsZfkvM8OELz0OZm/NpfLCBVOPb75qQfzP/bHVVGDwvSXBR8Bvv1Pw8bMvuN zty+E6Iby97G7k+wu4LlunwY9UPOyjWZyoRqbh1Q= Authentication-Results: smtp4j.mail.yandex.net; dkim=pass header.i=@yandex.ru To: bug-gnu-emacs@gnu.org From: Konstantin Kharlamov Subject: Adding a " in c++-mode fills the whole file with red Message-ID: <4ffd5027-1201-6a7b-6e82-645a99465404@yandex.ru> Date: Fri, 26 Oct 2018 17:05:04 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB-large Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.0 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -5.0 (-----) This long-standing problem appears occasionally, and only disappears if y= ou kill the buffer completely, then reopen the file. I never got to repor= t it because I never could find steps to reproduce it=E2=80=A6 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 =3D []()-> 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=E2=80=A6` is not red. # Actual The line with `auto foo=E2=80=A6` (in particular) becomes red. # Additional information Emacs version GNU Emacs 27.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Versi= on 3.22.30) of 2018-10-01, build with -flto. From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 28 06:49:09 2018 Received: (at 33163) by debbugs.gnu.org; 28 Oct 2018 10:49:09 +0000 Received: from localhost ([127.0.0.1]:46734 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGid2-0002b4-Uz for submit@debbugs.gnu.org; Sun, 28 Oct 2018 06:49:09 -0400 Received: from colin.muc.de ([193.149.48.1]:37232 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1gGid1-0002aw-I8 for 33163@debbugs.gnu.org; Sun, 28 Oct 2018 06:49:08 -0400 Received: (qmail 70696 invoked by uid 3782); 28 Oct 2018 10:49:06 -0000 Date: 28 Oct 2018 10:49:06 -0000 Message-ID: <20181028104906.70695.qmail@mail.muc.de> From: Alan Mackenzie To: Konstantin Kharlamov Subject: Re: bug#33163: Adding a " in c++-mode fills the whole file with red Organization: muc.de e.V. In-Reply-To: X-Newsgroups: gnu.emacs.bug User-Agent: tin/2.4.2-20171224 ("Lochhead") (UNIX) (FreeBSD/11.2-RELEASE-p4 (amd64)) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33163 Cc: acm@muc.de, 33163@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) 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=E2=80=A6 unt= il 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 =3D []()-> 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=E2=80=A6` is not red. > # Actual > The line with `auto foo=E2=80=A6` (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! > # 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)))) =20 - ((< 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 ge= tting ;; 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)))) =20 - (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)))) =20 @@ -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))) --=20 Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 28 07:21:29 2018 Received: (at 33163) by debbugs.gnu.org; 28 Oct 2018 11:21:29 +0000 Received: from localhost ([127.0.0.1]:46748 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGj8K-0003Rp-Jb for submit@debbugs.gnu.org; Sun, 28 Oct 2018 07:21:28 -0400 Received: from forward101j.mail.yandex.net ([5.45.198.241]:59788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gGj8H-0003Rb-PX for 33163@debbugs.gnu.org; Sun, 28 Oct 2018 07:21:26 -0400 Received: from mxback16j.mail.yandex.net (mxback16j.mail.yandex.net [IPv6:2a02:6b8:0:1619::92]) by forward101j.mail.yandex.net (Yandex) with ESMTP id 4F5B22E81125; Sun, 28 Oct 2018 14:21:19 +0300 (MSK) Received: from smtp3p.mail.yandex.net (smtp3p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:8]) by mxback16j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id QrNm2yw6qL-LJNCNHYi; Sun, 28 Oct 2018 14:21:19 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1540725679; bh=3T6du5D3H2Ka/MXwzB4cky8HMDYmXCnUaKIhTdPD9GY=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=WCC3UvGa6miaYHmZ/bzFCIFBBidezVvCGxUBqzNs3hnV8RE3d7s2dTlQMduoEJxSx DOmGnwpNx8FvsHnqxh6lAMTRzOIjPRGV04qAR/D60I4zPezHz2CdSMDRMhzlV/wz/c GpnGRqUbRHHPNc7T/dhKhj13XUzp3CBZeLV8GV38= Received: by smtp3p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id zGTj2jfAzR-LIiWJrSA; Sun, 28 Oct 2018 14:21:18 +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=1540725678; bh=3T6du5D3H2Ka/MXwzB4cky8HMDYmXCnUaKIhTdPD9GY=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=NQlChaToB+CFtauhvcEPQgQd8Uq3Dzicd6sVgXOp4qTUgLQ1+SB0MFmLKzATcNEXP aaepX0F2/nDJ6rCHCR1A8rqg3p7iMaoiNsLNFdtNnGGCHeeYz0pqPgp+VO77WIR3Ac xEw+4AOV4cBPesIb/MDYrwgLUOiqp54iBMDdbLpA= Authentication-Results: smtp3p.mail.yandex.net; dkim=pass header.i=@yandex.ru Subject: Re: bug#33163: Adding a " in c++-mode fills the whole file with red To: Alan Mackenzie References: <20181028104906.70695.qmail@mail.muc.de> From: Konstantin Kharlamov Message-ID: Date: Sun, 28 Oct 2018 14:21:11 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: <20181028104906.70695.qmail@mail.muc.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 33163 Cc: 33163@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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))) > > From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 29 14:47:07 2018 Received: (at 33163) by debbugs.gnu.org; 29 Oct 2018 18:47:07 +0000 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 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 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) 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= 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 Subject: Re: bug#33163: Adding a " in c++-mode fills the whole file with red From: Konstantin Kharlamov To: Alan Mackenzie References: <20181028104906.70695.qmail@mail.muc.de> Message-ID: <69a4fe02-5538-036e-5f47-3327dfccc80b@yandex.ru> Date: Mon, 29 Oct 2018 21:46:50 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 33163 Cc: 33163@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) 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))) >> >> From debbugs-submit-bounces@debbugs.gnu.org Tue Oct 30 08:01:31 2018 Received: (at 33163-done) by debbugs.gnu.org; 30 Oct 2018 12:01:31 +0000 Received: from localhost ([127.0.0.1]:53461 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gHSiB-0000xf-96 for submit@debbugs.gnu.org; Tue, 30 Oct 2018 08:01:31 -0400 Received: from colin.muc.de ([193.149.48.1]:20959 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1gHSi8-0000xT-VW for 33163-done@debbugs.gnu.org; Tue, 30 Oct 2018 08:01:29 -0400 Received: (qmail 4365 invoked by uid 3782); 30 Oct 2018 12:01:27 -0000 Received: from acm.muc.de (p5B1479F4.dip0.t-ipconnect.de [91.20.121.244]) by colin.muc.de (tmda-ofmipd) with ESMTP; Tue, 30 Oct 2018 13:01:26 +0100 Received: (qmail 16203 invoked by uid 1000); 30 Oct 2018 12:01:32 -0000 Date: Tue, 30 Oct 2018 12:01:32 +0000 To: Konstantin Kharlamov Subject: Re: bug#33163: Adding a " in c++-mode fills the whole file with red Message-ID: <20181030120132.GA16181@ACM> References: <20181028104906.70695.qmail@mail.muc.de> <69a4fe02-5538-036e-5f47-3327dfccc80b@yandex.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <69a4fe02-5538-036e-5f47-3327dfccc80b@yandex.ru> User-Agent: Mutt/1.10.1 (2018-07-13) X-Delivery-Agent: TMDA/1.1.12 (Macallan) From: Alan Mackenzie X-Primary-Address: acm@muc.de X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 33163-done Cc: 33163-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Hello, Konstantin On Mon, Oct 29, 2018 at 21:46:50 +0300, Konstantin Kharlamov wrote: > Thank you, so, I've used the patch today for working with a code, and > everything seemed to be well :) > Tested-by: Konstantin Kharlamov Thanks for the testing. I've committed the patch to all the usual places, and I'm closing the bug. -- Alan Mackenzie (Nuremberg, Germany). From debbugs-submit-bounces@debbugs.gnu.org Mon Nov 26 05:56:52 2018 Received: (at 33163-done) by debbugs.gnu.org; 26 Nov 2018 10:56:52 +0000 Received: from localhost ([127.0.0.1]:47867 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gREZQ-0003Xv-JO for submit@debbugs.gnu.org; Mon, 26 Nov 2018 05:56:52 -0500 Received: from forward101j.mail.yandex.net ([5.45.198.241]:38139) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gREZO-0003Xe-FL for 33163-done@debbugs.gnu.org; Mon, 26 Nov 2018 05:56:51 -0500 Received: from mxback10g.mail.yandex.net (mxback10g.mail.yandex.net [IPv6:2a02:6b8:0:1472:2741:0:8b7:171]) by forward101j.mail.yandex.net (Yandex) with ESMTP id D0F3B2E809F3; Mon, 26 Nov 2018 13:56:43 +0300 (MSK) Received: from smtp1p.mail.yandex.net (smtp1p.mail.yandex.net [2a02:6b8:0:1472:2741:0:8b6:6]) by mxback10g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id eOMC6gDlbU-uhcqUjuk; Mon, 26 Nov 2018 13:56:43 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1543229803; bh=MucSudwtvE31CV+80EAe2lYmQpBSjnnh97FLXumtWEA=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=MpmM+eLEJO2V5VYNLZvXsjdNeRxfSTi6hwMo8D0JukATCNDKS3Jvz/LRBRJmgoZay sxTjFw8OqpO3p793C0d6bPtIsUicnDTHACYhM9V8Lu9GmCHm6I7138GK2m1z6ZKCuy 7bsL4dakFoFVrvl6wD6R4HweYzNfYJPMwKH4QA9U= Received: by smtp1p.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id YcehpeeShl-uhMKgSDE; Mon, 26 Nov 2018 13:56:43 +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=1543229803; bh=MucSudwtvE31CV+80EAe2lYmQpBSjnnh97FLXumtWEA=; h=Subject:To:Cc:References:From:Message-ID:Date:In-Reply-To; b=MpmM+eLEJO2V5VYNLZvXsjdNeRxfSTi6hwMo8D0JukATCNDKS3Jvz/LRBRJmgoZay sxTjFw8OqpO3p793C0d6bPtIsUicnDTHACYhM9V8Lu9GmCHm6I7138GK2m1z6ZKCuy 7bsL4dakFoFVrvl6wD6R4HweYzNfYJPMwKH4QA9U= Authentication-Results: smtp1p.mail.yandex.net; dkim=pass header.i=@yandex.ru Subject: Re: bug#33163: Adding a " in c++-mode fills the whole file with red To: Alan Mackenzie References: <20181028104906.70695.qmail@mail.muc.de> <69a4fe02-5538-036e-5f47-3327dfccc80b@yandex.ru> <20181030120132.GA16181@ACM> From: Konstantin Kharlamov Message-ID: Date: Mon, 26 Nov 2018 13:56:42 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181030120132.GA16181@ACM> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB-large Content-Transfer-Encoding: 7bit X-Spam-Score: -0.7 (/) X-Debbugs-Envelope-To: 33163-done Cc: 33163-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.7 (-) FTR: since then I've encountered a likewise problem a few times more, except now it only happens with lines `#include "file.h"`. I haven't manage yet to get a minimal reproducible example, but I thought it's worth mentioning here, just in case you might have an offhand insight. On 30.10.2018 15:01, Alan Mackenzie wrote: > Hello, Konstantin > > On Mon, Oct 29, 2018 at 21:46:50 +0300, Konstantin Kharlamov wrote: >> Thank you, so, I've used the patch today for working with a code, and >> everything seemed to be well :) > >> Tested-by: Konstantin Kharlamov > > Thanks for the testing. I've committed the patch to all the usual > places, and I'm closing the bug. > From unknown Sat Jun 14 03:57:38 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Mon, 24 Dec 2018 12:24:05 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator