All pastes #1412188 Raw Edit

Untitled

public text v1 · immutable
#1412188 ·published 2009-05-04 15:22 UTC
rendered paste body
#!/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";