Open csrabak opened 2 months ago
Hey, could you run it by file and add the content of a file that gives a negative count. Or maybe the headers.
The problem seems to be from the comment count. I guess there are some comment cases that I didn't account for. Like if there is a single line comment but marked with /* comment */
instead of // comment
the counting will break as it will look for the ending */
on the next line and miss it.
As the files are of a project I've no authorization to publicize, I'll investigate the corner cases you mention and report back asap.
Using the regexp ^\/\*.*\*\/$
I've got two C files and one header that have more than one line that fits this case you mention.
More specifically, the header file has nine of such lines, and the C files 13 lines each (one of them includes one with /**/
.
So I think this diagnostic of yours is confirmed for this project case.
As an example of code you can inspect, I did the same experiment with Fabrizzio's wav https://github.com/fabrizzio-gz/wav, getting the following results:
D:\>\wav-master\src>ccloc . -l C "C Header"
--------------------------+------------+------------+------------+------------
Language | Total | Code | Comments | Files
--------------------------+------------+------------+------------+------------
C | 456 | 183 | 220 | 5
C Header | 73 | 56 | 0 | 5
--------------------------+------------+------------+------------+------------
TOTAL | 529 | 239 | 220 | 10
--------------------------+------------+------------+------------+------------
D:\>\wav-master\src>cloc .
10 text files.
10 unique files.
0 files ignored.
github.com/AlDanial/cloc v 2.02 T=0.03 s (306.5 files/s, 16214.1 lines/s)
-------------------------------------------------------------------------------
Language files blank comment code
-------------------------------------------------------------------------------
C 5 82 15 359
C/C++ Header 5 17 0 56
-------------------------------------------------------------------------------
SUM: 10 99 15 415
-------------------------------------------------------------------------------
Even if the blattant negative number don't appear still the difference is noticeable.
In a project folder with 58 C files and two C header files, ccloc called as follows
D:\> ccloc . -l C "C Header"
reports:As a comparison, when the same set of files is counted with
cloc
, this is summary obtained:The total lines of the two counters match for C files, and within ten lines of the
wc
utility, however the rest of the metrics are very discrepant and the negative counts for code seems to be a bug of some sort.