home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
swCHIP 1991 January
/
swCHIP_95-1.bin
/
utility
/
gs333ini
/
gs3.33
/
mergeini.ps
< prev
next >
Wrap
Text File
|
1995-12-09
|
4KB
|
160 lines
% 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 % <in_name> <out_name> <squash> <C>
{ /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 % <string> strip <string>
{ { ( ) anchorsearch
{ pop }
{ (\t) anchorsearch { pop } { exit } ifelse }
ifelse
}
loop
} def
/doit % <string> -> <string> 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_file>
{ /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=<C-file> mergeini.ps
% -- mergeini.ps <orig-init-file> <merged-init-file>
% -sCfile=<C-file> -- mergeini.ps <orig-init-file>
[ shellarguments
{ counttomark dup 2 eq
{ pop true false
}
{ 1 eq /Cfile where { pop true } { false } ifelse and
{ Cfile true true
}
{ cleartomark
(Usage: gs [-sCfile=<C-file>] mergeini.ps\n) print
( or: gs -sCfile=<C-file> -- mergeini.ps <orig-init-file>\n) print
( or: gs -- mergeini.ps <orig-init-file> <merged-init-file>\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