#
#	toks.awk
#
#	LastMod 20 Oct 97 DJ
#	Created 20 Oct 97 DJ
#
#
#	Look for statements that the NRC says should not be used
#
BEGIN {
	cur_func_name=""
	#
	# Tokens contained in the statement
	tok_count["SWITCH"]=0
	tok_count["TYPEDEF"]=0
	tok_count["FLOAT"]=0
	tok_count["QUESTION"]=0
	in_toks=0
}

# Get the function name
$1 == ".FUNC" {
		cur_func_name=$2
		next
	      }

# Print out what we have found
#
$1 == ".END" {
		if (tok_count["FLOAT"])
		   if (cur_func_name != "")
		      printf("Function '%s' contains %d float statements\n", cur_func_name, tok_count["FLOAT"])
		   else
		      printf("At file scope there are %d float statements\n", tok_count["FLOAT"])
		if (tok_count["QUESTION"])
		   printf("Function '%s' contains %d ? operators\n", cur_func_name, tok_count["QUESTION"])
		if (tok_count["SWITCH"])
		   printf("Function '%s' contains %d switch statements\n", cur_func_name, tok_count["SWITCH"])
		if (tok_count["TYPEDEF"])
		   if (cur_func_name != "")
		      printf("Function '%s' contains %d typedef statements\n", cur_func_name, tok_count["TYPEDEF"])
		   else
		      printf("At file scope there are %d typedef statements\n", tok_count["TYPEDEF"])
		cur_func_name=""
	        in_toks=0
		tok_count["SWITCH"]=0
		tok_count["TYPEDEF"]=0
		tok_count["FLOAT"]=0
		tok_count["QUESTION"]=0
		next
	     }

#
# Are we in a .TOKS section?
#
$1 == ".TOKS" {
	       in_toks=1
	       next
               }

# If we are in a .TOKS section count up the numbers of each tokens
{
if (in_toks == 1) {
   for (t=1; t<NR; t+=2)
      tok_count[$t]=$(t+1)
   }
}

