#!/bin/csh
# fixcplot: a sed script to change cplotlib function names to the
#           newer vplotlib names.
#
# keywords: vplot fix vplotlib update
#
if ($#argv == 0) then
	echo "fixcplot, a shell to change archaic cplotlib function names"
	echo "to their new forms. The original file is kept in .Boriginal_file"
	echo "Usage: fixcplot file_name"
exit
endif

cp $1 .B$1
expand < .B$1 | sed \
	-e 's/ window[ ]*(/ vp_clip (/g'\
	-e 's/ windo[ ]*(/ vp_clip (/g'\
	-e 's/ where[ ]*(/ vp_where (/g'\
	-e 's/ uwindow[ ]*(/ vp_uclip (/g'\
	-e 's/ uwindo[ ]*(/ vp_uclip (/g'\
	-e 's/ setfn[ ]*(/ vp_file (/g'\
	-e 's/ setfp[ ]*(/ vp_filep (/g'\
	-e 's/ set0[ ]*(/ vp_orig (/g'\
	-e 's/ setu0[ ]*(/ vp_uorig (/g'\
	-e 's/ setcol[ ]*(/ vp_color (/g'\
	-e 's/ setscl[ ]*(/ vp_scale (/g'\
	-e 's/ setdash[ ]*(/ vp_dash (/g'\
	-e 's/ text[ ]*(\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\))/ vp_text (\1,\2,\3,90*(\4),\5)/g'\
	-e 's/ utext[ ]*(\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\))/ vp_utext (\1,\2,\3,90*(\4),\5)/g'\
	-e 's/ Text[ ]*(/ vp_text (/g'\
	-e 's/ uText[ ]*(/ vp_utext (/g'\
	-e 's/ arrow[ ]*(/ vp_arrow (/g'\
	-e 's/ uarrow[ ]*(/ vp_uarrow (/g'\
	-e 's/ area[ ]*(/ vp_area (/g'\
	-e 's/ uarea[ ]*(/ vp_uarea (/g'\
	-e 's/ draw[ ]*(/ vp_draw (/g'\
	-e 's/ udraw[ ]*(/ vp_udraw (/g'\
	-e 's/ endplot[ ]*(/ vp_endplot (/g'\
	-e 's/ endplt[ ]*(/ vp_endplot (/g'\
	-e 's/ erase[ ]*(/ vp_erase (/g'\
	-e 's/ move[ ]*(/ vp_move (/g'\
	-e 's/ umove[ ]*(/ vp_umove (/g'\
	-e 's/ pendn[ ]*(/ vp_pendn (/g'\
	-e 's/ upendn[ ]*(/ vp_upendn (/g'\
	-e 's/ penup[ ]*(/ vp_penup (/g'\
	-e 's/ plot[ ]*(/ vp_plot (/g'\
	-e 's/ uplot[ ]*(/ vp_uplot (/g'\
	-e 's/ purge_plot[ ]*(/ vp_purge (/g'\
	-e 's/ setfat[ ]*(/ vp_fat (/g'\
	-e 's/ setovl[ ]*(/ vp_overlay (/g' \
	-e 's/^window[ ]*(/vp_clip (/'\
	-e 's/^windo[ ]*(/vp_clip (/'\
	-e 's/^where[ ]*(/vp_where (/'\
	-e 's/^uwindow[ ]*(/vp_uclip (/'\
	-e 's/^uwindo[ ]*(/vp_uclip (/'\
	-e 's/^setfn[ ]*(/vp_file (/'\
	-e 's/^setfp[ ]*(/vp_filep (/'\
	-e 's/^set0[ ]*(/vp_orig (/'\
	-e 's/^setu0[ ]*(/vp_uorig (/'\
	-e 's/^setcol[ ]*(/vp_color (/'\
	-e 's/^setscl[ ]*(/vp_scale (/'\
	-e 's/^setdash[ ]*(/vp_dash (/'\
	-e 's/^text[ ]*(\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\))/vp_text (\1,\2,\3,90*(\4),\5)/'\
	-e 's/^utext[ ]*(\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\),\([^,]*\))/vp_utext (\1,\2,\3,90*(\4),\5)/'\
	-e 's/^Text[ ]*(/vp_text (/'\
	-e 's/^uText[ ]*(/vp_utext (/'\
	-e 's/^arrow[ ]*(/vp_arrow (/'\
	-e 's/^uarrow[ ]*(/vp_uarrow (/'\
	-e 's/^area[ ]*(/vp_area (/'\
	-e 's/^uarea[ ]*(/vp_uarea (/'\
	-e 's/^draw[ ]*(/vp_draw (/'\
	-e 's/^udraw[ ]*(/vp_udraw (/'\
	-e 's/^endplot[ ]*(/vp_endplot (/'\
	-e 's/^endplt[ ]*(/vp_endplot (/'\
	-e 's/^erase[ ]*(/vp_erase (/'\
	-e 's/^move[ ]*(/vp_move (/'\
	-e 's/^umove[ ]*(/vp_umove (/'\
	-e 's/^pendn[ ]*(/vp_pendn (/'\
	-e 's/^upendn[ ]*(/vp_upendn (/'\
	-e 's/^penup[ ]*(/vp_penup (/'\
	-e 's/^plot[ ]*(/vp_plot (/'\
	-e 's/^uplot[ ]*(/vp_uplot (/'\
	-e 's/^purge_plot[ ]*(/vp_purge (/'\
	-e 's/^setfat[ ]*(/vp_fat (/'\
	-e 's/^setovl[ ]*(/vp_overlay (/' \
| unexpand > $1
