#! /bin/nawk -f
#
#	sgksfil1    relocate hardfil stuff first in sgks.ps
#
#				ver 1.0		92/03/26
#
#		usage:   % sgksfil1 sgks.ps > sgks.sps
#		         % sgksfil1 sgks.ps | lpr
#
#	        caution!!  Don't delete @sg-nohf file during the process. 
#		           Don't run two or more sgksopt process 
#		                 simultaneously in the same directory.
#
BEGIN 	{ body = 0
	  print "% no hard-fill part" > "@sg-nohf" }

/^N/	{ body = 1 }

/G/  	{ if ( body == 1 ) 
	  {  print
    	     while ( $0 != "0 G" )
	      { getline; print }
	  }
	  else print
	  next
	}

/^showpage/ { close("@sg-nohf")  
	      system("cat @sg-nohf")
	      print 
	      body = 0
  	      print "% no hard-fill part" > "@sg-nohf" 
	      next
            } 	 

	{ if ( body == 0 ) { print }
	  else { print >> "@sg-nohf" }
        }

END	{ system("/bin/rm -f @sg-nohf") }

