From 613faa7bc564ee213b81f6f687c23b1fefc2ab51 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Thu, 3 Nov 2005 13:46:34 -0500 Subject: [svn-r11678] Purpose: Bug fix, feature. Description: Fix a bug to recognize "#xyz..." is a comment in the init file. Add more binary data file types. Added prunepath command. Platforms tested: heping. --- bin/chkcopyright | 64 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/bin/chkcopyright b/bin/chkcopyright index b984efc..cdc308a 100755 --- a/bin/chkcopyright +++ b/bin/chkcopyright @@ -181,6 +181,14 @@ EOF # prune Directories to be skipped. Notice this prunes all directories # with the same name. E.g., # "prune test" skips test, fortran/test, c++/test, ... +# (See -name option in the find command.) +# prunepath Directory or file to be skipped. Notice this is different from +# prunes since it matches the exact pathname. E.g., +# "prunepath ./tools/testfiles" skips the directory/file matching +# exactly that path but NOT tools/h5dump/testfiles nor +# tools/h5dump/testfiles. +# (See -path option in the find command.) +# INITIALIZATION() { # clean up log files @@ -197,7 +205,7 @@ INITIALIZATION() if [ -r $INITFILE ]; then while read key value; do case "$key" in - '#' | '') # Comment or blank line, skip it + \#* | '') # Comment or blank line, skip it continue ;; skip) @@ -208,6 +216,10 @@ INITIALIZATION() echo $key $value EXCEPTIONDIRS="$EXCEPTIONDIRS -o -name $value" ;; + prunepath) + echo $key $value + EXCEPTIONDIRS="$EXCEPTIONDIRS -o -path $value" + ;; *) echo unknown setting input in file $INITFILE echo $key $value @@ -398,28 +410,39 @@ BATCH_FILE() # Check Unknown type file. -# Inspect the first 5 lines and try to guess what type of file it is. -# Then try verify Copyright notice according to guessed type. +# First check if there is something that resemble a copyright notice in +# the first "page". If so, then inspect the first 5 lines to guess what +# type of file it is. Then try verify Copyright notice according to +# guessed type. # UNKNOWN_FILE() { f=$1 - head -5 < $f > $tmpfile - if head -1 < $tmpfile | grep '^#!' > /dev/null; then - # First line is "#!". It is likely a shell script or similar type. - SHELL_FILE $f - elif grep '^#' < $tmpfile > /dev/null; then - # Some lines start with a "#". It may be a shell like type. - SHELL_FILE $f - elif grep '\/\*' < $tmpfile > /dev/null; then - # Found some lines containing '/*'. It may be a C/C++ style file. - C_SOURCE $f - elif grep '^!' < $tmpfile > /dev/null; then - # Some lines start with a "!". It may be a Fortran 9X style file. - FORTRAN_SOURCE $f - elif grep -i '^' < $tmpfile > /dev/null; then - # Some lines start with a "". It may be an HTML file. - HTML_FILE $f + if head -$NUMBEGINLINES < $f | grep "${COPYRIGHTSTR}" > /dev/null; then + # Now guess the file type and try match it. + head -5 < $f > $tmpfile + if head -1 < $tmpfile | grep '^#!' > /dev/null; then + # First line is "#!". It is likely a shell script or similar type. + SHELL_FILE $f + elif grep '\/\*' < $tmpfile > /dev/null; then + # Found some lines containing '/*'. It may be a C/C++ style file. + C_SOURCE $f + elif grep '^!' < $tmpfile > /dev/null; then + # Some lines start with a "!". It may be a Fortran 9X style file. + FORTRAN_SOURCE $f + elif grep '^#' < $tmpfile > /dev/null; then + # Some lines start with a "#". It may be a shell like type. + # Put this after C_SOURCE which may have #define and such lines. + SHELL_FILE $f + elif grep -i '^' < $tmpfile > /dev/null || \ + grep '^