Commit [fe0280]  Maximize  Restore  History

Indentation width detection: try not to get fooled by comments

C-style multiline comments, used among others in C, C++ and Java, are
often continued on next lines with an additional space followed by an

1. /* first comment line
2. * continuation line (asterisk is aligned with previous line)
3. * last line */

This fools the indentation with detection because lines 2 and 3 from
the above example have an extra space in what is considered being the
line indentation. In this example, the algorithm would detect an
indentation width of 5 rather than 4, because here most lines have an
indent of 5 -- although they actually have an indent of 4 plus a space
for alignment. This is not a problem in most situations because there
generally are fewer comment continuation lines than actual code lines
which have a indent multiple of the actual indent width, but with some
code with a lot of comments (e.g. short functions with verbose
documentation comments) this might start to fool the algorithm and
give wrong, annoying, results.

So, try to detect these continuation lines and avoid taking them into

Colomban Wendling Colomban Wendling 2013-06-02

changed src/document.c
src/document.c Diff Switch to side-by-side view

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks