I have a code snippet int t.c like
val = (val1 << 8) | (val >> 8 );
val = (val2 << 16) | (val >> 8 );
val = (val3 << 32) | (val >> 8 );
val = (val << 8);
I will get ouput if I grep as grep -nhE "(<<.*|).*(>>)" t.c
1:val = (val1 << 8) | (val >> 8 );
2:val = (val2 << 16) | (val >> 8 );
3:val = (val3 << 32) | (val >> 8 );
But If search with cppcheck like ./cppcheck --rule="(<<.*|).*(>>)" t.c
I will get output
[../test/t.c:1]: (style) found ' val = ( val1 << 8 ) | ( val >> 8 ) ; val = ( val2 << 16 ) | ( val >> 8 ) ; val = ( val3 << 32 ) | ( val >>'
ie the whole matching lines together from first matching is displaying. I want the result as in grep command.
Please help
Try following command (escaped |
):
cppcheck --rule="<<.*?\|.*?>>" t.c
The output is not exactly same as that of grep.