Untitled
public text v1 · immutable#!/usr/bin/perl -w
# Count lines in C functions. Assumes that function names all start in
# column 0, and there is no space between the name and the open paren,
# and that the close-brace ending the function is in column 0.
$all = 0;
while(<>) {
if (/^([a-zA-Z0-9_]+)\(/) {
$name = $1;
$start = $.;
}
if (/^\}/ && defined $name) {
$lines = $. - $start + 1;
$all += $lines;
print "$lines\t$name\n";
undef $name;
}
}
print "$all\ttotal\n";