Package: sloccount
Version: 2.26-2.1
Severity: wishlist
Tags: patch
attached is a patch that enhances the recognition of bison/flex source files
with .yy/.ll file name extensions and files generated from these input file.
The patch also enhances the recognition of bison/flex generated files from
.y/.l files.
-- System Information:
Debian Release: 4.0
APT prefers stable
APT policy: (500, 'stable')
Architecture: i386 (i686)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.24.2
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
diff -u sloccount-2.26/break_filelist sloccount-2.26-bison-flex/break_filelist
--- sloccount-2.26/break_filelist 2004-08-01 06:17:28.000000000 +0200
+++ sloccount-2.26-bison-flex/break_filelist 2008-02-20 13:27:10.000000000
+0100
@@ -189,7 +189,9 @@
"awk" => "awk",
"sed" => "sed",
"y" => "yacc",
+ "yy" => "yacc",
"l" => "lex",
+ "ll" => "lex",
"makefile" => "makefile",
"sql" => "sql",
"php" => "php", "php3" => "php", "php4" => "php", "php5" => "php",
@@ -850,6 +852,12 @@
if (($firstline =~ [EMAIL PROTECTED],.]\\"@) &&
$filename =~ [EMAIL PROTECTED](c|cpp|C|cxx|cc)$@) {return "not";}
+ # Make some more tests for Bison-generated files
+ if ($firstline =~ [EMAIL PROTECTED] Bison parser, made by GNU Bison@) {
+ print "Note: found bison-generated file $filename\n"
+ if $noisy;
+ return "auto";
+ }
if (!($firstline =~ [EMAIL PROTECTED]@)) {return "";} # No script indicator
here.
@@ -990,6 +998,37 @@
return "auto";
}
}
+ if ($basename =~ m/\.tab\.[ch]{2}$/) {
+ $possible_bison = $file_to_examine;
+ $possible_bison =~ s/\.tab\.[ch]{2}$/\.yy/;
+ if (-s "$possible_bison") {
+ print "Note: found bison-generated file $file_to_examine\n"
+ if $noisy;
+ return "auto";
+ }
+ }
+
+ # Flex may generate arbitraty files. Try to be a bit clever about the
+ # generated file. (Flex generates only C/C++ files - no header files.)
+ if ($basename =~ m/.c$/) {
+ $possible_flex = $file_to_examine;
+ $possible_flex =~ s/.c$/\.l/;
+ if (-s "$possible_flex") {
+ print "Note: found flex-generated file $file_to_examine\n"
+ if $noisy;
+ return "auto";
+ }
+ }
+ if ($basename =~ m/.cc$/) {
+ $possible_flex = $file_to_examine;
+ $possible_flex =~ s/.cc$/\.ll/;
+ if (-s "$possible_flex") {
+ print "Note: found flex-generated file $file_to_examine\n"
+ if $noisy;
+ return "auto";
+ }
+ }
+
# If there's a corresponding ".MASTER" file, treat this file
# as automatically-generated derivative. This handles "exmh".