terryyin / lizard

A simple code complexity analyser without caring about the C/C++ header files or Java imports, supports most of the popular languages.
Other
1.85k stars 250 forks source link

Wrong line # reported when '\' is used in C macro #307

Closed sungwoonpark closed 3 years ago

sungwoonpark commented 3 years ago

Hello.

Thanks for developing such great tool.

While I was using it in my code, I found the lizard report wrong line # sometimes. It happens when '\' was used in macro. As you can see below example, foo function is located at line 8, but the tool reported as line 3.

Can you take a look at this?

command : python3.7 lizard-1.17.7/lizard.py -Ecpre --xml hello.c > hello.c.xml

Here is hello.c `#define mymacro(_value) \ { \ if (_typeSize == 2) \ _value = htobe64(_value); \ } \ }

void foo(void) { int i=0; i++; } `

Here is Lizard output(hello.c.xml) `

1
        <value>5</value>
        <value>1</value>      

`

terryyin commented 3 years ago

Thanks. This seems to be a bug. I will find time to fix it.

On 17 Dec 2020, at 1:07 PM, sungwoonpark notifications@github.com wrote:

Hmm.. github deleted all '' in the macro. from the starting line to end line of the mymacro, there is '' at end of the line.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/terryyin/lizard/issues/307#issuecomment-747208143, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAGASYSSU3ACDBCZU2CEYM3SVGG2BANCNFSM4U64I2BA.

terryyin commented 3 years ago

Sorry for the long wait. This is fixed by https://github.com/terryyin/lizard/commit/42cc021aaf0346663101a4bad5e5bada170a7e6e.