#!/bin/sh
#
#  file: fix-edgar
#  auth: Brad Burdick
#  desc: Strip out all extra carriage return characters and convert any
#        stray ^L (formfeeds) to <PAGE> tags
#
#  usage: fix-edgar file [ file ... ]
#
#  NOTE:  This script contains some control characters, so it will be
#         necessary to download using BINARY mode.
#
##########################################################################
#  Copyright (c) 1994, 1995 Internet Multicasting Service
#
#  The SEC EDGAR Level 1 Dissemination processing software ("software")
#  was developed by the Internet Multicasting Service and may 
#  be used for academic, research, government, and internal business
#  purposes without charge.  You may not resell this code or include it
#  in a product that you are selling without prior permission of the
#  Internet Multicasting Service.
#
#  This software is provided ``as is'', without express or implied
#  warranty, and with no support nor obligation to assist in its
#  use, correction, modification or enhancement.  We assume no liability
#  with respect to the infringement of copyrights, trade secrets, or any
#  patents, and are not responsible for consequential damages.  Proper
#  use of the software is entirely the responsibility of the user.
##########################################################################

# clean up the data file(s)
for f in $*
do
	tmpfile="`basename ${f}`.tr"

	/bin/tr -d '\015' < ${f} | \
		/bin/sed -e 's/^\./ ./' \
		         -e 's/$/<PAGE>/' \
		         -e 's//<PAGE>\
/' \
		         -e 's/<\(.*\)><PAGE>/\1\
<PAGE>/' \
		         -e 's/\(.+\)<PAGE>/\1\
<PAGE>/' \
		> $tmpfile
	/bin/mv $tmpfile ${f}
done

exit 0

