#! /usr/local/bin/gawk -f
BEGIN { 

ID    =    "dclpsrmcm 0.3"
DATE  =                               "2002/06/07(takepiro)" 

EX    =    "remove corner mark and background from dcl.ps file"

USAGE =  "% dclpsrmcm <file>"

#----------------------------------------------------------------------------
# NO OPTIONS

	  if (ARGV[1]=="help") { 
	      print "  " ID,DATE
	      print " --- " EX
	      print " usage : " USAGE
              exit
          }

}

/^%%BeginObject: background/ \
                 { while ( $0!="%%EndObject" ) getline; next }

/^%%BeginObject/ { inmark=1
		   while (inmark==1) {
	  	     if ( $NF=="M" ) lastm = $0
		     if ( $NF=="M" || $NF=="L" )
                     { if ( $1!=79 && $1!=7421 && $2!=0 && $2!=5300 )
                       { inmark=0; 
		         print "N"
                         if ( $NF=="L") print lastm
                         print 
	               } 
	             }
	             else if ( $1!="N" && $1!="S" ) print
	             getline
                   }
                 }

	         { print }

