% Copyright (C) 1992, 1993, 1994 Aladdin Enterprises. All rights reserved. % % This file is part of Aladdin Ghostscript. % % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND. No author % or distributor accepts any responsibility for the consequences of using it, % or for whether it serves any particular purpose or works at all, unless he % or she says so in writing. Refer to the Aladdin Ghostscript Free Public % License (the "License") for full details. % % Every copy of Aladdin Ghostscript must include a copy of the License, % normally in a plain ASCII text file named PUBLIC. The License grants you % the right to copy, modify and redistribute Aladdin Ghostscript, but only % under certain conditions described in the License. Among other things, the % License requires that the copyright notice and this notice be preserved on % all copies. % mergeini.ps - utility for merging all the Ghostscript initialization files % (gs_*.ps) into a single file, optionally converting them to C data. /infile { findlibfile { exch pop } { (r) file } ifelse } def /lstring =string length string def /rl { in lstring readline } def /wcstring 3 string def /wl { toC { 0 exch { wcstring cvs out exch writestring out (,) writestring 1 add dup 20 eq { out (\n) writestring pop 0 } if } forall pop (10,) } if out exch writestring out (\n) writestring } def /merge % { /C exch def /squash exch def exch infile /in exch def (w) file /out exch def /toC false def % Copy comments up to the first blank line, % since this is the legal notice for the file. C { (/*) wl { rl pop dup () eq { pop exit } if wl } loop (*/) wl () wl (/* Pre-compiled initialization string for Ghostscript. */) wl (#include "stdpre.h") wl () wl (const byte gs_ccinit_string[] = {) wl /toC true def } { { rl pop dup wl () eq { exit } if } loop } ifelse in mergefile C { /toC false def (10};) wl (const uint gs_ccinit_string_sizeof = sizeof\(gs_ccinit_string\);) wl } if out closefile } def /strip % strip { { ( ) anchorsearch { pop } { (\t) anchorsearch { pop } { exit } ifelse } ifelse } loop } def /doit % -> true | false { % We use loop and exit to avoid deeply nested conditionals. { squash not { true exit } if strip dup () eq { pop false exit } if dup (%END) anchorsearch { pop pop true exit } if pop (%) anchorsearch { pop pop false exit } if dup (%) search { exch pop exch (\)) search { pop pop pop } { pop exch } ifelse } if pop true exit } loop } def /mergefile % { /in exch def { rl not { pop exit } if (%% Replace ) anchorsearch { pop in exch token pop % # of lines exch token pop exch pop % file name or list name exch { rl pop pop } repeat exec dup type /stringtype eq { [ exch ] } if { infile mergefile } forall /in exch def } { doit { wl } if } ifelse } loop in closefile } def % If the program was invoked from the command line, run it now. % The various invocation methods are: % mergeini.ps % -sCfile= mergeini.ps % -- mergeini.ps % -sCfile= -- mergeini.ps [ shellarguments { counttomark dup 2 eq { pop true false } { 1 eq /Cfile where { pop true } { false } ifelse and { Cfile true true } { cleartomark (Usage: gs [-sCfile=] mergeini.ps\n) print ( or: gs -sCfile= -- mergeini.ps \n) print ( or: gs -- mergeini.ps \n) print flush quit } ifelse } ifelse } { /Cfile where { pop (gs_init.ps) Cfile true true } { (gs_init.ps) (gs_xinit.ps) true false } ifelse } ifelse (Merging ) print 3 index print ( to ) print 2 index print ( ... ) print flush merge pop (Done.\n) print flush quit