From 414249dcea536dd6f8b370212f8e51cf352b0756 Mon Sep 17 00:00:00 2001 From: Albert Cheng Date: Tue, 11 Oct 2005 14:40:43 -0500 Subject: [svn-r11544] Purpose: New feature. Description: Added code that try to guess what type of file it is by inspecting the first 5 lines. Then it tries to find the Copyright notice according to the guess. --- bin/chkcopyright | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/bin/chkcopyright b/bin/chkcopyright index 0dbf5de..62dd36c 100755 --- a/bin/chkcopyright +++ b/bin/chkcopyright @@ -26,6 +26,7 @@ PROGNAME=$0 DIFF="diff" INITFILE=.h5chkright.ini EXCEPTIONS=/tmp/h5chkright.except.$$ +tmpfile=/tmp/h5chkright_tmp.$$ EXCEPTIONDIRS="-name CVS" # at least skip CVS directories. EXTRACTEDFILE=/tmp/h5chkright.extracted.$$ VERBOSE= # default no @@ -337,6 +338,30 @@ SHELL_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. +# +UNKNOWN_FILE() +{ + f=$1 + head -5 < $f > $tmpfile + if head -1 < $tmpfile | grep '^#!' > /dev/null; then + # It is likely a shell script or similar type. + SHELL_FILE $f + elif grep '\/\*' < $tmpfile > /dev/null; then + # It is C/C++ style file. + C_SOURCE $f + elif grep '^!' < $tmpfile > /dev/null; then + # It is a Fortran 9X style file. + FORTRAN_SOURCE $f + else + # Unknown type. + UNKNOWN_TYPE $f + fi +} + + # Passed checking. # $1 file that has passed. # @@ -422,7 +447,7 @@ while read file; do continue ;; *) - UNKNOWN_TYPE $file + UNKNOWN_FILE $file ;; esac fi -- cgit v0.12