Path: utzoo!attcan!uunet!ginosko!usc!ucsd!ucbvax!hplabs!hpl-opus!hpnmdla!hpmwtd!jeffa
From: jeffa@hpmwtd.HP.COM (Jeff Aguilera)
Newsgroups: comp.lang.c
Subject: Re: C source lines in file
Message-ID: <680008@hpmwjaa.HP.COM>
Date: 15 Aug 89 23:38:37 GMT
References: <35120@ccicpg.UUCP>
Organization: HP Microwave Tech. - Santa Rosa, Ca.
Lines: 33

Here's my offering:

#!/bin/sh 
#
#	ncss: non commented source statements
#
{
	for file in $*
	do
		grep -v '^#' $file | /lib/cpp -P | rmnl | wc
		wc $file
		echo ''
	done
} | 
awk ' 
NF == 3 {
	l1 += $1
	w1 += $2
	c1 += $3 
}

NF == 4 {
	l2 += $1
	w2 += $2
	c2 += $3
}

{ print }

END {
	printf "%7d %6d %6d\tNoncommented\n", l1, w1, c1
	printf "%7d %6d %6d\tCommented\n", l2, w2, c2
}' -