From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Alan Mackenzie Newsgroups: gmane.emacs.bugs Subject: bug#41809: c-context-line-break incorrect after comments: cache issue? Date: Fri, 12 Jun 2020 07:42:01 +0000 Message-ID: <20200612074201.GA5615@ACM> References: <20200611183829.59331.qmail@mail.muc.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="9083"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41809@debbugs.gnu.org To: Daniel Colascione Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 12 09:43:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jjeLG-0002Hg-Fx for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Jun 2020 09:43:10 +0200 Original-Received: from localhost ([::1]:57992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jjeLF-0004Fk-54 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 12 Jun 2020 03:43:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jjeL8-0004Bb-8I for bug-gnu-emacs@gnu.org; Fri, 12 Jun 2020 03:43:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jjeL7-0002p9-VM for bug-gnu-emacs@gnu.org; Fri, 12 Jun 2020 03:43:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jjeL7-00033p-TN for bug-gnu-emacs@gnu.org; Fri, 12 Jun 2020 03:43:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Alan Mackenzie Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jun 2020 07:43:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41809 X-GNU-PR-Package: emacs Original-Received: via spool by 41809-submit@debbugs.gnu.org id=B41809.159194773111700 (code B ref 41809); Fri, 12 Jun 2020 07:43:01 +0000 Original-Received: (at 41809) by debbugs.gnu.org; 12 Jun 2020 07:42:11 +0000 Original-Received: from localhost ([127.0.0.1]:38857 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jjeKI-00032e-RS for submit@debbugs.gnu.org; Fri, 12 Jun 2020 03:42:11 -0400 Original-Received: from colin.muc.de ([193.149.48.1]:30693 helo=mail.muc.de) by debbugs.gnu.org with smtp (Exim 4.84_2) (envelope-from ) id 1jjeKH-00032R-04 for 41809@debbugs.gnu.org; Fri, 12 Jun 2020 03:42:09 -0400 Original-Received: (qmail 94356 invoked by uid 3782); 12 Jun 2020 07:42:02 -0000 Original-Received: from acm.muc.de (p4fe15d7d.dip0.t-ipconnect.de [79.225.93.125]) by localhost.muc.de (tmda-ofmipd) with ESMTP; Fri, 12 Jun 2020 09:42:01 +0200 Original-Received: (qmail 10373 invoked by uid 1000); 12 Jun 2020 07:42:01 -0000 Content-Disposition: inline In-Reply-To: <20200611183829.59331.qmail@mail.muc.de> 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.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:181886 Archived-At: Hello again, Daniel. On Thu, Jun 11, 2020 at 18:38:29 -0000, Alan Mackenzie wrote: > In article you wrote: > > c-context-line-break sometimes incorrectly extends a comment when invoked > > immediately after the end of a comment. To repro: > > emacs -Q --eval '(progn (c-mode) (insert "/*foo*/") (backward-char) > > (c-context-line-break) (delete-char -2) (end-of-line) > > (c-context-line-break))' > > The second c-context-line-break occurs when point is *after* the comment, > > so the /*foo*/ comment shouldn't be extended --- yet it is. The problem > > appears to be some kind of cc-mode cache corruption. This recipe behaves > > correctly: > > $ emacs -Q --eval '(progn (c-mode) (insert "/*foo*/") (backward-char) > > (c-context-line-break) (delete-char -2) (end-of-line) (c-before-change > > (point-min) (point-max)) (c-after-change (point-min) (point-max) (1- > > (point-max))) (c-context-line-break))' > Thanks for the report. > After a quick bit of edebugging, it seems to be an off-by-one error in > some cache handling. It shouldn't be too difficult to sort out. Would you please try out the following patch on your real code where you found the bug. It seems to fix your test case. diff -r fd31432873bd cc-engine.el --- a/cc-engine.el Thu Jun 11 10:50:35 2020 +0000 +++ b/cc-engine.el Fri Jun 12 07:32:38 2020 +0000 @@ -3141,7 +3141,7 @@ (not base) ; FIXME!!! Compare base and far-base?? ; (2019-05-21) (not end) - (> here end)) + (>= here end)) (progn (setq far-base-and-state (c-parse-ps-state-below here) far-base (car far-base-and-state) @@ -3154,7 +3154,7 @@ (or (and (> here base) (null end)) (null (nth 8 s)) - (and end (> here end)) + (and end (>= here end)) (not (or (and (nth 3 s) ; string Thanks! -- Alan Mackenzie (Nuremberg, Germany).