Got this error while running CPD on a C++ codebase:
net.sourceforge.pmd.lang.ast.TokenMgrError: Lexical error in file /work/mhargett/qa-tools-trunk/./perf-test/mtest.cc at line 157, column 11. Encountered: "\n" (10), after : "\""
at net.sourceforge.pmd.lang.cpp.ast.CppParserTokenManager.getNextToken(CppParserTokenManager.java:1648)
at net.sourceforge.pmd.lang.cpp.CppTokenManager.getNextToken(CppTokenManager.java:23)
at net.sourceforge.pmd.cpd.CPPTokenizer.tokenize(CPPTokenizer.java:29)
at net.sourceforge.pmd.cpd.CPD.add(CPD.java:110)
the code in question:
#if 0
static void my_memset(void *dest,int fill_value,int count)
{
__asm __volatile__(
"cld\n"
"mov %ecx, %ebx\n"
"shr 2,%ecx\n"
"rep "
"stosl\n"
"mov %ebx,%ecx\n"
" // line 157 mentioned above
:
: "c" (count), "a" (fill_value), "D" (dest)
: "cc","%ebx" );
}
#endif
The syntax is incorrect, of course, but I'm not sure that PMD should be trying to process something that is #if 0'd out. Simian appears to correctly skip #if 0'd things and has no problem with this file.
Will be fixed/implemented with 5.2.2.
2 new parameters for CPD have been introduced:
--no-skip-blocks: can disable the behavior. By default, skip blocks is activated.--skip-blocks-pattern: the start/end pattern to identify a block .By default "#if 0|#endif" is used. The start/end patterns are separated by a "|".Diff: