unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41809: c-context-line-break incorrect after comments: cache issue?
@ 2020-06-11 16:09 Daniel Colascione
       [not found] ` <mailman.1663.1591891807.2541.bug-gnu-emacs@gnu.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Daniel Colascione @ 2020-06-11 16:09 UTC (permalink / raw)
  To: 41809; +Cc: acm

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))'






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#41809: c-context-line-break incorrect after comments: cache issue?
       [not found] ` <mailman.1663.1591891807.2541.bug-gnu-emacs@gnu.org>
@ 2020-06-11 18:38   ` Alan Mackenzie
  2020-06-12  7:42     ` Alan Mackenzie
  2020-06-25 17:12     ` Alan Mackenzie
  0 siblings, 2 replies; 4+ messages in thread
From: Alan Mackenzie @ 2020-06-11 18:38 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: 41809, acm

Hello, Daniel.

In article <mailman.1663.1591891807.2541.bug-gnu-emacs@gnu.org> 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.

-- 
Alan Mackenzie (Nuremberg, Germany).






^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#41809: c-context-line-break incorrect after comments: cache issue?
  2020-06-11 18:38   ` Alan Mackenzie
@ 2020-06-12  7:42     ` Alan Mackenzie
  2020-06-25 17:12     ` Alan Mackenzie
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Mackenzie @ 2020-06-12  7:42 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: 41809

Hello again, Daniel.

On Thu, Jun 11, 2020 at 18:38:29 -0000, Alan Mackenzie wrote:
> In article <mailman.1663.1591891807.2541.bug-gnu-emacs@gnu.org> 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).





^ permalink raw reply	[flat|nested] 4+ messages in thread

* bug#41809: c-context-line-break incorrect after comments: cache issue?
  2020-06-11 18:38   ` Alan Mackenzie
  2020-06-12  7:42     ` Alan Mackenzie
@ 2020-06-25 17:12     ` Alan Mackenzie
  1 sibling, 0 replies; 4+ messages in thread
From: Alan Mackenzie @ 2020-06-25 17:12 UTC (permalink / raw)
  To: Daniel Colascione; +Cc: acm, 41809-done

Hello, Daniel.

On Thu, Jun 11, 2020 at 18:38:29 -0000, Alan Mackenzie wrote:
> In article <mailman.1663.1591891807.2541.bug-gnu-emacs@gnu.org> 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.

It wasn't.  I've committed a simple patch for this, and I'm closing the
bug.

> -- 
> Alan Mackenzie (Nuremberg, Germany).





^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-06-25 17:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-11 16:09 bug#41809: c-context-line-break incorrect after comments: cache issue? Daniel Colascione
     [not found] ` <mailman.1663.1591891807.2541.bug-gnu-emacs@gnu.org>
2020-06-11 18:38   ` Alan Mackenzie
2020-06-12  7:42     ` Alan Mackenzie
2020-06-25 17:12     ` Alan Mackenzie

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).