% Copyright (C) 1989-2004 artofcode LLC. All rights reserved.% % This software is provided AS-IS with no warranty, either express or% implied.% % This software is distributed under license and may not be copied,% modified or distributed except as expressly authorized under the terms% of the license contained in the file LICENSE in this distribution.% % For more information about licensing, please refer to% http://www.ghostscript.com/licensing/. For information on% commercial licensing, go to http://www.artifex.com/licensing/ or% contact Artifex Software, Inc., 101 Lucas Valley Road #110,% San Rafael, CA 94903, U.S.A., +1(415)492-9861. % $Id: gs_init.ps,v 1.120 2005/10/07 19:46:35 ray Exp $% Initialization file for the interpreter.% When this is run, systemdict is still writable. % Comment lines of the form% %% Replace <n> <file(s)>% indicate places where the next <n> lines should be replaced by% the contents of <file(s)>, when creating a single merged init file. % The interpreter can call out to PostScript code. All procedures% called in this way, and no other procedures defined in these% initialization files, have names that begin with %, e.g.,% (%Type1BuildChar) cvn. % Check the interpreter revision. NOTE: the interpreter code requires% that the first non-comment token in this file be an integer.853dup revision ne { (gs: Interpreter revision \() print revision 10 string cvs print (\) does not match gs_init.ps revision \() print 10 string cvs print (\).\n) print flush //null 1 .quit }if pop % Acquire userdict, and set its length if necessary./userdict where { pop userdict maxlength 0 eq } { true }ifelsesystemdict exch { % userdict wasn't already set up by iinit.c. dup /userdict currentdict dup 200 .setmaxlength % userdict .forceput % userdict is local, systemdict is global }if begin % Define dummy local/global operators if needed.systemdict /.setglobal known { true .setglobal } { /.setglobal { pop } bind def /.currentglobal { false } bind def /.gcheck { pop false } bind def }ifelse % Define .languagelevel if needed.systemdict /.languagelevel known not { /.languagelevel 1 def } if % Optionally choose a default paper size other than U.S. letter.% The default page size for many devices is set at compile time to % letter, but this can be changed to A4 although this is rarely done. % Some devices such as bbox have a different default page size,% and should not be set to A4 or letter.% When ghostscript is used in countries that use the international% standard page size A4 rather than US letter, the page size of % devices that default to letter or A4 can be changed by setting% DEFAULTPAPERSIZE.% /DEFAULTPAPERSIZE (a4) def % Turn on array packing for the rest of initialization.true setpacking % Define the old MS-DOS EOF character as a no-op.% This is a hack to get around the absurd habit of MS-DOS editors% of adding an EOF character at the end of the file.<1a> cvn { } def % Acquire the debugging flags.currentdict /DEBUG known /DEBUG exch def % if DEBUG is set, set ALL of the subset debugging flagsmark % '[' isn't defined yet /CCFONTDEBUG % Compiled Fonts /CFFDEBUG % CFF Fonts /CMAPDEBUG % CMAP /DOCIEDEBUG % CIE color /EPSDEBUG % EPS handling /FAPIDEBUG % Font API /INITDEBUG % Initialization /PDFDEBUG % PDF Interpreter /PDFOPTDEBUG % PDF Optimizer (Linearizer) /PDFWRDEBUG % PDF Writer /SETPDDEBUG % setpagedevice /STRESDEBUG % Static Resources /TTFDEBUG % TTF Fonts /VGIFDEBUG % ViewGIF /VJPGDEBUG % ViewJPEG /RESMPDEBUG % Resource mapcounttomark array astore exch pop % ']' isn't defined yet{ dup currentdict exch known DEBUG or def } forall currentdict /PDFSTEP known /PDFSTEP exch def% if PDFSTEP is on, turn on PDFDEBUGPDFSTEP { /PDFDEBUG true def } if /VMDEBUG INITDEBUG {{print mark systemdict /level2dict known { .currentglobal dup false .setglobal vmstatus true .setglobal vmstatus 3 -1 roll pop 6 -2 roll pop .setglobal } { vmstatus 3 -1 roll pop } ifelse usertime 16#fffff and counttomark { ( ) print ( ) cvs print } repeat pop ( ) print systemdict length ( ) cvs print ( ) print countdictstack ( ) cvs print ( <) print count ( ) cvs print (>\n) print flush }} {{pop }} ifelse def currentdict /BATCH known /BATCH exch defcurrentdict /DELAYBIND known /DELAYBIND exch defcurrentdict /DISKFONTS known /DISKFONTS exch defcurrentdict /DOINTERPOLATE .knownget { /INTERPOLATE exch def } ifcurrentdict /ESTACKPRINT known /ESTACKPRINT exch defcurrentdict /FAKEFONTS known /FAKEFONTS exch defcurrentdict /FIXEDMEDIA known /FIXEDMEDIA exch defcurrentdict /FIXEDRESOLUTION known /FIXEDRESOLUTION exch defcurrentdict /LOCALFONTS known /LOCALFONTS exch defcurrentdict /JOBSERVER known /JOBSERVER exch defcurrentdict /NOBIND known /NOBIND exch def/.bind /bind load defNOBIND { /bind { } def } ifcurrentdict /NOCACHE known /NOCACHE exch defcurrentdict /NOCCFONTS known /NOCCFONTS exch defcurrentdict /NOCIE known /NOCIE exch defcurrentdict /NOPSICC known /NOPSICC exch defcurrentdict /NODISPLAY known not /DISPLAYING exch defcurrentdict /NOFONTMAP known /NOFONTMAP exch defcurrentdict /NOFONTPATH known /NOFONTPATH exch defcurrentdict /NOGC known /NOGC exch defcurrentdict /NOINTERPOLATE .knownget { /INTERPOLATE exch not def } ifcurrentdict /NOOUTERSAVE known /NOOUTERSAVE exch defcurrentdict /NOPAGEPROMPT known /NOPAGEPROMPT exch defcurrentdict /NOPAUSE known /NOPAUSE exch defcurrentdict /NOPLATFONTS known /NOPLATFONTS exch defcurrentdict /NOPROMPT known /NOPROMPT exch defcurrentdict /NOTRANSPARENCY known /NOTRANSPARENCY exch defcurrentdict /DOPS known /DOPS exch defcurrentdict /NOSUBSTDEVICECOLORS known /NOSUBSTDEVICECOLORS exch def% The default value of ORIENT1 is true, not false.currentdict /ORIENT1 known not { /ORIENT1 true def } ifcurrentdict /OSTACKPRINT known /OSTACKPRINT exch defcurrentdict /OUTPUTFILE known % obsolete { /OutputFile /OUTPUTFILE load def currentdict /OUTPUTFILE .undef } ifcurrentdict /QUIET known /QUIET exch def% DELAYSAFER is effectively the same as newer NOSAFERcurrentdict /DELAYSAFER known { /DELAYSAFER true def /NOSAFER true def } if/SAFER currentdict /NOSAFER known { false} { currentdict /SAFER known currentdict /PARANOIDSAFER known or % PARANOIDSAFER is equivalent}ifelse defcurrentdict /SHORTERRORS known /SHORTERRORS exch defcurrentdict /STRICT known /STRICT exch defcurrentdict /TTYPAUSE known /TTYPAUSE exch defcurrentdict /WRITESYSTEMDICT known /WRITESYSTEMDICT exch def % Acquire environment variables.currentdict /DEVICE known not { (GS_DEVICE) getenv { /DEVICE exch def } if } if (START) VMDEBUG % Open the standard files, so they will be open at the outermost save level.(%stdin) (r) file pop(%stdout) (w) file pop(%stderr) (w) file pop /.currentuserparams where { pop mark % The Adobe implementations appear to have very large maximum % stack sizes. This turns out to actually make a difference, % since some badly-behaved files include extremely long procedures, % or construct huge arrays on the operand stack. % We reset the stack sizes now so that we don't have to worry % about overflowing the (rather small) built-in stack sizes % during initialization. /MaxDictStack 500 /MaxExecStack 5000 /MaxOpStack 50000 .dicttomark .setuserparams} if % Define a procedure for skipping over an unneeded section of code.% This avoids allocating space for the skipped procedures.% We can't use readline, because that imposes a line length limit./.skipeof % <string> .skipeof - { currentfile exch 1 exch .subfiledecode flushfile } .bind def % Define procedures to assist users who don't read the documentation.userdict begin/help { (Enter PostScript commands. '(filename) run' runs a file, 'quit' exits.\n) print flush } .bind defend % Define =string, which is used by some PostScript programs even though% it isn't documented anywhere.% Put it in userdict so that each context can have its own copy.userdict /=string 256 string put % Print the greeting. /printgreeting { mark product (Ghostscript) search { pop pop pop (This software comes with NO WARRANTY: see the file PUBLIC for details.\n) } { pop } ifelse (\n) copyright (\)\n) revisiondate 10 mod revisiondate 10 idiv 10 mod (-) revisiondate 100 idiv 10 mod revisiondate 1000 idiv 10 mod (-) revisiondate 10000 idiv ( \() revision 10 mod revision 100 mod 10 idiv (.) revision 100 idiv ( ) product counttomark { (%stdout) (w) file exch 0 .writecvp } repeat pop } .bind def QUIET not { printgreeting flush } if % Define a special version of def for making operator procedures./obind { % <name> <proc> obind <name> <oper> 1 index exch .makeoperator} .bind def/odef { % <name> <proc> odef - 1 index exch .makeoperator def} .bind def % Define a special version of def for storing local objects into global% dictionaries. Like .forceput, this exists only during initialization./.forcedef { % <key> <value> .forcedef - currentdict 3 1 roll .forceput} .bind odef % Define procedures for accessing variables in systemdict and userdict% regardless of the contents of the dictionary stack./.systemvar { % <name> .systemvar <value> //systemdict exch get} .bind odef/.userdict { % - .userdict <dict> /userdict .systemvar} .bind odef/.uservar { % <name> .uservar <value> .userdict exch get} .bind odef % If we're delaying binding, remember everything that needs to be bound later.DELAYBIND NOBIND not and { .currentglobal false .setglobal systemdict /.delaybind 1500 array .forceput .setglobal userdict /.delaycount 0 put % When we've done the delayed bind, we want to stop saving. % Detect this by the disappearance of .delaybind. /bind { /.delaybind .systemvar dup length 0 ne { .delaycount 2 index put .userdict /.delaycount .delaycount 1 add put } { pop /.bind cvx exec } ifelse } .bind def } if %**************** BACKWARD COMPATIBILITY ****************/hwsizedict mark /HWSize //null .dicttomark readonly def/copyscanlines { % <device> <y> <string> copyscanlines <substr> 0 3 1 roll 3 index //hwsizedict .getdeviceparams exch pop exch pop aload pop 3 2 roll 0 exch //null exch .getbitsrect exch pop} bind odefcurrentdict /hwsizedict .undef/getdeviceprops { //null .getdeviceparams } bind odef/.putdeviceprops { //null true counttomark 1 add 3 roll .putdeviceparams dup type /booleantype ne { dup mark eq { /unknown /rangecheck } if counttomark 4 add 1 roll cleartomark pop pop pop /.putdeviceprops load exch signalerror } if } bind odef/.currentfilladjust { .currentfilladjust2 pop } bind odef/.setfilladjust { dup .setfilladjust2 } bind odef/.writecvs { 0 .writecvp } bind odef%**************** DEPRECATED PROCEDURES ****************%**************** DO NOT USE THESE IN NEW CODE ****************/max { .max } bind def % use .max instead/min { .min } bind def % use .min instead/unread /.unread load def % use .peekstring instead%**************** END OF BACKWARD COMPATIBILITY SECTION **************** % Utility procedure to sort an array% <array> <lt-proc> .sort <array>/.sort { 1 index length 1 sub -1 1 { 2 index exch 2 copy get 3 copy % arr proc arr i arr[i] arr i arr[i] 0 1 3 index 1 sub { 3 index 1 index get % arr proc arr i arr[i] arr imax amax j arr[j] 2 index 1 index 10 index exec { % ... amax < arr[j] 4 2 roll } if pop pop } for % arr proc arr i arr[i] arr imax amax 4 -1 roll exch 4 1 roll put put } for pop} bind def % Utility for removing all entries from a dictionary/.PurgeDict % <dict> .PurgeDict -{ { true 1 index { pop exch pop false exit } forall { exit } if 1 index exch undef } loop pop} bind def % Define predefined procedures substituting for operators,% in alphabetical order. userdict /#copies 1 put% Adobe implementations don't accept /[ or /], so we don't either.([) cvn /mark load def(]) cvn {counttomark array astore exch pop} odef% .beginpage is redefined if setpagedevice is present./.beginpage { } odef% In LanguageLevel 3, copypage erases the page./copypage { .languagelevel 3 ge dup { 0 } { 1 } ifelse .endpage { .currentnumcopies 1 index .outputpage (>>copypage, press <return> to continue<<\n) .confirm dup { erasepage } if } if pop systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if .beginpage} odef/currentmatrix { .currentmatrix 6 index astore pop} odef% .currentnumcopies is redefined in Level 2./.currentnumcopies { #copies } odef/setcolorscreen where { pop % not in all Level 1 configurations /currentcolorscreen { .currenthalftone { { 60 exch 0 exch 3 copy 6 copy } % halftone - not possible { 3 copy 6 copy } % screen { } % colorscreen } exch get exec } odef} if/currentscreen { .currenthalftone { { 60 exch 0 exch } % halftone - not possible { } % screen { 12 3 roll 9 { pop } repeat } % colorscreen } exch get exec } odef/.echo /echo load defuserdict /.echo.mode true put/echo {dup /.echo.mode exch store .echo} odef/.eexec_param_dict mark /eexec true /seed 55665.dicttomark readonly def/eexec { % Rebind .currentresourcefile if it is the source for the eexec. dup //.eexec_param_dict //filterdict /eexecDecode get exec cvx exch .currentresourcefile eq //systemdict begin { {exec} .execasresource } { exec } ifelse % Only pop systemdict if it is still the top element, % because this is apparently what Adobe interpreters do. currentdict //systemdict eq { end } if} odef% .endpage is redefined if setpagedevice is present./.endpage { 2 ne } odef% erasepage mustn't use gsave/grestore, because we call it before% the graphics state stack has been fully initialized./erasepage { /currentcolor where { pop currentcolor currentcolorspace { setcolorspace setcolor } } { /currentcmykcolor where { pop currentcmykcolor { setcmykcolor } } { currentrgbcolor { setrgbcolor } } ifelse } ifelse currentoverprint false setoverprint 1 setgray .fillpage setoverprint exec } odef% To satisfy the Genoa FTS, executive must be a procedure, not an operator./executive { { prompt { (%statementedit) (r) file } stopped { pop pop $error /errorname get /undefinedfilename eq { .clearerror exit } if % EOF /handleerror .systemvar exec //null % ioerror?? } if cvx { .runexec } execute } loop } bind def/filter { //filterdict 1 index .knownget { exch pop exec } { /filter load /undefined signalerror } ifelse } odef% handleerror procedure as mentioned in the "Operators" section of the PLRM Section 8.2% This invokes the handleerror procedure from errordict (unless we are running under a% JOBSERVER where we want to always use a defined error handler (many error handlers in% 'wild' PostScript files are broken and don't indicate the error in any useful fashion).%% We run the handleerror procedure using .internalstopped so that broken error handlers% won't cause nested errors (Unexpected Error conditions)./handleerror JOBSERVER { { /errordict .systemvar /.GShandleerror get .internalstopped pop } bind % always use .GShandleerror. } { { /errordict .systemvar /handleerror get .internalstopped pop } bind % PLRM standard errorhandling } ifelse def/identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def/identmatrix { dup 0 //identmatrix putinterval } odef/languagelevel 1 def % gs_lev2.ps may change this/makeimagedevice { false makewordimagedevice } odef/matrix { 6 array identmatrix } odef/pathbbox { false .pathbbox } odef% .promptmsg is redefined if the interpreter includes readline support./.promptmsg { (GS) print count 0 ne { (<) print count =only } if (>) print flush} bind def/prompt { flush flushpage NOPROMPT not { .promptmsg } if } bind def/pstack { 0 1 count 3 sub { index == } for } bind def/putdeviceprops { .putdeviceprops { erasepage } if } odef/quit { /quit load 0 .quit } odef/run { dup type /filetype ne { (r) file } if % We must close the file when execution terminates, % regardless of the state of the stack, % and then propagate an error, if any. cvx .runexec } odef% Execute a file.% Level 2 uses 2 .stop to clear the e-stack for a successful startjob:% we detect that here, since we need to handle this even if we start out% without job control in effect.%% What we push on the e-stack is the following to be executed in this order:% <lit-file|fileproc> .runexec1 <lit-file|fileproc> .runexec2Lines 1–500 of 2243. Load more
% Copyright (C) 1989-2004 artofcode LLC. All rights reserved. % % This software is provided AS-IS with no warranty, either express or % implied. % % This software is distributed under license and may not be copied, % modified or distributed except as expressly authorized under the terms % of the license contained in the file LICENSE in this distribution. % % For more information about licensing, please refer to % http://www.ghostscript.com/licensing/. For information on % commercial licensing, go to http://www.artifex.com/licensing/ or % contact Artifex Software, Inc., 101 Lucas Valley Road #110, % San Rafael, CA 94903, U.S.A., +1(415)492-9861. % $Id: gs_init.ps,v 1.120 2005/10/07 19:46:35 ray Exp $ % Initialization file for the interpreter. % When this is run, systemdict is still writable. % Comment lines of the form % %% Replace <n> <file(s)> % indicate places where the next <n> lines should be replaced by % the contents of <file(s)>, when creating a single merged init file. % The interpreter can call out to PostScript code. All procedures % called in this way, and no other procedures defined in these % initialization files, have names that begin with %, e.g., % (%Type1BuildChar) cvn. % Check the interpreter revision. NOTE: the interpreter code requires % that the first non-comment token in this file be an integer. 853 dup revision ne { (gs: Interpreter revision \() print revision 10 string cvs print (\) does not match gs_init.ps revision \() print 10 string cvs print (\).\n) print flush //null 1 .quit } if pop % Acquire userdict, and set its length if necessary. /userdict where { pop userdict maxlength 0 eq } { true } ifelse systemdict exch { % userdict wasn't already set up by iinit.c. dup /userdict currentdict dup 200 .setmaxlength % userdict .forceput % userdict is local, systemdict is global } if begin % Define dummy local/global operators if needed. systemdict /.setglobal known { true .setglobal } { /.setglobal { pop } bind def /.currentglobal { false } bind def /.gcheck { pop false } bind def } ifelse % Define .languagelevel if needed. systemdict /.languagelevel known not { /.languagelevel 1 def } if % Optionally choose a default paper size other than U.S. letter. % The default page size for many devices is set at compile time to % letter, but this can be changed to A4 although this is rarely done. % Some devices such as bbox have a different default page size, % and should not be set to A4 or letter. % When ghostscript is used in countries that use the international % standard page size A4 rather than US letter, the page size of % devices that default to letter or A4 can be changed by setting % DEFAULTPAPERSIZE. % /DEFAULTPAPERSIZE (a4) def % Turn on array packing for the rest of initialization. true setpacking % Define the old MS-DOS EOF character as a no-op. % This is a hack to get around the absurd habit of MS-DOS editors % of adding an EOF character at the end of the file. <1a> cvn { } def % Acquire the debugging flags. currentdict /DEBUG known /DEBUG exch def % if DEBUG is set, set ALL of the subset debugging flags mark % '[' isn't defined yet /CCFONTDEBUG % Compiled Fonts /CFFDEBUG % CFF Fonts /CMAPDEBUG % CMAP /DOCIEDEBUG % CIE color /EPSDEBUG % EPS handling /FAPIDEBUG % Font API /INITDEBUG % Initialization /PDFDEBUG % PDF Interpreter /PDFOPTDEBUG % PDF Optimizer (Linearizer) /PDFWRDEBUG % PDF Writer /SETPDDEBUG % setpagedevice /STRESDEBUG % Static Resources /TTFDEBUG % TTF Fonts /VGIFDEBUG % ViewGIF /VJPGDEBUG % ViewJPEG /RESMPDEBUG % Resource map counttomark array astore exch pop % ']' isn't defined yet { dup currentdict exch known DEBUG or def } forall currentdict /PDFSTEP known /PDFSTEP exch def % if PDFSTEP is on, turn on PDFDEBUG PDFSTEP { /PDFDEBUG true def } if /VMDEBUG INITDEBUG {{print mark systemdict /level2dict known { .currentglobal dup false .setglobal vmstatus true .setglobal vmstatus 3 -1 roll pop 6 -2 roll pop .setglobal } { vmstatus 3 -1 roll pop } ifelse usertime 16#fffff and counttomark { ( ) print ( ) cvs print } repeat pop ( ) print systemdict length ( ) cvs print ( ) print countdictstack ( ) cvs print ( <) print count ( ) cvs print (>\n) print flush }} {{pop }} ifelse def currentdict /BATCH known /BATCH exch def currentdict /DELAYBIND known /DELAYBIND exch def currentdict /DISKFONTS known /DISKFONTS exch def currentdict /DOINTERPOLATE .knownget { /INTERPOLATE exch def } if currentdict /ESTACKPRINT known /ESTACKPRINT exch def currentdict /FAKEFONTS known /FAKEFONTS exch def currentdict /FIXEDMEDIA known /FIXEDMEDIA exch def currentdict /FIXEDRESOLUTION known /FIXEDRESOLUTION exch def currentdict /LOCALFONTS known /LOCALFONTS exch def currentdict /JOBSERVER known /JOBSERVER exch def currentdict /NOBIND known /NOBIND exch def /.bind /bind load def NOBIND { /bind { } def } if currentdict /NOCACHE known /NOCACHE exch def currentdict /NOCCFONTS known /NOCCFONTS exch def currentdict /NOCIE known /NOCIE exch def currentdict /NOPSICC known /NOPSICC exch def currentdict /NODISPLAY known not /DISPLAYING exch def currentdict /NOFONTMAP known /NOFONTMAP exch def currentdict /NOFONTPATH known /NOFONTPATH exch def currentdict /NOGC known /NOGC exch def currentdict /NOINTERPOLATE .knownget { /INTERPOLATE exch not def } if currentdict /NOOUTERSAVE known /NOOUTERSAVE exch def currentdict /NOPAGEPROMPT known /NOPAGEPROMPT exch def currentdict /NOPAUSE known /NOPAUSE exch def currentdict /NOPLATFONTS known /NOPLATFONTS exch def currentdict /NOPROMPT known /NOPROMPT exch def currentdict /NOTRANSPARENCY known /NOTRANSPARENCY exch def currentdict /DOPS known /DOPS exch def currentdict /NOSUBSTDEVICECOLORS known /NOSUBSTDEVICECOLORS exch def % The default value of ORIENT1 is true, not false. currentdict /ORIENT1 known not { /ORIENT1 true def } if currentdict /OSTACKPRINT known /OSTACKPRINT exch def currentdict /OUTPUTFILE known % obsolete { /OutputFile /OUTPUTFILE load def currentdict /OUTPUTFILE .undef } if currentdict /QUIET known /QUIET exch def % DELAYSAFER is effectively the same as newer NOSAFER currentdict /DELAYSAFER known { /DELAYSAFER true def /NOSAFER true def } if /SAFER currentdict /NOSAFER known { false } { currentdict /SAFER known currentdict /PARANOIDSAFER known or % PARANOIDSAFER is equivalent } ifelse def currentdict /SHORTERRORS known /SHORTERRORS exch def currentdict /STRICT known /STRICT exch def currentdict /TTYPAUSE known /TTYPAUSE exch def currentdict /WRITESYSTEMDICT known /WRITESYSTEMDICT exch def % Acquire environment variables. currentdict /DEVICE known not { (GS_DEVICE) getenv { /DEVICE exch def } if } if (START) VMDEBUG % Open the standard files, so they will be open at the outermost save level. (%stdin) (r) file pop (%stdout) (w) file pop (%stderr) (w) file pop /.currentuserparams where { pop mark % The Adobe implementations appear to have very large maximum % stack sizes. This turns out to actually make a difference, % since some badly-behaved files include extremely long procedures, % or construct huge arrays on the operand stack. % We reset the stack sizes now so that we don't have to worry % about overflowing the (rather small) built-in stack sizes % during initialization. /MaxDictStack 500 /MaxExecStack 5000 /MaxOpStack 50000 .dicttomark .setuserparams } if % Define a procedure for skipping over an unneeded section of code. % This avoids allocating space for the skipped procedures. % We can't use readline, because that imposes a line length limit. /.skipeof % <string> .skipeof - { currentfile exch 1 exch .subfiledecode flushfile } .bind def % Define procedures to assist users who don't read the documentation. userdict begin /help { (Enter PostScript commands. '(filename) run' runs a file, 'quit' exits.\n) print flush } .bind def end % Define =string, which is used by some PostScript programs even though % it isn't documented anywhere. % Put it in userdict so that each context can have its own copy. userdict /=string 256 string put % Print the greeting. /printgreeting { mark product (Ghostscript) search { pop pop pop (This software comes with NO WARRANTY: see the file PUBLIC for details.\n) } { pop } ifelse (\n) copyright (\)\n) revisiondate 10 mod revisiondate 10 idiv 10 mod (-) revisiondate 100 idiv 10 mod revisiondate 1000 idiv 10 mod (-) revisiondate 10000 idiv ( \() revision 10 mod revision 100 mod 10 idiv (.) revision 100 idiv ( ) product counttomark { (%stdout) (w) file exch 0 .writecvp } repeat pop } .bind def QUIET not { printgreeting flush } if % Define a special version of def for making operator procedures. /obind { % <name> <proc> obind <name> <oper> 1 index exch .makeoperator } .bind def /odef { % <name> <proc> odef - 1 index exch .makeoperator def } .bind def % Define a special version of def for storing local objects into global % dictionaries. Like .forceput, this exists only during initialization. /.forcedef { % <key> <value> .forcedef - currentdict 3 1 roll .forceput } .bind odef % Define procedures for accessing variables in systemdict and userdict % regardless of the contents of the dictionary stack. /.systemvar { % <name> .systemvar <value> //systemdict exch get } .bind odef /.userdict { % - .userdict <dict> /userdict .systemvar } .bind odef /.uservar { % <name> .uservar <value> .userdict exch get } .bind odef % If we're delaying binding, remember everything that needs to be bound later. DELAYBIND NOBIND not and { .currentglobal false .setglobal systemdict /.delaybind 1500 array .forceput .setglobal userdict /.delaycount 0 put % When we've done the delayed bind, we want to stop saving. % Detect this by the disappearance of .delaybind. /bind { /.delaybind .systemvar dup length 0 ne { .delaycount 2 index put .userdict /.delaycount .delaycount 1 add put } { pop /.bind cvx exec } ifelse } .bind def } if %**************** BACKWARD COMPATIBILITY **************** /hwsizedict mark /HWSize //null .dicttomark readonly def /copyscanlines { % <device> <y> <string> copyscanlines <substr> 0 3 1 roll 3 index //hwsizedict .getdeviceparams exch pop exch pop aload pop 3 2 roll 0 exch //null exch .getbitsrect exch pop } bind odef currentdict /hwsizedict .undef /getdeviceprops { //null .getdeviceparams } bind odef /.putdeviceprops { //null true counttomark 1 add 3 roll .putdeviceparams dup type /booleantype ne { dup mark eq { /unknown /rangecheck } if counttomark 4 add 1 roll cleartomark pop pop pop /.putdeviceprops load exch signalerror } if } bind odef /.currentfilladjust { .currentfilladjust2 pop } bind odef /.setfilladjust { dup .setfilladjust2 } bind odef /.writecvs { 0 .writecvp } bind odef %**************** DEPRECATED PROCEDURES **************** %**************** DO NOT USE THESE IN NEW CODE **************** /max { .max } bind def % use .max instead /min { .min } bind def % use .min instead /unread /.unread load def % use .peekstring instead %**************** END OF BACKWARD COMPATIBILITY SECTION **************** % Utility procedure to sort an array % <array> <lt-proc> .sort <array> /.sort { 1 index length 1 sub -1 1 { 2 index exch 2 copy get 3 copy % arr proc arr i arr[i] arr i arr[i] 0 1 3 index 1 sub { 3 index 1 index get % arr proc arr i arr[i] arr imax amax j arr[j] 2 index 1 index 10 index exec { % ... amax < arr[j] 4 2 roll } if pop pop } for % arr proc arr i arr[i] arr imax amax 4 -1 roll exch 4 1 roll put put } for pop } bind def % Utility for removing all entries from a dictionary /.PurgeDict % <dict> .PurgeDict - { { true 1 index { pop exch pop false exit } forall { exit } if 1 index exch undef } loop pop } bind def % Define predefined procedures substituting for operators, % in alphabetical order. userdict /#copies 1 put % Adobe implementations don't accept /[ or /], so we don't either. ([) cvn /mark load def (]) cvn {counttomark array astore exch pop} odef % .beginpage is redefined if setpagedevice is present. /.beginpage { } odef % In LanguageLevel 3, copypage erases the page. /copypage { .languagelevel 3 ge dup { 0 } { 1 } ifelse .endpage { .currentnumcopies 1 index .outputpage (>>copypage, press <return> to continue<<\n) .confirm dup { erasepage } if } if pop systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if .beginpage } odef /currentmatrix { .currentmatrix 6 index astore pop } odef % .currentnumcopies is redefined in Level 2. /.currentnumcopies { #copies } odef /setcolorscreen where { pop % not in all Level 1 configurations /currentcolorscreen { .currenthalftone { { 60 exch 0 exch 3 copy 6 copy } % halftone - not possible { 3 copy 6 copy } % screen { } % colorscreen } exch get exec } odef } if /currentscreen { .currenthalftone { { 60 exch 0 exch } % halftone - not possible { } % screen { 12 3 roll 9 { pop } repeat } % colorscreen } exch get exec } odef /.echo /echo load def userdict /.echo.mode true put /echo {dup /.echo.mode exch store .echo} odef /.eexec_param_dict mark /eexec true /seed 55665 .dicttomark readonly def /eexec { % Rebind .currentresourcefile if it is the source for the eexec. dup //.eexec_param_dict //filterdict /eexecDecode get exec cvx exch .currentresourcefile eq //systemdict begin { {exec} .execasresource } { exec } ifelse % Only pop systemdict if it is still the top element, % because this is apparently what Adobe interpreters do. currentdict //systemdict eq { end } if } odef % .endpage is redefined if setpagedevice is present. /.endpage { 2 ne } odef % erasepage mustn't use gsave/grestore, because we call it before % the graphics state stack has been fully initialized. /erasepage { /currentcolor where { pop currentcolor currentcolorspace { setcolorspace setcolor } } { /currentcmykcolor where { pop currentcmykcolor { setcmykcolor } } { currentrgbcolor { setrgbcolor } } ifelse } ifelse currentoverprint false setoverprint 1 setgray .fillpage setoverprint exec } odef % To satisfy the Genoa FTS, executive must be a procedure, not an operator. /executive { { prompt { (%statementedit) (r) file } stopped { pop pop $error /errorname get /undefinedfilename eq { .clearerror exit } if % EOF /handleerror .systemvar exec //null % ioerror?? } if cvx { .runexec } execute } loop } bind def /filter { //filterdict 1 index .knownget { exch pop exec } { /filter load /undefined signalerror } ifelse } odef % handleerror procedure as mentioned in the "Operators" section of the PLRM Section 8.2 % This invokes the handleerror procedure from errordict (unless we are running under a % JOBSERVER where we want to always use a defined error handler (many error handlers in % 'wild' PostScript files are broken and don't indicate the error in any useful fashion). % % We run the handleerror procedure using .internalstopped so that broken error handlers % won't cause nested errors (Unexpected Error conditions). /handleerror JOBSERVER { { /errordict .systemvar /.GShandleerror get .internalstopped pop } bind % always use .GShandleerror. } { { /errordict .systemvar /handleerror get .internalstopped pop } bind % PLRM standard errorhandling } ifelse def /identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def /identmatrix { dup 0 //identmatrix putinterval } odef /languagelevel 1 def % gs_lev2.ps may change this /makeimagedevice { false makewordimagedevice } odef /matrix { 6 array identmatrix } odef /pathbbox { false .pathbbox } odef % .promptmsg is redefined if the interpreter includes readline support. /.promptmsg { (GS) print count 0 ne { (<) print count =only } if (>) print flush } bind def /prompt { flush flushpage NOPROMPT not { .promptmsg } if } bind def /pstack { 0 1 count 3 sub { index == } for } bind def /putdeviceprops { .putdeviceprops { erasepage } if } odef /quit { /quit load 0 .quit } odef /run { dup type /filetype ne { (r) file } if % We must close the file when execution terminates, % regardless of the state of the stack, % and then propagate an error, if any. cvx .runexec } odef % Execute a file. % Level 2 uses 2 .stop to clear the e-stack for a successful startjob: % we detect that here, since we need to handle this even if we start out % without job control in effect. % % What we push on the e-stack is the following to be executed in this order: % <lit-file|fileproc> .runexec1 <lit-file|fileproc> .runexec2