#! /bin/sh
#
# 5799-WZQ (C) COPYRIGHT IBM CORPORATION 1987
# LICENSED MATERIALS - PROPERTY OF IBM
# REFER TO COPYRIGHT INSTRUCTIONS FORM NUMBER G120-2083
#
# $Header:fixsyms 12.0$ 
# $ACIS:fixsyms 12.0$ 
# $Source: /ibm/acis/usr/sys/conf/RCS/fixsyms,v $ 

#
# fixsyms [file] [outfile]
#
# clean up ncs symbols 
#
rmfile=
case "$1" in
"")
	file=/tmp/$$fixsym
	rmfile="rm -f $file"
	cat $1 > $file
	;;
*)
	file=$1
	;;
esac
if egrep -s '_\.' $file
then
	awk '
#
# script to fix up the output from nm by replacing 
# all symbols _x where a _.x exists.
#
# input is of form
#    $1      $2   $3
# address letter symbol
#
#
($2 == "T" || $2 == "t") && $3 ~ /^_\./ {
	name= "_" substr($3,3)
	names[name] = $1
	next
	}
names[$3] != "" {
	next
	}
{
names[$3] = $1
}

END {
	for (i in names)
		print names[i], "=", i
}
' $file | sort 
else
	cat $file 
fi >$2
eval "$rmfile"
