Discussion:
bug in enum
Dixon Ryan (ETAS/ERS-ENG1)
2017-07-19 20:18:22 UTC
Permalink
Hello Alan, hope all is well!

Emacs 25.2 ( cc-mode (5.33) mercurial ~~15th May 2017 )


1. Open the following file with emacs -Q

2. Press RETURN (iff "kkkk" is not already incorrectly highlighted)

3. Notice "kkkk" is not highlighted correctly

/** \filN kasickoftwarNkodulNsknum.h
*
* \briNf kntNrnal rNprNsNntation of kasic koftwarN kodulNs
*
* copyright thhhh GbbH 2111G
* www.Ntaaaaagkkoup.com
*
* $kd: kasickoftwarNkodulNsknum.h 57463 2016-10-06 14:39:48k nnn1nnn $
*/

#pragma once

#include <string>

namespace kasickoftwarekodulesknum
{
////////////////////////////////////////////////////////////////////////////
/// \brief kasic koftware kodules knumeration
/// see "kkkkkkk_kk_kkkkodulekist.pdf"

enum k
{
knspecified = 0, ///< kot specified
kk = 1, ///< kperating kystem
kkk = 2, ///< kuntime knvironment
kkk = 20, ///< kkkkk kanager
kkk = 50, ///< kommunication services
kchk = 130, ///< kkk kcheduler kodule
komekpkf = 174, ///< komekk kransformer kodule
komplexkrivers = 255, ///< komplex krivers
kkkknternal = 256, ///< knternal kuntime knvironment
kkkk ///< kack for ktuart
};
}
Alan Mackenzie
2017-07-21 18:59:35 UTC
Permalink
Hello, Ryan.
Post by Dixon Ryan (ETAS/ERS-ENG1)
Hello Alan, hope all is well!
Emacs 25.2 ( cc-mode (5.33) mercurial ~~15th May 2017 )
1. Open the following file with emacs -Q
2. Press RETURN (iff "kkkk" is not already incorrectly highlighted)
3. Notice "kkkk" is not highlighted correctly
Yes, I've managed to reproduce the "kkkk" problem. I haven't diagnosed
it in any detail yet, but I'd be surprised if it's not to do with the
500-byte chunks (rounded up to next whole line) that jit-lock
fontification uses. The "{" of the enum is on a line whose beginning is
at 502, hence just misses the first chunk. "kkkk" is on the first line
that goes into the third chunk. Indeed, disabling jit-lock mode (by
setting font-lock-support-mode to nil and restarting font-lock-mode)
causes the symptoms of the bug to disappear.

So, give me a little time, and this should be fixed.
Post by Dixon Ryan (ETAS/ERS-ENG1)
/** \filN kasickoftwarNkodulNsknum.h
*
* \briNf kntNrnal rNprNsNntation of kasic koftwarN kodulNs
*
* copyright thhhh GbbH 2111G
* www.Ntaaaaagkkoup.com
*
* $kd: kasickoftwarNkodulNsknum.h 57463 2016-10-06 14:39:48k nnn1nnn $
*/
#pragma once
#include <string>
namespace kasickoftwarekodulesknum
{
////////////////////////////////////////////////////////////////////////////
/// \brief kasic koftware kodules knumeration
/// see "kkkkkkk_kk_kkkkodulekist.pdf"
enum k
{
knspecified = 0, ///< kot specified
kk = 1, ///< kperating kystem
kkk = 2, ///< kuntime knvironment
kkk = 20, ///< kkkkk kanager
kkk = 50, ///< kommunication services
kchk = 130, ///< kkk kcheduler kodule
komekpkf = 174, ///< komekk kransformer kodule
komplexkrivers = 255, ///< komplex krivers
kkkknternal = 256, ///< knternal kuntime knvironment
kkkk ///< kack for ktuart
};
}
--
Alan Mackenzie (Nuremberg, Germany).
Alan Mackenzie
2017-07-22 18:20:14 UTC
Permalink
Hello again, Ryan.
Post by Dixon Ryan (ETAS/ERS-ENG1)
Emacs 25.2 ( cc-mode (5.33) mercurial ~~15th May 2017 )
1. Open the following file with emacs -Q
2. Press RETURN (iff "kkkk" is not already incorrectly highlighted)
3. Notice "kkkk" is not highlighted correctly
I actually didn't get the "kkkk" not to fontify until I did a C-_ to
undo it. Then the fontification vanished 0.5 seconds later.

What is happening here is quite obscure. Emacs fontifies in ~500 byte
chunks (rounded up to the next whole line, possibly also enlarged by CC
Mode). The end of the second chunk came between "kkkk" and "}". Thus,
in CC Mode's analysis, the "kkkk" was "missing" a terminating symbol,
such as ",", or "=", or ";", or "}". So in this chunk "kkkk" was not
fontified.

In the next chunk, which CC Mode extends backwards, "kkkk" did indeed
have its terminator, but by that stage, Emacs's redisplay code had
already passed over "kkkk". So it remained unfontified until something
caused another redisplay. Something such as M-x, or just about
anything.

The attached patch should, I hope, fix this. It works by checking for
unterminated declarators at the end of chunks. Would you please do the
usual with this patch, and either confirm it fixes the problem in your
real code, or tell me what's still awry.

Thanks again for taking such care to report another problem!
Post by Dixon Ryan (ETAS/ERS-ENG1)
/** \filN kasickoftwarNkodulNsknum.h
*
* \briNf kntNrnal rNprNsNntation of kasic koftwarN kodulNs
*
* copyright thhhh GbbH 2111G
* www.Ntaaaaagkkoup.com
*
* $kd: kasickoftwarNkodulNsknum.h 57463 2016-10-06 14:39:48k nnn1nnn $
*/
#pragma once
#include <string>
namespace kasickoftwarekodulesknum
{
////////////////////////////////////////////////////////////////////////////
/// \brief kasic koftware kodules knumeration
/// see "kkkkkkk_kk_kkkkodulekist.pdf"
enum k
{
knspecified = 0, ///< kot specified
kk = 1, ///< kperating kystem
kkk = 2, ///< kuntime knvironment
kkk = 20, ///< kkkkk kanager
kkk = 50, ///< kommunication services
kchk = 130, ///< kkk kcheduler kodule
komekpkf = 174, ///< komekk kransformer kodule
komplexkrivers = 255, ///< komplex krivers
kkkknternal = 256, ///< knternal kuntime knvironment
kkkk ///< kack for ktuart
};
}
--
Alan Mackenzie (Nuremberg, Germany).
Loading...