summaryrefslogtreecommitdiff
path: root/Master/tlpkg/tlgs/Resource/Init/gs_init.ps
diff options
context:
space:
mode:
Diffstat (limited to 'Master/tlpkg/tlgs/Resource/Init/gs_init.ps')
-rw-r--r--Master/tlpkg/tlgs/Resource/Init/gs_init.ps764
1 files changed, 436 insertions, 328 deletions
diff --git a/Master/tlpkg/tlgs/Resource/Init/gs_init.ps b/Master/tlpkg/tlgs/Resource/Init/gs_init.ps
index d733124b96d..55a785eceed 100644
--- a/Master/tlpkg/tlgs/Resource/Init/gs_init.ps
+++ b/Master/tlpkg/tlgs/Resource/Init/gs_init.ps
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2018 Artifex Software, Inc.
+% Copyright (C) 2001-2019 Artifex Software, Inc.
% All Rights Reserved.
%
% This software is provided AS-IS with no warranty, either express or
@@ -34,7 +34,7 @@
% Interpreter library version number
% NOTE: the interpreter code requires that the first non-comment token
% in this file be an integer, and that it match the compiled-in version!
-926
+927
% Check the interpreter revision.
dup revision ne
@@ -54,18 +54,11 @@ systemdict exch
dup /userdict
currentdict dup 200 .setmaxlength % userdict
.forceput % userdict is local, systemdict is global
- }
+ } executeonly
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
+% Init to global memory (possibly not needed, but left in for legacy purposes)
+//true .setglobal
% Define .languagelevel if needed.
systemdict /.languagelevel known not { /.languagelevel 1 def } if
@@ -116,7 +109,7 @@ currentdict /PDFSTEP known /PDFSTEP exch def
PDFSTEP { /PDFDEBUG //true def } if
currentdict /PDFSTOPONERROR known /PDFSTOPONERROR exch def
-currentdict /PDFSTOPONWARNING known {/PDFSTOPONWARNING true def /PDFSTOPONERROR true def}{/PDFSTOPONWARNING false def} ifelse
+currentdict /PDFSTOPONWARNING known {/PDFSTOPONWARNING //true def /PDFSTOPONERROR //true def}{/PDFSTOPONWARNING //false def} ifelse
currentdict /PDFNOCIDFALLBACK known /PDFNOCIDFALLBACK exch def
/.bind /bind load def
@@ -147,7 +140,7 @@ currentdict /PDFNOCIDFALLBACK known /PDFNOCIDFALLBACK exch def
% ancient and no longer maintained piece of softare, did check
% its value unconditionally. So we retain this key in the dictionary
% purely for backward compatibility.
-/NOBIND false def
+/NOBIND //false def
currentdict /BATCH known /BATCH exch def
currentdict /DELAYBIND known /DELAYBIND exch def
@@ -212,12 +205,9 @@ currentdict /SCANCONVERTERTYPE known
currentdict /SCANCONVERTERTYPE get .setscanconverter
} if
-% We rely on PSFitPage to actually implement EPSFitPage
-% But we need EPSCrop to be true, to actually issue a PageSize request, so set it here
-% in case the user forgets.
-currentdict /EPSFitPage known { /PSFitPage //true def /EPSCrop //true def} if
+currentdict /EPSFitPage known { /PSFitPage //true def } if
% This is a "convenience" option that sets a combination of EPSFitPage, PDFFitPage and PSFitPage
-currentdict /FitPage known { /EPSFitPage //true def /EPSCrop //true def /PDFFitPage //true def /PSFitPage //true def } if
+currentdict /FitPage known { /EPSFitPage //true def /PDFFitPage //true def /PSFitPage //true def } if
% Acquire environment variables.
currentdict /DEVICE known not
@@ -271,7 +261,7 @@ userdict /=string 256 string put
{ mark
product (GPL Ghostscript) search
{ pop pop pop
- (This software comes with NO WARRANTY: see the file PUBLIC for details.\n)
+ (This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:\nsee the file COPYING for details.\n)
}
{ pop
}
@@ -289,7 +279,8 @@ userdict /=string 256 string put
} repeat pop
} .bind def
-QUIET not { printgreeting flush } if
+QUIET not { //printgreeting exec flush } if
+currentdict /printgreeting .undef
% Define a special version of def for making operator procedures.
/obind { % <name> <proc> obind <name> <oper>
@@ -299,27 +290,20 @@ QUIET not { printgreeting flush } if
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 -
- 1 .argindex pop % check # of args
- 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
+} .bind executeonly odef
/.systemexec {
.systemvar exec
-} .bind odef
+} .bind executeonly odef
/.userdict { % - .userdict <dict>
/userdict .systemvar
-} .bind odef
+} .bind executeonly odef
/.uservar { % <name> .uservar <value>
.userdict exch get
-} .bind odef
+} .bind executeonly odef
% If we're delaying binding, remember everything that needs to be bound later.
DELAYBIND
@@ -347,7 +331,7 @@ DELAYBIND
}
ifelse
} .bind def
-} if
+} executeonly if
%**************** BACKWARD COMPATIBILITY ****************
/hwsizedict mark /HWSize //null .dicttomark readonly def
@@ -360,6 +344,9 @@ currentdict /hwsizedict .undef
/getdeviceprops
{ //null .getdeviceparams
} bind odef
+
+% NOTE: Note sure why/if this needs to be a separate operator. Consider rolling this
+% implementation into /putdeviceprops ?
/.putdeviceprops
{ //null //true counttomark 1 add 3 roll .putdeviceparams
dup type /booleantype ne
@@ -368,15 +355,14 @@ currentdict /hwsizedict .undef
/.putdeviceprops .systemvar exch signalerror
}
if
- } bind odef
-/.currentfilladjust { .currentfilladjust2 pop } bind odef
-/.setfilladjust { dup .setfilladjust2 } bind odef
+ } bind executeonly odef
/.writecvs { 0 .writecvp } bind odef
+
%**************** DEPRECATED PROCEDURES ****************
%**************** DO NOT USE THESE IN NEW CODE ****************
+% Keeping these because they have been around a long time and we don't want to break old code that's out in the wild
/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 for removing all entries from a dictionary
@@ -400,19 +386,19 @@ userdict /#copies 1 put
/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 .doneshowpage {
- .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
+%
+% - initgraphics -
+%
+% Although the internal routine gs_initgraphics resets the color space,
+% it does not reset the color space we store in the 'interpreter'
+% graphics state (so that we can hand it back in currentcolorspace).
+% So we need to do that in the PostScript world.
+%
+%
+/initgraphics
+ { initgraphics systemdict /DeviceGray_array get setcolorspace }
+.bind executeonly odef
+
/currentmatrix {
dup type /arraytype ne
{ /currentmatrix load /typecheck signalerror } if
@@ -420,8 +406,52 @@ userdict /#copies 1 put
{ /currentmatrix load /rangecheck signalerror } if
.currentmatrix 6 .argindex astore pop
} odef
-% .currentnumcopies is redefined in Level 2.
-/.currentnumcopies { #copies } odef
+
+% We have to guard against the BeginPage procedure not popping its operand.
+% This is really stupid, but the Genoa CET does it.
+/.beginpage { % - .beginpage -
+ .currentshowpagecount {
+ .currentpagedevice pop
+ dup //null ne { /BeginPage .knownget } { pop //false } ifelse {
+ % Stack: ... pagecount proc
+ count 2 .execn
+ % Stack: ... ..???.. oldcount
+ count 1 add exch sub { pop } repeat
+ } {
+ pop
+ } ifelse
+ } if
+} .bind executeonly odef
+
+% Guard similarly against EndPage not popping its operand.
+/.endpage { % <reason> .endpage <print_bool>
+ .currentshowpagecount {
+ 1 index .currentpagedevice pop
+ dup //null ne { /EndPage .knownget } { pop //false } ifelse {
+ % Stack: ... reason pagecount reason proc
+ count 2 .execn
+ % Stack: ... ..???.. print oldcount
+ count 2 add exch sub { exch pop } repeat
+ } {
+ pop pop 2 ne
+ } ifelse
+ } {
+ 2 ne
+ } ifelse
+} .bind executeonly odef
+
+% Define .currentnumcopies so it consults the NumCopies device parameter.
+/.numcopiesdict mark
+ /NumCopies dup
+.dicttomark readonly def
+/.currentnumcopies
+ { currentdevice //.numcopiesdict .getdeviceparams
+ dup type /integertype eq
+ { exch pop exch pop }
+ { cleartomark #copies }
+ ifelse
+} .bind executeonly odef
+
/setcolorscreen where { pop % not in all Level 1 configurations
/currentcolorscreen
{ .currenthalftone
@@ -456,8 +486,6 @@ userdict /.echo.mode //true put
% 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
@@ -472,24 +500,48 @@ userdict /.echo.mode //true put
currentoverprint //false setoverprint 1 setgray .fillpage setoverprint
exec
} odef
+% Define a procedure for clearing the error indication.
+/.clearerror
+ { $error /newerror //false put
+ $error /errorname //null put
+ $error /errorinfo //null put
+ 0 .setoserrno
+ } bind executeonly def
+
% To satisfy the Genoa FTS, executive must be a procedure, not an operator.
+% Define the procedure used by .runfile, .runstdin and .runstring
+% for executing user input.
+% This is called with a procedure or executable file on the operand stack.
+/.execute { % <obj> .execute <stopped>
+ stopped $error /newerror get and
+ { /handleerror .systemvar exec flush //true } { //false } ifelse
+} bind def
+% Define an execute analogue of runlibfile0.
+/execute0 { % <obj> execute0 -
+ //.execute exec { /execute0 cvx 1 .quit } if
+} bind def
/executive
{ { prompt
{ (%statementedit) (r) .systemvmfile } stopped
{ pop pop $error /errorname get /undefinedfilename eq
- { .clearerror exit } if % EOF
+ { //.clearerror exec exit } if % EOF
/handleerror .systemvar exec //null % ioerror??
}
if
- cvx { .runexec } .execute pop
+ cvx { .runexec } //.execute exec pop
} loop
} bind def
+currentdict /.execute .undef
+
/filter
{ //filterdict 1 .argindex .knownget
{ exch pop exec }
{ /filter .systemvar /undefined signalerror }
ifelse
} odef
+% Internal uses of stopped that aren't going to do a stop if an error occurs
+% should use .internalstopped to avoid setting newerror et al.
+/.internalstopped { //null 1 .stopped //null ne } bind executeonly def
% 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
@@ -499,9 +551,9 @@ userdict /.echo.mode //true put
% won't cause nested errors (Unexpected Error conditions).
/handleerror
JOBSERVER {
- { /.GShandleerror .systemvar .internalstopped pop } bind % always use .GShandleerror.
+ { /.GShandleerror .systemvar //.internalstopped exec pop } bind % always use .GShandleerror.
} {
- { /errordict .systemvar /handleerror get .internalstopped pop } bind % PLRM standard errorhandling
+ { /errordict .systemvar /handleerror get //.internalstopped exec pop } bind % PLRM standard errorhandling
} ifelse def
/identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def
/identmatrix {
@@ -512,16 +564,18 @@ userdict /.echo.mode //true put
/languagelevel 1 def % gs_lev2.ps may change this
/makeimagedevice { //false makewordimagedevice } odef
/matrix { 6 array identmatrix } 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
+/prompt { flush flushpage NOPROMPT not { //.promptmsg exec} if } bind def
+currentdict /.promptmsg .undef
+
/pstack { 0 1 count 3 sub { index == } for } bind def
/putdeviceprops
- { .putdeviceprops { erasepage } if } odef
+ { .putdeviceprops { erasepage } if } bind executeonly odef
/quit { /quit load 0 .quit } odef
/run { dup type /filetype ne { (r) .systemvmfile } if
% We must close the file when execution terminates,
@@ -543,7 +597,7 @@ userdict /.echo.mode //true put
% startjob replaces the null on the o-stack with a procedure
% to be executed when we get back here.
dup //null ne { exec //true } { pop //false } ifelse
-} bind def
+} bind executeonly def
/.runexec2 { % <continue> <file|fileproc> .runexec2 -
exch {
.runexec
@@ -598,10 +652,48 @@ odef
dup length 6 ne { /setmatrix load /rangecheck signalerror } if
dup aload pop .setmatrix pop
} odef
+
+/.confirmread {
+ TTYPAUSE {
+ (/dev/tty) (r) file dup read pop pop closefile
+ } {
+ .echo.mode //false echo
+ (%stdin) (r) file dup read {
+ dup (\n) 0 get eq { pop pop } { .unread } ifelse
+ } {
+ pop
+ } ifelse echo
+ } ifelse
+} bind executeonly def
+
+/.confirm {
+ DISPLAYING NOPAUSE not TTYPAUSE or and {
+ % Print a message (unless NOPAGEPROMPT or NOPROMPT is true)
+ % and wait for the user to type something.
+ % If the user just types a newline, flush it.
+ NOPAGEPROMPT NOPROMPT or { pop } { print flush } ifelse
+ //.confirmread exec
+ } {
+ pop
+ } ifelse
+} bind executeonly def
+
+% In LanguageLevel 3, copypage erases the page.
+/copypage {
+ .languagelevel 3 ge
+ dup { 0 } { 1 } ifelse .endpage .doneshowpage {
+ .currentnumcopies 1 index .outputpage
+ (>>copypage, press <return> to continue<<\n) //.confirm exec
+ dup { erasepage } if
+ } if pop
+ systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if
+ .beginpage
+} .bind executeonly odef
+
/showpage {
0 .endpage .doneshowpage {
.currentnumcopies //true .outputpage
- (>>showpage, press <return> to continue<<\n) .confirm
+ (>>showpage, press <return> to continue<<\n) //.confirm exec
% Uncomment the following line, and use a Memento build to track
% blocks that are created and not destroyed between each successive
% page.
@@ -614,14 +706,12 @@ odef
{ initgraphics } ifelse
systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if
.beginpage
-} odef
+} .bind executeonly odef
+
% Code output by Adobe Illustrator relies on the fact that
% `stack' is a procedure, not an operator!!!
/stack { 0 1 count 3 sub { index = } for } bind def
/start { BATCH { //null 0 .quit } { executive } ifelse } def
-% Internal uses of stopped that aren't going to do a stop if an error occurs
-% should use .internalstopped to avoid setting newerror et al.
-/.internalstopped { //null 1 .stopped //null ne } bind def
/store { % Don't alter operands before completing.
1 .argindex where { 2 index 2 index put pop pop } { def } ifelse
} odef
@@ -642,8 +732,6 @@ currentdict /.typenames .undef
% internaldict is defined in systemdict, but the dictionary is allocated
% in local VM. However, the procedure must be global, since it is an
% "operator" and must be bind-able into global procedures.
-% We make a procedure for creating it, since we must create a new one
-% for each context with private local VM.
/.makeinternaldict {
.currentglobal //true .setglobal
[ /dup .systemvar 1183615869 /eq .systemvar
@@ -655,9 +743,10 @@ currentdict /.typenames .undef
/ifelse .systemvar
] cvx executeonly
exch .setglobal
-} odef
+} executeonly def
systemdict /internaldict dup .makeinternaldict .makeoperator
.forceput % proc is local, systemdict is global
+currentdict /.makeinternaldict .undef
% Define some additional built-in procedures (beyond the ones defined by
% the PostScript Language Reference Manual).
@@ -673,8 +762,6 @@ systemdict /internaldict dup .makeinternaldict .makeoperator
% Copy a dictionary per the Level 2 spec even in Level 1.
/.copydict % <fromdict> <todict> .copydict <todict>
{ dup 3 -1 roll { put dup } forall pop } bind def
-/copystring
- { dup length string copy } bind def
/findlibfile {
.systemvmlibfile { dup .filename pop exch //true } { //false } ifelse
} odef
@@ -682,11 +769,11 @@ systemdict /internaldict dup .makeinternaldict .makeoperator
{ length 3 mul 2 idiv 1 add
} bind def
/.growdict % grow a dictionary
- { dup .growdictlength .setmaxlength
+ { dup //.growdictlength exec .setmaxlength
} bind def
/.growput % put, grow the dictionary if needed
{ 2 index length 3 index maxlength eq
- { 3 copy pop known not { 2 index .growdict } if
+ { 3 copy pop known not { 2 index //.growdict exec} if
} if
put
} bind def
@@ -709,8 +796,6 @@ systemdict /internaldict dup .makeinternaldict .makeoperator
} ifelse
/.packtomark
{ counttomark packedarray exch pop } bind def
-/ppstack
- { 0 1 count 3 sub { index === } for } bind def
/runlibfile
{ % We don't want to bind 'run' into this procedure,
% since run may get redefined.
@@ -777,13 +862,13 @@ userdict /.currentresourcefile //null put
2 .execn % stopped <file>
.userdict /.currentresourcefile 3 -1 roll put
{ stop } if
-} bind def
+} bind executeonly def
/.runresource { % <file> .runresource -
{ /run .systemvar exec } .execasresource
} bind def
-% Define auxiliary procedures needed for the above.
-/shellarguments % -> shell_arguments true (or) false
+% Convenience function (documented extension)
+/.shellarguments % -> shell_arguments true (or) false
{ /ARGUMENTS where
{ /ARGUMENTS get dup type /arraytype eq
{ aload pop /ARGUMENTS //null store //true }
@@ -791,44 +876,7 @@ userdict /.currentresourcefile //null put
ifelse }
{ //false } ifelse
} bind def
-/.confirm {
- DISPLAYING NOPAUSE not TTYPAUSE or and {
- % Print a message (unless NOPAGEPROMPT or NOPROMPT is true)
- % and wait for the user to type something.
- % If the user just types a newline, flush it.
- NOPAGEPROMPT NOPROMPT or { pop } { print flush } ifelse
- .confirmread
- } {
- pop
- } ifelse
-} bind def
-/.confirmread {
- TTYPAUSE {
- (/dev/tty) (r) file dup read pop pop closefile
- } {
- .echo.mode //false echo
- (%stdin) (r) file dup read {
- dup (\n) 0 get eq { pop pop } { unread } ifelse
- } {
- pop
- } ifelse echo
- } ifelse
-} bind def
-% Define the procedure used by .runfile, .runstdin and .runstring
-% for executing user input.
-% This is called with a procedure or executable file on the operand stack.
-/.execute { % <obj> .execute <stopped>
- stopped $error /newerror get and
- { /handleerror .systemvar exec flush //true } { //false } ifelse
-} bind def
-/execute { % <obj> execute -
- .execute pop
-} odef
-% Define an execute analogue of runlibfile0.
-/execute0 { % <obj> execute0 -
- .execute { /execute0 cvx 1 .quit } if
-} bind def
% Define the procedure that the C code uses for running files
% named on the command line.
/.runfile {
@@ -884,7 +932,8 @@ def
} bind def
% Temporarily substitute it for the real runlibfile.
/.runlibfile /runlibfile load def
-/runlibfile /runlibfile0 load def
+/runlibfile //runlibfile0 def
+currentdict /runlibfile0 .undef
% Create the error handling machinery.
% Define the standard error handlers.
@@ -916,7 +965,7 @@ def
1 .instopped { //null eq { pop pop stop } if } if
(I) //false .setdebug
$error /.inerror get 1 .instopped { pop } { pop //true } ifelse
- { .unstoppederrorhandler
+ { //.unstoppederrorhandler exec
} if % detect error recursion
$error /globalmode .currentglobal //false .setglobal put
$error /.inerror //true put
@@ -940,12 +989,12 @@ def
}
ifelse
$error /position currentfile status
- { currentfile { fileposition } .internalstopped { pop //null } if
+ { currentfile { fileposition } //.internalstopped exec { pop //null } if
}
{ % If this was a scanner error, the file is no longer current,
% but the command holds the file, which may still be open.
$error /command get dup type /filetype eq
- { { fileposition } .internalstopped { pop //null } if }
+ { { fileposition } //.internalstopped exec { pop //null } if }
{ pop //null }
ifelse
}
@@ -956,59 +1005,14 @@ def
$error /.inerror //false put
stop
} bind executeonly def
+currentdict /.unstoppederrorhandler .undef
+
% Define the standard handleerror. We break out the printing procedure
% (.printerror) so that it can be extended for binary output
% if the Level 2 facilities are present.
- /.printerror
- { $error begin newerror
- {
- /command load errorname SHORTERRORS
- { (%%[ Error: ) print =only flush
- (; OffendingCommand: ) print =only
- errorinfo dup //null eq {
- pop
- } {
- (;\nErrorInfo:) print
- dup type /arraytype eq
- { { ( ) print =only } forall }
- { ( ) print =only }
- ifelse
- } ifelse
- ( ]%%) = flush
- }
- { (Error: ) print ==only flush
- ( in ) print ==only flush
- errorinfo dup //null eq {
- pop
- } {
- (\nAdditional information: ) print ==only flush
- } ifelse
- .printerror_long
- }
- ifelse
- .clearerror flush
- }
- { % newerror is //false, test to see if user has set handleerror to a different
- % routine, if so execute it, otherwise, just return. This code deals with the
- % Genoa issue of setting /handleerror, and then calling it, without an error
- % being set. We were erroring in this case, due to /command load failing.
-
- //JOBSERVER {
- /errordict .systemvar /handleerror get /.GShandleerror .systemvar ne
- } {
- //false
- } ifelse
- { /errordict .systemvar begin /handleerror load .internalstopped pop end
- }
- if
- }
- ifelse % newerror
- end
- flush
- } bind executeonly def
- /.printerror_long % long error printout,
+/.printerror_long % long error printout,
% $error is on the dict stack
- { % Push the (anonymous) stack printing procedure.
+{ % Push the (anonymous) stack printing procedure.
% <heading> <==flag> <override-name> <stackname> proc
{
currentdict exch .knownget % stackname defined in $error?
@@ -1082,18 +1086,59 @@ def
{ (Current file position is ) print position = }
if
- } bind executeonly def
-% Define a procedure for clearing the error indication.
-/.clearerror
- { $error /newerror //false put
- $error /errorname //null put
- $error /errorinfo //null put
- 0 .setoserrno
- } bind executeonly def
+} bind executeonly def
+/.printerror
+{ $error begin newerror
+ {
+ /command load errorname SHORTERRORS
+ { (%%[ Error: ) print =only flush
+ (; OffendingCommand: ) print =only
+ errorinfo dup //null eq {
+ pop
+ } {
+ (;\nErrorInfo:) print
+ dup type /arraytype eq
+ { { ( ) print =only } forall }
+ { ( ) print =only }
+ ifelse
+ } ifelse
+ ( ]%%) = flush
+ }
+ { (Error: ) print ==only flush
+ ( in ) print ==only flush
+ errorinfo dup //null eq {
+ pop
+ } {
+ (\nAdditional information: ) print ==only flush
+ } ifelse
+ //.printerror_long exec
+ }
+ ifelse
+ //.clearerror exec flush
+ }
+ { % newerror is //false, test to see if user has set handleerror to a different
+ % routine, if so execute it, otherwise, just return. This code deals with the
+ % Genoa issue of setting /handleerror, and then calling it, without an error
+ % being set. We were erroring in this case, due to /command load failing.
+
+ //JOBSERVER {
+ /errordict .systemvar /handleerror get /.GShandleerror .systemvar ne
+ } {
+ //false
+ } ifelse
+ { /errordict .systemvar begin /handleerror load //.internalstopped exec pop end
+ }
+ if
+ }
+ ifelse % newerror
+ end
+ flush
+} bind executeonly def
+currentdict /.printerror_long .undef
% Define $error. This must be in local VM.
.currentglobal //false .setglobal
-/$error 40 dict .forcedef % $error is local, systemdict is global
+currentdict /$error 40 dict .forceput % $error is local, systemdict is global
% newerror, errorname, command, errorinfo,
% ostack, estack, dstack, recordstacks,
% binary, globalmode,
@@ -1112,8 +1157,8 @@ end
% Define errordict similarly. It has one entry per error name,
% plus handleerror. However, some astonishingly badly written PostScript
% files require it to have at least one empty slot.
-/errordict ErrorNames length 3 add dict
-.forcedef % errordict is local, systemdict is global
+currentdict /errordict ErrorNames length 3 add dict
+.forceput % errordict is local, systemdict is global
.setglobal % back to global VM
% gserrordict contains all the default error handling methods, but unlike
% errordict it is noaccess after creation (also it is in global VM).
@@ -1129,22 +1174,24 @@ end
% files. However, ErrorNames contains all of the error names regardless of
% what features are included, so we have to "know" that VMerror is the last
% Level 1 error.
-/.registererror % <name> .registererror -
- { errordict exch .registererror2
- } bind def
/.registererror2 % <dict> <name> .registererror -
{ .currentglobal //true .setglobal % create procs in global VM
3 1 roll
- mark 1 index systemdict /.errorhandler get /exec load .packtomark cvx put
+ mark 1 index systemdict /.errorhandler get /exec load //.packtomark exec cvx put
.setglobal
} bind def
+/.registererror % <name> .registererror -
+ { errordict exch //.registererror2 exec
+ } bind def
+currentdict /.registererror2 .undef
+
ErrorNames
{ .registererror} forall
errordict begin
% The handlers for interrupt and timeout are special; there is no
% 'current object', so they push their own name.
{ /interrupt /timeout }
- { mark 1 index dup systemdict /.errorhandler get /exec load .packtomark cvx def
+ { mark 1 index dup systemdict /.errorhandler get /exec load //.packtomark exec cvx def
} forall
/handleerror % this key is 'well known' and some PS may redefine it
{ /.printerror .systemvar exec
@@ -1168,8 +1215,8 @@ errordict /unknownerror .undef
}ifelse
}forall
noaccess pop
- systemdict /.setsafeerrors .forceundef
- systemdict /.SAFERERRORLIST .forceundef
+ //systemdict /.setsafeerrors .forceundef
+ //systemdict /.SAFERERRORLIST .forceundef
} bind executeonly odef
SAFERERRORS {.setsafererrors} if
@@ -1242,39 +1289,53 @@ end
/=== { ===only (\n) print } bind def
% Create the initialization queue.
-
-/.delayed_init_queue 10 dict def
+1183615869 internaldict dup
+/.delayed_init_queue 10 dict put
/.schedule_init % <priority> <proc> .schedule_init -
{
- //.delayed_init_queue 2 index known {
+ 1183615869 internaldict begin
+ .delayed_init_queue 2 index known {
+ end
(.delayed_init_queue priority conflict with ) print 1 index =
/.schedule_init cvx /configurationerror signalerror
} if
- //.delayed_init_queue 3 1 roll .growput
+ .delayed_init_queue 3 1 roll .growput
+ end
} bind def
+begin
/.execute_scheduled_inits % - .execute_scheduled_inits -
{
- { 0 //null //.delayed_init_queue { % maxp {} p {}
+ 2 dict begin
+ /.newdelayed_init_queue
+ mark
+ 1183615869 internaldict /.delayed_init_queue get {} forall
+ .dicttomark def
+ {
+ 0 //null .newdelayed_init_queue { % maxp {} p {}
3 index 2 index lt {
4 2 roll
} if
pop pop
} forall
- exch //.delayed_init_queue exch undef
+ exch .newdelayed_init_queue exch undef
dup //null eq {
pop exit
} if
exec
} loop
+ currentdict /.newdelayed_init_queue undef
+ end
} bind def
+end
(END PROCS) VMDEBUG
% Define the font directory.
+currentdict
/FontDirectory //false .setglobal 100 dict //true .setglobal
-.forcedef % FontDirectory is local, systemdict is global
+.forceput % FontDirectory is local, systemdict is global
% Define the encoding dictionary.
/EncodingDirectory 16 dict def % enough for Level 2 + PDF standard encodings
@@ -1336,7 +1397,7 @@ currentdict /PDFA known { PDFA type /booleantype eq { /PDFA 1 def } if } if
% Loop until the .getdevice gets a rangecheck.
errordict /rangecheck 2 copy get
errordict /rangecheck { pop stop } put % pop the command
- 0 { {dup .getdevice exch 1 add} loop} .internalstopped pop
+ 0 { {dup .getdevice exch 1 add} loop} //.internalstopped exec pop
1 add dict /devicedict 1 index def
begin % 2nd copy of count is on stack
{ dup .devicename exch
@@ -1542,12 +1603,20 @@ setpacking
% Increase fill adjustment so that we effectively use Adobe's
% any-part-of-pixel rule.
- 0.5 .setfilladjust
+ 0.5 dup .setfilladjust2
} bind def
+
% Set the default screen and BG/UCR.
+% We define the proc here, rather than inline in .setdefaultbgucr
+% for the benefit of gs_cet.ps so jobs that do anything that causes
+% .setdefaultbgucr to be called will still get the redefined proc
+% in gs_cet.ps
+(%.defaultbgrucrproc) cvn { pop 0 } def
+
/.setdefaultbgucr {
systemdict /setblackgeneration known {
- { pop 0 } dup setblackgeneration setundercolorremoval
+ (%.defaultbgrucrproc) cvn load dup
+ setblackgeneration setundercolorremoval
} if
} bind def
/.useloresscreen { % - .useloresscreen <bool>
@@ -1571,7 +1640,7 @@ setpacking
% false
/.getdefaulthalftone {
% try the device to see if it has a default halftone
- { currentdevice /HalftoneDefault //.gsgetdeviceprop exec } .internalstopped
+ { currentdevice /HalftoneDefault //.gsgetdeviceprop exec } //.internalstopped exec
{ pop pop //false } % no device property
{ dup type /dicttype eq { //true } { pop //false } ifelse }
ifelse
@@ -1579,7 +1648,7 @@ setpacking
% false not found
dup not
{ % device did not provide a default, try Resource
- pop { /Default /Halftone /findresource .systemvar exec } .internalstopped
+ pop { /Default /Halftone /findresource .systemvar exec } //.internalstopped exec
{ pop pop //false } { //true } ifelse
}
if
@@ -1587,18 +1656,20 @@ setpacking
currentdict /.gsgetdeviceprop .forceundef
/.setdefaulthalftone {
- .getdefaulthalftone
+ //.getdefaulthalftone exec
{ sethalftone }
{ % default not found
- .useloresscreen { .setloreshalftone } { .sethireshalftone pop } ifelse
+ //.useloresscreen exec { .setloreshalftone } { .sethireshalftone pop } ifelse
}
ifelse
} bind def
/.setdefaultscreen {
- .useloresscreen { .setloresscreen } { .sethiresscreen } ifelse
- .setdefaultbgucr
+ //.useloresscreen exec { .setloresscreen } { .sethiresscreen } ifelse
+ //.setdefaultbgucr exec
} bind def
+currentdict /.setdefaultbgucr .undef
+currentdict /.useloresscreen .undef
% Rendering intent mapping for setcolorrendering1 and PDF interpreter
/.renderingintentdict mark
@@ -1709,7 +1780,7 @@ currentdict /.gsgetdeviceprop .forceundef
dup length
2 index length sub % drop "ffn", remaining "ldffn" = length of the "directory" part
exch % {} b [dl] (templ) (ffn) ldffn (dffn)
- .makepathtemplate % {} b [dl] (templ) (ffn) ldffn (Dffn)
+ //.makepathtemplate exec % {} b [dl] (templ) (ffn) ldffn (Dffn)
dup % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn)
4 index length dup % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) templL templL
2 index length % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) templL templL DffnL
@@ -1741,7 +1812,8 @@ currentdict /.gsgetdeviceprop .forceundef
} forall
} ifelse % (t1) ?l1 (t2) ?l2 ... (tN) ?ln {} b [dl] (templ) (ffn)
pop pop pop pop pop % (t1) ?l1 (t2) ?l2 ... (tN) ?ln
-} bind def
+} .bind executeonly odef
+currentdict /.makepathtemplate .undef
% <dir_list> <template> .generate_dir_list_templates <t1> ... <tN>
%
@@ -1749,8 +1821,8 @@ currentdict /.gsgetdeviceprop .forceundef
% It's the 'false' case of the function above.
%
/.generate_dir_list_templates
-{ //false 3 1 roll //.generate_dir_list_templates_with_length exec
-} bind def
+{ //false 3 1 roll //.generate_dir_list_templates_with_length
+} .bind executeonly odef
% Load the initialization files for optional features.
%% Replace 4 INITFILES
@@ -1789,6 +1861,7 @@ end
% Load initial fonts from FONTPATH directories, Fontmap file,
% and/or .getccfont as appropriate.
.loadinitialfonts
+currentdict /.loadinitialfonts .undef
% Remove NullFont from FontDirectory, so it can't be accessed by mistake.
/undefinefont where {
@@ -1810,12 +1883,16 @@ currentdict /.runlibfile .undef
{ dup type /operatortype eq
{
% This might be a real operator, so bind might cause a typecheck
- {.bind} .internalstopped pop
+ {.bind} //.internalstopped exec pop
}
if pop pop
} forall
} def
-DELAYBIND not { .bindoperators } if
+DELAYBIND not {
+ .bindoperators
+ %% if not DELAYBIND, undef this now. Otherwise defer to .bindnow
+ //systemdict /.bindoperators .undef
+} if
% Establish a default environment.
@@ -1938,7 +2015,7 @@ ifelse
% If the initial device parameters are invalid, the setdevice may fail.
% Trap this and produce a reasonable error message.
{ setdevice } % does an erasepage
-INITDEBUG { exec //false } { .internalstopped } ifelse {
+INITDEBUG { exec //false } { //.internalstopped exec } ifelse {
(%stderr) (w) file dup
(**** Unable to open the initial device, quitting.\n) writestring
flushfile
@@ -2020,9 +2097,21 @@ gsave
} {
{ }
} ifelse def
-<1b> cvn { % UEL is <esc>%-12345X and acts the same as ^D
- currentfile (%-12345X) .peekstring pop (%-12345X) eq <04> cvn load if
-} bind def
+<1b> cvn
+.actonuel % UEL is <esc>%-12345X and acts the same as ^D
+{systemdict (.forceinterp_exit) cvn known {//true} {//false} ifelse}
+{//false} ifelse
+
+{
+ {
+ currentfile (%-12345X) .peekstring pop (%-12345X) eq
+ { currentfile .forceinterp_exit } if
+ }
+}
+{
+ {currentfile (%-12345X) .peekstring pop (%-12345X) eq <04> cvn load if}
+} ifelse bind def
+
<1b45> cvn { } def % PJL reset prologue (ESC E)
<1b451b> cvn <1b> cvn load def % PJL reset epilogue (ESC E + UEL)
(\001M) cvn % TBCP initiator
@@ -2048,7 +2137,9 @@ gsave
% Install the EPS handler if needed
systemdict /EPSBoundingBoxInit known { EPSBoundingBoxInit } if
+systemdict /EPSBoundingBoxInit .forceundef
+%% ---------------- SAFER stuff BEGIN -------------------%%
% If we want a "safer" system, disable some obvious ways to cause havoc.
.currentglobal //true .setglobal
/SAFETY 2 dict
@@ -2108,13 +2199,14 @@ readonly def
>> setuserparams
}
if
-} bind def
+} .bind executeonly def
currentdict /tempfilepaths undef
+%% --- These are documented extensions ---
/.locksafe {
- .locksafe_userparams
- systemdict /getenv {pop //false} .forceput
+ //.locksafe_userparams exec
+ //systemdict /getenv {pop //false} .forceput
% setpagedevice has the side effect of clearing the page, but
% we will just document that. Using setpagedevice keeps the device
% properties and pagedevice .LockSafetyParams in agreement even
@@ -2125,6 +2217,20 @@ currentdict /tempfilepaths undef
//SAFETY /safe //true .forceput % overrides readonly
} .bind executeonly odef
+/.setsafe
+{
+ SAFETY /safe get not {
+ <<
+ /PermitFileReading [ ]
+ /PermitFileWriting [ ]
+ /PermitFileControl [ ]
+ >> setuserparams
+ }
+ if
+ .locksafe
+} .bind executeonly odef
+%% --- End documented extensions ---
+
% This is only used during startup. Its required so that
% we can detect in setpagdevice that we are in fact in startup
% and allocate a *global* instead of local VM. We need it to be
@@ -2132,7 +2238,7 @@ currentdict /tempfilepaths undef
% in gs_setpd.ps)
%
/.locksafeglobal {
- .locksafe_userparams
+ //.locksafe_userparams exec
systemdict /getenv {pop //false} put
% setpagedevice has the side effect of clearing the page, but
% we will just document that. Using setpagedevice keeps the device
@@ -2144,20 +2250,7 @@ currentdict /tempfilepaths undef
>> setpagedevice
setglobal
//SAFETY /safe //true .forceput % overrides readonly
-} .bind executeonly odef
-
-/.setsafe
-{
- SAFETY /safe get not {
- <<
- /PermitFileReading [ ]
- /PermitFileWriting [ ]
- /PermitFileControl [ ]
- >> setuserparams
- }
- if
- .locksafe
-} .bind executeonly odef
+} .bind def
% See /.locksafeglobal above.
%
@@ -2170,12 +2263,16 @@ currentdict /tempfilepaths undef
>> setuserparams
}
if
- .locksafeglobal
-} bind executeonly odef
+ //.locksafeglobal exec
+} .bind def
% If we are running in SAFER mode, lock things down
SAFER { .setsafeglobal } if
+currentdict /.locksafe_userparams .undef
+currentdict /.setsafeglobal .undef
+currentdict /.locksafeglobal .undef
+SAFER {
/SAFERUndefinePostScriptOperators {
[
% Used by our own test suite files
@@ -2186,30 +2283,17 @@ SAFER { .setsafeglobal } if
/.endtransparencygroup % transparency-example.ps
/.setdotlength % Bug687720.ps
/.sort /.setdebug /.mementolistnewblocks /getenv
-
- /.makeoperator /.setCPSImode % gs_cet.ps, this won't work on cluster with -dSAFER
-
/unread
]
{systemdict exch .forceundef} forall
//systemdict /SAFERUndefinePostScriptOperators .forceundef
} .bind executeonly def % must be bound and hidden for .forceundef
+} if
-/UndefinePostScriptOperators {
-
- % This list is of Display PostScript operators. We believe that Display PostScript
- % was never fully implemented and the only known user, GNUStep, is no longer
- % using it. So lets remove it.
- [
- /condition /currentcontext /detach /.fork /join /.localfork /lock /monitor /notify
- /wait /yield /.currentscreenphase /.setscreenphase /.image2 /eoviewclip /initviewclip
- /viewclip /viewclippath /defineusername
- % NeXT DPS extensions
- /currentalpha /setalpha /.alphaimage /composite /compositerect /dissolve /sizeimagebox /.sizeimageparams
- ]
- {systemdict exch .forceundef} forall
+%% ---------------- SAFER stuff END -------------------%%
+/UndefinePostScriptOperators {
% This list is of operators which no longer appear to be used, and which we do not believe
% to have any real use. For now we will undefine the operstors so they cannot easily be used
% but can be easily restored (just delete the name from the list in the array). In future
@@ -2244,17 +2328,58 @@ SAFER { .setsafeglobal } if
/.file_name_combine /.file_name_is_absolute /.file_name_separator /.file_name_directory_separator /.file_name_current /.filename
/.peekstring /.writecvp /.subfiledecode /.setupUnicodeDecoder /.jbig2makeglobalctx /.registerfont /.parsecff
/.getshowoperator /.getnativefonts /.beginform /.endform /.get_form_id /.repeatform /.reusablestream /.rsdparams
- /.buildfunction /.currentfilladjust2 /.setfilladjust2 /.sethpglpathmode /.currenthpglpathmode
+ /.buildfunction /.sethpglpathmode /.currenthpglpathmode
/.currenthalftone /.sethalftone5 /.image1 /.imagemask1 /.image3 /.image4
/.getiodevice /.getdevparms /.putdevparams /.bbox_transform /.matchmedia /.matchpagesize /.defaultpapersize
/.oserrno /.setoserrno /.oserrorstring /.getCPSImode
- /.getscanconverter /.setscanconverter /.type1encrypt /.type1decrypt/.languagelevel /.setlanguagelevel /.eqproc /.fillpage /.buildpattern1 /.saslprep
- /.buildshading1 /.buildshading2 /.buildshading3 /.buildshading4 /.buildshading5 /.buildshading6 /.buildshading7 /.buildshadingpattern
+ /.getscanconverter /.setscanconverter /.type1encrypt /.type1decrypt/.languagelevel /.setlanguagelevel /.eqproc /.fillpage
+ /.saslprep
/.shfill /.argindex /.bytestring /.namestring /.stringbreak /.stringmatch /.globalvmarray /.globalvmdict /.globalvmpackedarray /.globalvmstring
/.localvmarray /.localvmdict /.localvmpackedarray /.localvmstring /.systemvmarray /.systemvmdict /.systemvmpackedarray /.systemvmstring /.systemvmfile /.systemvmlibfile
/.systemvmSFD /.settrapparams /.currentsystemparams /.currentuserparams /.getsystemparam /.getuserparam /.setsystemparams /.setuserparams
/.checkpassword /.locale_to_utf8 /.currentglobal /.gcheck /.imagepath /.currentoutputdevice
/.type /.writecvs /.setSMask /.currentSMask /.needinput /.countexecstack /.execstack /.applypolicies
+ /filterdict /.cidfonttypes /.colorrenderingtypes
+ /.formtypes /.halftonetypes /.imagetypes /.imagemasktypes
+ /.patterntypes /.shadingtypes /.wheredict /.renderingintentdict
+ /.currentmatrix /.setmatrix
+ /.setlinecap /.setlinejoin /.sizeimagebox /.systemvmcheck
+ /.forceinterp_exit /.actonuel
+ /.init_otto_font_file
+ /.composefontdict
+ /.type1build
+ /.origdefinefont /.origundefinefont /.origfindfont
+ /.buildnativefontmap
+ /.completefont
+ /.definefakefonts
+ /.fontnameproperties
+ /.growfontdict
+ /.substitutefont /.substitutefontname
+ /.FontDirectory
+ /.charkeys
+ /.makesfnts
+ /.pickcmap
+ /.loadttcidfont
+ /.loadpdfttfont
+ /obind
+ /odef
+ /.packtomark
+ /.putdeviceprops
+ /.growdict /.growdictlength
+ /.userdict /.uservar
+ /.getdefaulthalftone
+ /.registererror
+ /.PurgeDict
+ /.runresource
+ /.numicc_components
+ /.set_outputintent
+ /.internalstopped
+ /.generate_dir_list_templates /.generate_dir_list_templates_with_length
+ /.type11mapcid /.type9mapcid
+ /.clearerror
+ /.beginpage /.endpage
+ /.getpath
+ /.confirm /.confirmread
% Used by a free user in the Library of Congress. Apparently this is used to
% draw a partial page, which is then filled in by the results of a barcode
@@ -2267,52 +2392,57 @@ SAFER { .setsafeglobal } if
% Used by our own test suite files
%/.fileposition %image-qa.ps
- %/.makeoperator /.setCPSImode % gs_cet.ps
% Either our code uses these in ways which mean they can't be undefined, or they are used directly by
% test files/utilities, or engineers expressed a desire to keep them visible.
%
%/currentdevice /.sort /.buildfont0 /.buildfont1 /.buildfont2 /.buildfont3 /.buildfont4 /.buildfont9 /.buildfont10 /.buildfont11
- %/.buildfont32 /.buildfont42 /.type9mapcid /.type11mapcid /.swapcolors
+ %/.buildfont32 /.buildfont42 /.swapcolors
%/currentdevice /.quit /.setuseciecolor /.needinput /.setoverprintmode /.special_op /.dicttomark /.knownget
%/.FAPIBuildGlyph /.FAPIBuildChar /.FAPIBuildGlyph9
- %/.tempfile /.numicc_components /.set_outputintent /.max /.min /.vmreclaim /.getpath /.setglobal
+ %/.tempfile /.max /.min /.setglobal
%/.setdebug /.mementolistnewblocks /getenv
]
{systemdict exch .forceundef} forall
+ % level 2 operators, undefine from both systemdict and level2dict
+ [
+ /.execform1
+ /.getdevparams
+ /.setuserparams2
+ /.startjob
+ /.checkFilePermitparams
+ /.copyparam
+ /.setdevicecolorrendering1
+ /.buildpattern1
+ /.findcategory
+ /.execinstall
+ /.findfontop
+
+% Couldn't figure out how to do these yet
+% /.checkparamtype
+% /.startnewjob
+ ]
+ dup {level2dict exch .forceundef} forall
+ {systemdict exch .forceundef} forall
+
+ % undef stuff from statusdict
+ [
+% /.setpagesize
+ ]
+ {statusdict exch .forceundef} forall
+
//systemdict /UndefinePostScriptOperators .forceundef
} .bind executeonly def % must be bound and hidden for .forceundef
+% Undefine operators that are used by PDF internally.
+% This list is maintained in pdf_main.ps
/UndefinePDFOperators {
- % This list of operators are used internally by various parts of the Ghostscript PDF interpreter.
- % Since each operator is a potential security vulnerability, and any operator listed here
- % is not required once the initislisation is complete and functions are bound, we undefine
- % the ones that aren't needed at runtime.
- % This function is only called if DELAYBIND is true. It is a copy of the code at the end of pdf_main.ps
- % and must be maintained in parallel with it.
- [
- /.pdfawidthshow /.pdfwidthshow /.currentblackptcomp /.setblackptcomp
- /.setfillcolor /.setfillcolorspace /.setstrokecolor /.setstrokecolorspace /.currentrenderingintent /.setrenderingintent
- /.currenttextrenderingmode /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading
- /.settextrise /.currenttextrise /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling
- /.settextlinematrix /.currenttextlinematrix /.currenttextmatrix /.settextmatrix /.currentblendmode
- /.currentopacityalpha /.currentshapealpha /.currenttextknockout
- /.pushextendedgstate /.popextendedgstate /.begintransparencytextgroup
- /.endtransparencytextgroup /.begintransparencymaskgroup /.begintransparencymaskimage /.endtransparencymask /.image3x
- /.abortpdf14devicefilter /.pdfinkpath /.pdfFormName /.setstrokeconstantalpha
- /.setfillconstantalpha /.setalphaisshape /.currentalphaisshape
- /.settextspacing /.currenttextspacing /.settextleading /.currenttextleading /.settextrise /.currenttextrise
- /.setwordspacing /.currentwordspacing /.settexthscaling /.currenttexthscaling /.setPDFfontsize /.currentPDFfontsize
- /.setdistillerparams
-
- % undefining these causes errors/incorrect output
- %/.settextrenderingmode /.setblendmode /.begintransparencygroup /.settextknockout /check_r6_password /.setstrokeoverprint /.setfilloverprint
- %/.currentstrokeoverprint /.currentfilloverprint /.currentfillconstantalpha /.currentstrokeconstantalpha
- ]
- {systemdict exch .forceundef} forall
+ .PDF_UNDEF_OPLIST
+ {//systemdict exch .forceundef} forall
+ //systemdict /.PDF_UNDEF_OPLIST .forceundef
//systemdict /UndefinePDFOperators .forceundef
-} .bind executeonly def % must be bound and hidden for .forceundef
+} .bind def
% If we delayed binding, make it possible to do it later.
/.bindnow {
@@ -2333,9 +2463,9 @@ SAFER { .setsafeglobal } if
//systemdict /UndefinePostScriptOperators get exec
//systemdict /UndefinePDFOperators get exec
//systemdict /.forcecopynew .forceundef % remove temptation
- //systemdict /.forcedef .forceundef % ditto
//systemdict /.forceput .forceundef % ditto
//systemdict /.undef .forceundef % ditto
+ //systemdict /.bindoperators .forceundef
//systemdict /.forceundef .forceundef % ditto
currentuserparams /IdiomRecognition known {
1 dict dup /IdiomRecognition 4 -1 roll put setuserparams
@@ -2357,7 +2487,7 @@ SAFER { .setsafeglobal } if
% Update the copy of the user parameters.
mark .currentuserparams counttomark 2 idiv {
userparams 3 1 roll .forceput % userparams is read-only
- } repeat pop
+ } executeonly repeat pop
% Turn on idiom recognition, if available.
currentuserparams /IdiomRecognition known {
/IdiomRecognition //true .definepsuserparam
@@ -2368,15 +2498,15 @@ SAFER { .setsafeglobal } if
% (and, if implemented, context switching).
.currentglobal //false .setglobal
mark userparams { } forall .dicttomark readonly
- /userparams exch .forcedef % systemdict is read-only
+ currentdict exch /userparams exch .forceput % systemdict is read-only
.setglobal
-} if
+} executeonly if
/.currentsystemparams where {
pop
% Remove real system params from pssystemparams.
mark .currentsystemparams counttomark 2 idiv {
pop pssystemparams exch .forceundef
- } repeat pop
+ } executeonly repeat pop
} if
% Set up AlignToPixels :
@@ -2399,47 +2529,19 @@ $error /.nosetlocal //false put
(END GLOBAL) VMDEBUG
-% .savelocalstate is part of Display PostScript (if included). Part of the function of
-% the .savelocalstate routine is to store the 'initial saved gstate' (savedinitialgstate)
-% in systemdict. The code in dps1.c, gstate_check_space, disallows writing or creating
-% gstates in global VM in certain conditions. If we execute setpagedevice before we
-% reach this point, we must ensure that we do so using /..StartupGlobal so that
-% the dictionary is defined in global VM, because the gstate contains a pointer to the
-% device dictionary, and if that is allocated in local VM we will fail the gstate check.
-/.savelocalstate where {
- % If we might create new contexts, save away copies of all dictionaries
- % referenced from systemdict that are stored in local VM,
- % and also save a copy of the initial gstate.
- pop .savelocalstate
-} {
- % If we're *not* running in a multi-context system and FAKEFONTS is
- % defined, add the fake fonts to LocalFontDirectory.
- .definefakefonts % current VM is local
-} ifelse
+% Add the fake fonts to LocalFontDirectory.
+//.definefakefonts exec % current VM is local
% Execute scheduled inits :
-//.execute_scheduled_inits exec
-currentdict /.execute_scheduled_inits undef
-currentdict /.delayed_init_queue undef
+1183615869 internaldict /.execute_scheduled_inits get exec
+currentdict /.schedule_init undef
+%currentdict /.execute_scheduled_inits undef
+%currentdict /.delayed_init_queue undef
% Make global and local FontDirectory read-only.
FontDirectory readonly pop
/GlobalFontDirectory where { pop GlobalFontDirectory readonly pop } if
-% Remove systemdict entries for things that have been bound in where used
-% and that shouldn't be accessible by name, and close up systemdict.
-currentdict /filterdict .undef
-currentdict /.cidfonttypes .undef
-currentdict /.colorrenderingtypes .undef
-currentdict /.formtypes .undef
-currentdict /.halftonetypes .undef
-currentdict /.imagetypes .undef
-currentdict /.imagemasktypes .undef
-currentdict /.patterntypes .undef
-currentdict /.shadingtypes .undef
-currentdict /.wheredict .undef
-currentdict /.renderingintentdict .undef
-
% If we are using DELAYBIND we have to defer the undefinition
% until .bindnow.
DELAYBIND not {
@@ -2455,24 +2557,30 @@ end
/vmreclaim where
{ pop NOGC not { 2 .vmreclaim 0 vmreclaim } if
} if
+systemdict /.vmreclaim .undef
+level2dict /.vmreclaim .undef
+
+% Do this before systemdict is locked (see below for additional CETMODE setup using gs_cet.ps)
+systemdict /CETMODE .knownget {
+ {
+ (gs_cet.ps) runlibfile
+ } if
+} if
+systemdict /.makeoperator .undef % must be after gs_cet.ps
+systemdict /.setCPSImode .undef % must be after gs_cet.ps
+
DELAYBIND not {
systemdict /.bindnow .undef % We only need this for DELAYBIND
systemdict /.forcecopynew .undef % remove temptation
- systemdict /.forcedef .undef % ditto
systemdict /.forceput .undef % ditto
systemdict /.forceundef .undef % ditto
} if
-% Move superexec to internaldict if superexec is defined.
-systemdict /superexec .knownget {
- 1183615869 internaldict /superexec 3 -1 roll put
- systemdict /superexec .undef
-} if
-
% Can't remove this one until the last minute :-)
DELAYBIND not {
systemdict /.undef .undef
} if
+
WRITESYSTEMDICT {
SAFER {
(\n *** WARNING - you have selected SAFER, indicating you want Ghostscript\n) print