keywords.sh revision 7c478bd95313f5f23a4c958a745db2134aa03244
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
# Checks the list of files to make sure that each given
# file has a SMI standard ident string.
#
# It checks that keywords exist, and verifies the string. By default,
# all allowable forms of keywords (according to the ON documentation)
# are acceptable. The '-p' option (pedantic) allows only the canonical
# form of keywords. See below for allowable forms.
#
# Use as "keywords filelist" where filelist is the list of
# plain files, which could be the edited output of 'putback -n'.
#
# The following command will check a reasonable subset of ON source
# in a teamware workspace.
#
# % cd $CODEMGR_WS/usr/src
# % keywords \
# `find . -name SCCS -prune -o -name '*Make*' -print -o '*.csh' -print`
#
# Output consists of filenames with expanded, incorrect or missing
#
# Exits with status 0 if all files are sccs files and all files have
# unexpanded, correct keywords. Otherwise, exits with a non-zero status.
#
# The CDPATH variable causes ksh's `cd' builtin to emit messages to stdout
# under certain circumstances, which can really screw things up; unset it.
#
unset CDPATH
# Canonical form for .c and .h files
CANON_C_H="^#pragma ident \"\%\Z\%\%\M\% \%\I\% \%\E\% SMI\""
# Realmode (different compiler) canonical form for .c and .h files
REALMODE_C_H="^#ident \"\%\Z\%\%\M\% \%\I\% \%\E\% SMI\""
# Canonical form for other files
CANON_OTHER="ident \"\%\Z\%\%\M\% \%\I\% \%\E\% SMI\""
STANDARD="ident \"(\%\Z\%\%\M\% +\%\I\%|\%W\%) +\%\E\% SMI\""
EXPANDED="@\(#\).*[ ]+[1-9]+(\.[0-9]+)+[ ]+(-[ ]+)?[0-9][0-9]/[01][0-9]/[0-3][0-9][ ]+.*(SMI|Sun)"
LIBERAL="(\%\Z\%\%\M\%[ ]+\%\I\%|\%W\%)[ ]+\%\E\%[ ]+.*(SMI|Sun)"
fname=$1
bname=$2
canon_str=$3
if [ $? -ne 0 ]; then
echo "Incorrect ident string in $fname"
exitcode=1
fi
if [ $? -ne 0 ]; then
if [ $? -eq 0 ]; then
echo "Expanded keywords in $fname"
else
echo "Incorrect ident string in $fname"
fi
exitcode=1
fi
else
if [ $? -ne 0 ]; then
if [ $? -eq 0 ]; then
echo "Expanded keywords in $fname"
else
echo "Incorrect ident string in $fname"
fi
exitcode=1
fi
fi
}
pedantic=0
liberal=0
cwd=`pwd`
exitcode=0
while getopts lp c
do
case $c in
l) liberal=1;;
p) pedantic=1;;
\?) echo $USAGE
exit 2;;
esac
done
for i
do
# Try to build the full path to the file argument
if [ ! $? -eq 0 ]; then
fi
cd $dir
# We should now be in the directory where the file to check lives.
# If this directory has 'realmode' anywhere within its path then
# select the realmode canonical string.
case `pwd` in
*realmode*)
*)
esac
*)
esac
else
if [ $? -eq 0 ]; then
if [ $? -eq 0 ]; then
echo "Expanded keywords in $i"
else
echo "Missing keywords in $i"
fi
exitcode=1
else
*)
esac
fi
fi
else
echo "Not an SCCS file: $i"
exitcode=1
fi
cd $cwd
done
exit $exitcode