
# total_rules counts the number of rules in a given rule file.  If two
# arguments are passed, the second is a state number which tells total_rules
# to stop counting after the occurance of the specified state.

case $# in
0)	echo 'Usage: total_rules rule_file [state_number]' 1>&2; exit 1;;
1)	awk	'BEGIN		{cnt = 0}
  		($1 != "state")	{cnt++}
		END		{print cnt}' $1 ;;

2)	sed /$2/q $1 | awk 'BEGIN		{cnt = 0}
  			   ($1 != "state")	{cnt++}
			   END			{print cnt}' ;;
esac
	
