Indentation width detection: try not to get fooled by comments
commitfe0280037d9b964e56c405b1efedbcea5cec762e
authorColomban Wendling <ban@herbesfolles.org>
Sun, 2 Jun 2013 20:42:47 +0000 (2 22:42 +0200)
committerColomban Wendling <ban@herbesfolles.org>
Sun, 2 Jun 2013 20:42:47 +0000 (2 22:42 +0200)
tree1d94b5ffd0e09cb82aa842a7dfa238982566e0b2
parent8afff838c1127067e621ec49652d715427d3e141
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
asterisk:

  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
account.
src/document.c