cloc --diff fails (undefined value as an ARRAY reference)
Brought to you by:
alnd
Hi,
when runnig cloc --diff following is thrown with no result:
39622 text files.
40377 text files.es
Can't use an undefined value as an ARRAY reference at cloc/bin/cloc line 3626.
when running non-diff counting for both files separately everything is ok
Anonymous
Version 1.60 works fine .. only 1.62 fails
Can you post your two zip files? If not, can you post a pair of files that will duplicate this problem? This will be challenging to fix if I can't trigger the error.
I was hopping that you can detect it from the diff between the versions 1.60 and 1.62 .. these files are versions of compressed company project (500MB size) so I can't post it to you, but I will try to debug it somehow and post the results to you if I find sth.
From the line context it seems that some file recognition is wrong. It is recognized as some language, but subroutine handler for this language does not exists. Haven't you add any new language in the latest version?
Here is the verbose output for failing command - hopefully this will help:
-> call_counter(/tmp/i5mvT2AhQD/common/gmc/GUI/src/GUIFW/src/test/groovy/sendscript.groovy, Groovy)
-> read_file(/tmp/i5mvT2AhQD/common/gmc/GUI/src/GUIFW/src/test/groovy/sendscript.groovy)
<- read_file
-> rm_blanks(language=Groovy)
-> remove_matches(pattern=^\s*$)
<- remove_matches
<- rm_blanks(language=Groovy)
-> rm_comments(file=/tmp/i5mvT2AhQD/common/gmc/GUI/src/GUIFW/src/test/groovy/sendscript.groovy)
Can't use an undefined value as an ARRAY reference at ./cloc-1.62.pl line 3626.
thank you for your answer
PS: Please how can I add new language support - just for my private use (for our internal languages), I guess in language def file (--write-lang-def => --read-lang-def) I can modify only already defined languages?
Indeed, the verbose output was very helpful, thanks. It shows that the language filter for Groovy was missing in the 1.62 release (was there in 1.60, I must have been careless in a later update). I added this back in with svn commit 411, you can get the code here https://sourceforge.net/p/cloc/code/HEAD/tree/trunk/cloc. In addition I added a check so such a flaw won't happen again.
I don't see how running a straight, non-diff, count could have worked though. If a Groovy file appears in the input, the code would have crashed as it did with diff.
The easiest way to add a new, custom, language is to study the output from --write-lang-def then make your own definition patterned after one of the existing entries, then read your new entry back in with --read-lang-def. If you want, describe to me how comments appear in your custom language and I'll show you what the definition would look like.
v1.64 released