#! /bin/csh
#
# Copyright 10/10/96 Sun Microsystems, Inc. All Rights Reserved
#
# @(#)tidy-mif	1.2	96/10/10 SMI

#	tidy-mif: switch off rulers, borders, text symbols and the grid
#		  in the argument .mif files
#
# THIS SAMPLE PROGRAM IS BEING PROVIDED "AS IS" AND ONLY AS A COURTESY TO
# THE RECIPIENT.  SUN MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS 
# OR IMPLIED WITH RESPECT TO THIS SAMPLE PROGRAM INCLUDING QUALITY, PERF- 
# FORMANCE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON- 
# INFRINGEMENT.  IN NO EVENT WILL SUN BE LIABLE FOR ANY DIRECT, INDIRECT,  
# SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR  
# INABILITY TO USE THIS SAMPLE PROGRAM.

set my_name = "tidy-mif"

if ( $#argv < 1 ) then
    echo "usage: ${my_name} file[.mif] ..."
    exit 1
endif

foreach file ( $argv )
    #	default the extension to .mif.
    if ( ${file:e} == "" ) then
	set file = ${file}.mif
    endif

    #	check that the file is okay to write
    if ( ! -w ${file} ) then
	# destination isn't writeable, then forget writing it.
	echo "${my_name}: ${file} is not writeable"
	exit 1
    endif

    sed -e '/^ <DGridOn Yes >$/s// <DGridOn No >/' \
	-e '/^ <DRulersOn Yes >$/s// <DRulersOn No >/' \
	-e '/^ <DBordersOn Yes >$/s// <DBordersOn No >/' \
	-e '/^ <DSymbolsOn Yes >$/s// <DSymbolsOn No >/' \
	-e '/^ <DWindowRect .* >$/s// <DWindowRect 0 0 0 0 >/' \
	< ${file} > /tmp/$$

    if { cmp -s ${file} /tmp/$$ } then
	# no edits needed; leave original file alone
	rm /tmp/$$
    else
	mv /tmp/$$ ${file}
    endif
end















