diff options
author | Ronald Aigner <ra3@os.inf.tu-dresden.de> | 2012-04-11 12:21:24 +0200 |
---|---|---|
committer | Jari Aalto <jari.aalto@cante.net> | 2012-04-11 12:21:24 +0200 |
commit | b420f0b7af30848bfed4bfbf41f3a0ba473ce5eb (patch) | |
tree | c7050572097a6350bab0d7e6d00bf5136e323794 | |
parent | fbf79a96a03e388fc71075a095de38de6ada7b53 (diff) |
Enhance the recognition of bison/flex source files
Gbp-Pq: Name 30_bts466827_enhance_bison_flex.patch
-rwxr-xr-x | break_filelist | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/break_filelist b/break_filelist index 86d0e74..021d913 100755 --- a/break_filelist +++ b/break_filelist @@ -190,7 +190,9 @@ $noisy = 0; # Set to 1 if you want noisy reports. "awk" => "awk", "sed" => "sed", "y" => "yacc", + "yy" => "yacc", "l" => "lex", + "ll" => "lex", "makefile" => "makefile", "sql" => "sql", "php" => "php", "php3" => "php", "php4" => "php", "php5" => "php", @@ -851,6 +853,12 @@ sub file_type_from_contents() { if (($firstline =~ m@^[,.]\\"@) && $filename =~ m@\.(c|cpp|C|cxx|cc)$@) {return "not";} + # Make some more tests for Bison-generated files + if ($firstline =~ m@A Bison parser, made by GNU Bison@) { + print "Note: found bison-generated file $filename\n" + if $noisy; + return "auto"; + } if (!($firstline =~ m@^#!@)) {return "";} # No script indicator here. @@ -991,6 +999,37 @@ sub get_file_type { 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". |