bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#13244: cc-mode indentation fails depending on the phase of the moon


From: Alan Mackenzie
Subject: bug#13244: cc-mode indentation fails depending on the phase of the moon
Date: Thu, 27 Dec 2012 16:20:54 +0000
User-agent: Mutt/1.5.21 (2010-09-15)

Hello, Dietrich.

>This bug is weird.  I couldn't use auto-indentation in a certain file.
>I tried restarting Emacs, behavior persists.  I upgraded to the latest
>version from Bzr, behavior persists.  I created a new account with no
>.emacs file and tried from there, behavior persists.  In comparison,
>indentation works correctly in the Emacs that in the current Debian
>Wheezy repository, which is 24.3.50.1.

>Trying to automatically indent code inside the last function in the
>attached file fails.  It succeeds if I make almost any modification to
>code above the last function in the file -- it could be something as
>minor as adding a space on an empty line, but changing text in the
>comments seems to have no effect.  Indentation works in every function
>but the last one (or any one you create below it).

>The point at which indentation breaks is somewhere very close to the
>bottom of the file, I deleted code from the bottom of the file until I
>found the location where it breaks.

What is happening is this: CC Mode maintains a cache of "safe positions"
(i.e. positions not in a string or comment) approximately every 3000
bytes.  By pure chance, one of these supposed positions in your file is
at pos. 21002, which happens to be between the "/" and the "*" of the
comment opener on L836.  This position isn't safe at all, and is found
due to a bug in a low level scanning routine (`parse-partial-sexp') in
Emacs.

Furthermore, that comment contains an "unbalanced" "'".  So when CC Mode
scans forward from that supposed safe position, it finds the "'" and
thinks it's inside a string.  This is why indentation isn't working in
your file after that comment.

As you've noted, the slightest change to the buffer and the error no
longer happens (since the "safe" position is no longer inside the
comment opener).

Thank you very much indeed for taking the trouble to report this arcane
bug.  We actually noticed the possibility of this bug in December 2011
and discussed it a bit, but nobody actually got around to fixing it
then.  Maybe we should now.

-- 
Alan Mackenzie (Nuremberg, Germany).





reply via email to

[Prev in Thread] Current Thread [Next in Thread]