Date:
Tue, 12 Oct 1999 10:07:19 -0700
Content-Transfer-Encoding:
7bit
Content-Type:
text/plain; charset="iso-8859-1"
MIME-Version:
1.0
|
My favourite is this awk script, typically driven from the C-shell
script that follows it:
#!/bin/awk -f
BEGIN { cmnt = 0; nblnk = 0; blnk = 0; semi = 0; }
/^[ \t]*--/ { cmnt++; next; }
/^[ \t]*$/ { blnk++; next; }
/;$/ { semi++; next; }
{ nblnk++; next; }
END {
printf("Comment lines: %5d\n", cmnt);
printf("Blank lines: %5d\n", blnk);
printf("Semicolon lines: %5d\n", semi);
printf("Other lines: %5d\n", nblnk);
printf("-----------------------\n");
printf("Total lines: %5d\n", cmnt+blnk+semi+nblnk);
}
#! /bin/csh -f
#
# Command file to count lines in: ada units and or views
#
set sloc_counter = "~/bin/sc"
set usage = "Usage: $0 [-v] <file_list>"
#
# Check for verbosity
#
if ( $1 == -v ) then
shift
set verbose
endif
#
# Check number of arguments
#
if ( $#argv < 1 ) then
echo "$usage"
exit 1
endif
# Loop for each arg
foreach file ( $* )
if ( -e $file ) then
#only get here if the 'object' exists
if ( -f $file && $file =~ *.ada ) then
echo $file
$sloc_counter $file
else
if ( -d $file ) then
echo "Totals for directory $file"
#
# Don't iterate over all files, instead give a total
# find $file -name '*.ada' -print -exec $sloc_counter {} \;
#
$sloc_counter $file/*.ada
else
echo "$file is not an Ada unit or a directory name"
endif
endif
else
echo "$file doesn't exist"
endif
end
|
|
|