| 1 |
% Copyright (C) 2001-2026 Artifex Software, Inc. |
| 2 |
% All Rights Reserved. |
| 3 |
% |
| 4 |
% This software is provided AS-IS with no warranty, either express or |
| 5 |
% implied. |
| 6 |
% |
| 7 |
% This software is distributed under license and may not be copied, |
| 8 |
% modified or distributed except as expressly authorized under the terms |
| 9 |
% of the license contained in the file LICENSE in this distribution. |
| 10 |
% |
| 11 |
% Refer to licensing information at http://www.artifex.com or contact |
| 12 |
% Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco, |
| 13 |
% CA 94129, USA, for further information. |
| 14 |
% |
| 15 |
|
| 16 |
% Initialization file for the interpreter. |
| 17 |
% When this is run, systemdict is still writable. |
| 18 |
|
| 19 |
% Comment lines of the form |
| 20 |
% %% Replace <n> <file(s)> |
| 21 |
% indicate places where the next <n> lines should be replaced by |
| 22 |
% the contents of <file(s)>, when creating a single merged init file. |
| 23 |
% |
| 24 |
% For reasons not clear to me, some cases of %% are being treated as |
| 25 |
% DSC comments when (and only when) the resource files are disk based |
| 26 |
% This can kill DSC parsing for pdfwrite at least, so avoid using |
| 27 |
% double % comments in this file. |
| 28 |
|
| 29 |
% The interpreter can call out to PostScript code. All procedures |
| 30 |
% called in this way, and no other procedures defined in these |
| 31 |
% initialization files, have names that begin with %, e.g., |
| 32 |
% (%Type1BuildChar) cvn. |
| 33 |
|
| 34 |
% Interpreter library version number |
| 35 |
% NOTE: the interpreter code requires that the first non-comment token |
| 36 |
% in this file be an integer, and that it match the compiled-in version! |
| 37 |
10071 |
| 38 |
|
| 39 |
% Check the interpreter revision. |
| 40 |
dup revision ne |
| 41 |
{ (gs: Interpreter revision \() print revision 10 string cvs print |
| 42 |
(\) does not match gs_init.ps revision \() print 10 string cvs print |
| 43 |
(\).\n) print flush //null 1 .quit |
| 44 |
} |
| 45 |
if pop |
| 46 |
|
| 47 |
% Acquire userdict, and set its length if necessary. |
| 48 |
/userdict where |
| 49 |
{ pop userdict maxlength 0 eq } |
| 50 |
{ //true } |
| 51 |
ifelse |
| 52 |
systemdict exch |
| 53 |
{ % userdict wasn't already set up by iinit.c. |
| 54 |
dup /userdict |
| 55 |
currentdict dup 200 .setmaxlength % userdict |
| 56 |
.forceput % userdict is local, systemdict is global |
| 57 |
} executeonly |
| 58 |
if begin |
| 59 |
|
| 60 |
% Init to global memory (possibly not needed, but left in for legacy purposes) |
| 61 |
//true .setglobal |
| 62 |
|
| 63 |
% Define .languagelevel if needed. |
| 64 |
systemdict /.languagelevel known not { /.languagelevel 1 def } if |
| 65 |
|
| 66 |
% Optionally choose a default paper size other than U.S. letter. |
| 67 |
% The default page size for many devices is set at compile time to |
| 68 |
% letter, but this can be changed to A4 although this is rarely done. |
| 69 |
% Some devices such as bbox have a different default page size, |
| 70 |
% and should not be set to A4 or letter. |
| 71 |
% When ghostscript is used in countries that use the international |
| 72 |
% standard page size A4 rather than US letter, the page size of |
| 73 |
% devices that default to letter or A4 can be changed by setting |
| 74 |
% DEFAULTPAPERSIZE. |
| 75 |
% /DEFAULTPAPERSIZE (a4) def |
| 76 |
|
| 77 |
% Turn on array packing for the rest of initialization. |
| 78 |
//true setpacking |
| 79 |
|
| 80 |
% Define the old MS-DOS EOF character as a no-op. |
| 81 |
% This is a hack to get around the absurd habit of MS-DOS editors |
| 82 |
% of adding an EOF character at the end of the file. |
| 83 |
<1a> cvn { } def |
| 84 |
|
| 85 |
% Acquire the debugging flags. |
| 86 |
currentdict /DEBUG known /DEBUG exch def |
| 87 |
|
| 88 |
% if DEBUG is set, set ALL of the subset debugging flags |
| 89 |
mark % '[' isn't defined yet |
| 90 |
/CCFONTDEBUG % Compiled Fonts |
| 91 |
/CFFDEBUG % CFF Fonts |
| 92 |
/CMAPDEBUG % CMAP |
| 93 |
/DOCIEDEBUG % CIE color |
| 94 |
/EPSDEBUG % EPS handling |
| 95 |
/FAPIDEBUG % Font API |
| 96 |
/INITDEBUG % Initialization |
| 97 |
/PDFDEBUG % PDF Interpreter |
| 98 |
/PDFWRDEBUG % PDF Writer |
| 99 |
/SETPDDEBUG % setpagedevice |
| 100 |
/TTFDEBUG % TTF Fonts |
| 101 |
/VGIFDEBUG % ViewGIF |
| 102 |
/VJPGDEBUG % ViewJPEG |
| 103 |
/RESMPDEBUG % Resource map |
| 104 |
counttomark array astore exch pop % ']' isn't defined yet |
| 105 |
{ dup currentdict exch known DEBUG or def } forall |
| 106 |
|
| 107 |
currentdict /PDFSTEP known /PDFSTEP exch def |
| 108 |
% if PDFSTEP is on, turn on PDFDEBUG |
| 109 |
PDFSTEP { /PDFDEBUG //true def } if |
| 110 |
|
| 111 |
currentdict /PDFSTOPONERROR known /PDFSTOPONERROR exch def |
| 112 |
currentdict /PDFSTOPONWARNING known {/PDFSTOPONWARNING //true def /PDFSTOPONERROR //true def}{/PDFSTOPONWARNING //false def} ifelse |
| 113 |
currentdict /PDFNOCIDFALLBACK known /PDFNOCIDFALLBACK exch def |
| 114 |
|
| 115 |
% Versions of bind for use during startup: |
| 116 |
% bind - normal "bind", honors DELAYBIND |
| 117 |
% .bind - normal "bind", but ignores DELAYBIND |
| 118 |
% .internalbind - as "bind" but forces the executeonly attribute |
| 119 |
% .forcebind - as ".bind" but forces the executeonly attribute |
| 120 |
% |
| 121 |
% In general, for security and consistency startup code should use |
| 122 |
% .internalbind or .forcebind, and only use bind/.bind when we |
| 123 |
% cannot enforce executeonly on a given proc |
| 124 |
/.bind /bind load def |
| 125 |
/.internalbind {bind executeonly} .bind 1 index exch .makeoperator def |
| 126 |
/.forcebind {.bind executeonly} .bind 1 index exch .makeoperator def |
| 127 |
|
| 128 |
/VMDEBUG |
| 129 |
INITDEBUG {{print mark |
| 130 |
systemdict /level2dict known |
| 131 |
{ .currentglobal dup //false .setglobal vmstatus |
| 132 |
//true .setglobal vmstatus 3 -1 roll pop |
| 133 |
6 -2 roll pop .setglobal |
| 134 |
} |
| 135 |
{ vmstatus 3 -1 roll pop |
| 136 |
} |
| 137 |
ifelse usertime 16#fffff and counttomark |
| 138 |
{ ( ) print ( ) cvs print } |
| 139 |
repeat pop |
| 140 |
( ) print systemdict length ( ) cvs print |
| 141 |
( ) print countdictstack ( ) cvs print |
| 142 |
( <) print count ( ) cvs print (>\n) print flush |
| 143 |
}} |
| 144 |
{{pop |
| 145 |
}} |
| 146 |
ifelse |
| 147 |
.forcebind def |
| 148 |
|
| 149 |
% This was a debugging switch removed in 9.22, no other software |
| 150 |
% should have had any regard for it, and even if testing its value |
| 151 |
% should have checked its existence first. However pstotext, an |
| 152 |
% ancient and no longer maintained piece of softare, did check |
| 153 |
% its value unconditionally. So we retain this key in the dictionary |
| 154 |
% purely for backward compatibility. |
| 155 |
/NOBIND //false def |
| 156 |
|
| 157 |
currentdict /BATCH known /BATCH exch def |
| 158 |
currentdict /DELAYBIND known /DELAYBIND exch def |
| 159 |
currentdict /DOINTERPOLATE .knownget { { -1 } { 1 } ifelse /InterpolateControl exch def } if |
| 160 |
currentdict /NOINTERPOLATE .knownget { { 0 } { 1 } ifelse /InterpolateControl exch def } if |
| 161 |
currentdict /ESTACKPRINT known /ESTACKPRINT exch def |
| 162 |
currentdict /FAKEFONTS known /FAKEFONTS exch def |
| 163 |
currentdict /FIXEDMEDIA known /FIXEDMEDIA exch def |
| 164 |
currentdict /FIXEDRESOLUTION known /FIXEDRESOLUTION exch def |
| 165 |
currentdict /LOCALFONTS known /LOCALFONTS exch def |
| 166 |
currentdict /JOBSERVER known /JOBSERVER exch def |
| 167 |
currentdict /NOCACHE known /NOCACHE exch def |
| 168 |
currentdict /NOCCFONTS known /NOCCFONTS exch def |
| 169 |
currentdict /NOCIE known /NOCIE exch def |
| 170 |
currentdict /NOPSICC known /NOPSICC exch def |
| 171 |
currentdict /NODISPLAY known not /DISPLAYING exch def |
| 172 |
currentdict /NOFONTMAP known /NOFONTMAP exch def |
| 173 |
currentdict /NOFONTPATH known /NOFONTPATH exch def |
| 174 |
currentdict /NOGC known /NOGC exch def |
| 175 |
currentdict /NOMEDIAATTRS known /NOMEDIAATTRS exch def |
| 176 |
currentdict /NOOUTERSAVE known /NOOUTERSAVE exch def |
| 177 |
currentdict /NOPAGEPROMPT known /NOPAGEPROMPT exch def |
| 178 |
currentdict /NOPAUSE known /NOPAUSE exch def |
| 179 |
currentdict /NOPLATFONTS known /NOPLATFONTS exch def |
| 180 |
currentdict /NOPROMPT known /NOPROMPT exch def |
| 181 |
currentdict /NOTRANSPARENCY known /NOTRANSPARENCY exch def |
| 182 |
currentdict /DOPS known /DOPS exch def |
| 183 |
currentdict /NOSUBSTDEVICECOLORS known /NOSUBSTDEVICECOLORS exch def |
| 184 |
% The default value of ORIENT1 is true, not false. |
| 185 |
currentdict /ORIENT1 known not { /ORIENT1 //true def } if |
| 186 |
currentdict /OSTACKPRINT known /OSTACKPRINT exch def |
| 187 |
currentdict /OUTPUTFILE known % obsolete |
| 188 |
{ /OutputFile /OUTPUTFILE load def |
| 189 |
currentdict /OUTPUTFILE .undef |
| 190 |
} if |
| 191 |
currentdict /QUIET known /QUIET exch def |
| 192 |
% DELAYSAFER is effectively the same as newer NOSAFER |
| 193 |
currentdict /DELAYSAFER known { /DELAYSAFER //true def /NOSAFER //true def } if |
| 194 |
/SAFER currentdict /NOSAFER known { |
| 195 |
//false |
| 196 |
} { |
| 197 |
//true |
| 198 |
} |
| 199 |
ifelse def |
| 200 |
|
| 201 |
/OLDSAFER currentdict /OLDSAFER known def |
| 202 |
|
| 203 |
/SAFERERRORS |
| 204 |
currentdict /NOSAFERERRORS known |
| 205 |
{ |
| 206 |
//false |
| 207 |
} |
| 208 |
{ |
| 209 |
currentdict /SAFERERRORS known |
| 210 |
} ifelse def |
| 211 |
|
| 212 |
currentdict /ALLOWPSTRANSPARENCY known not |
| 213 |
{ |
| 214 |
/ALLOWPSTRANSPARENCY //false def |
| 215 |
} if |
| 216 |
|
| 217 |
currentdict /SHORTERRORS known /SHORTERRORS exch def |
| 218 |
currentdict /TTYPAUSE known /TTYPAUSE exch def |
| 219 |
currentdict /WRITESYSTEMDICT known /WRITESYSTEMDICT exch def |
| 220 |
currentdict /RENDERTTNOTDEF known /RENDERTTNOTDEF exch def |
| 221 |
|
| 222 |
currentdict /EPSFitPage known { /PSFitPage //true def } if |
| 223 |
% This is a "convenience" option that sets a combination of EPSFitPage, PDFFitPage and PSFitPage |
| 224 |
currentdict /FitPage known { /EPSFitPage //true def /PDFFitPage //true def /PSFitPage //true def } if |
| 225 |
|
| 226 |
currentdict /SimulateOverprint known { |
| 227 |
(\n**** -dSimulateOverprint={true|false} is no longer supported. ****\n) print |
| 228 |
(**** It has been replaced by -dOverprint={enable|disable|simulate} ****\n\n) print |
| 229 |
% Set the new variable appropriately. |
| 230 |
/Overprint SimulateOverprint { /enable } { /disable } ifelse def |
| 231 |
} if |
| 232 |
|
| 233 |
% Acquire environment variables. |
| 234 |
currentdict /DEVICE known not |
| 235 |
{ (GS_DEVICE) getenv { /DEVICE exch def } if } if |
| 236 |
|
| 237 |
(START) VMDEBUG |
| 238 |
|
| 239 |
% Open the standard files, so they will be open at the outermost save level. |
| 240 |
(%stdin) (r) file pop |
| 241 |
(%stdout) (w) file pop |
| 242 |
(%stderr) (w) file pop |
| 243 |
|
| 244 |
/.currentuserparams where { |
| 245 |
pop mark |
| 246 |
% The Adobe implementations appear to have very large maximum |
| 247 |
% stack sizes. This turns out to actually make a difference, |
| 248 |
% since some badly-behaved files include extremely long procedures, |
| 249 |
% or construct huge arrays on the operand stack. |
| 250 |
% We reset the stack sizes now so that we don't have to worry |
| 251 |
% about overflowing the (rather small) built-in stack sizes |
| 252 |
% during initialization. |
| 253 |
/MaxDictStack 500 |
| 254 |
/MaxExecStack 5000 |
| 255 |
/MaxOpStack 300000 |
| 256 |
.dicttomark .setuserparams |
| 257 |
} if |
| 258 |
|
| 259 |
% Define a procedure for skipping over an unneeded section of code. |
| 260 |
% This avoids allocating space for the skipped procedures. |
| 261 |
% We can't use readline, because that imposes a line length limit. |
| 262 |
/.skipeof % <string> .skipeof - |
| 263 |
{ currentfile exch 1 exch /SubFileDecode filter flushfile |
| 264 |
} .forcebind def |
| 265 |
|
| 266 |
% Define procedures to assist users who don't read the documentation. |
| 267 |
userdict begin |
| 268 |
/help |
| 269 |
{ (Enter PostScript commands. '(filename) run' runs a file, 'quit' exits.\n) |
| 270 |
print flush |
| 271 |
} .forcebind def |
| 272 |
end |
| 273 |
|
| 274 |
% Define =string, which is used by some PostScript programs even though |
| 275 |
% it isn't documented anywhere. |
| 276 |
% Put it in userdict so that each context can have its own copy. |
| 277 |
userdict /=string 256 string put |
| 278 |
|
| 279 |
% Print the greeting. |
| 280 |
|
| 281 |
/printgreeting |
| 282 |
{ mark |
| 283 |
product (GPL Ghostscript) search |
| 284 |
{ pop pop pop |
| 285 |
(This software is supplied under the GNU AGPLv3 and comes with NO WARRANTY:\nsee the file COPYING for details.\n) |
| 286 |
} |
| 287 |
{ pop |
| 288 |
} |
| 289 |
ifelse |
| 290 |
(\n) copyright |
| 291 |
(\)\n) revisiondate 10 mod revisiondate 10 idiv 10 mod (-) |
| 292 |
revisiondate 100 idiv 10 mod revisiondate 1000 idiv 10 mod (-) |
| 293 |
revisiondate 10000 idiv ( \() |
| 294 |
.revisionstring ( ) |
| 295 |
product |
| 296 |
counttomark |
| 297 |
{ (%stdout) (w) file exch 0 .writecvp |
| 298 |
} repeat pop |
| 299 |
} .forcebind def |
| 300 |
|
| 301 |
QUIET not { //printgreeting exec flush } if |
| 302 |
currentdict /printgreeting .undef |
| 303 |
|
| 304 |
% Define a special version of def for making operator procedures. |
| 305 |
/obind { % <name> <proc> obind <name> <oper> |
| 306 |
1 index exch .makeoperator |
| 307 |
} .forcebind def |
| 308 |
/odef { % <name> <proc> odef - |
| 309 |
1 index exch .makeoperator def |
| 310 |
} .forcebind def |
| 311 |
|
| 312 |
% Define procedures for accessing variables in systemdict and userdict |
| 313 |
% regardless of the contents of the dictionary stack. |
| 314 |
/.systemvar { % <name> .systemvar <value> |
| 315 |
//systemdict exch get |
| 316 |
} .forcebind odef |
| 317 |
/.systemexec { |
| 318 |
.systemvar exec |
| 319 |
} .forcebind odef |
| 320 |
/.userdict { % - .userdict <dict> |
| 321 |
/userdict .systemvar |
| 322 |
} .forcebind odef |
| 323 |
/.uservar { % <name> .uservar <value> |
| 324 |
.userdict exch get |
| 325 |
} .forcebind odef |
| 326 |
|
| 327 |
% If we're delaying binding, remember everything that needs to be bound later. |
| 328 |
DELAYBIND |
| 329 |
{ |
| 330 |
SAFER { |
| 331 |
(\n *** WARNING - you have selected SAFER, indicating you want Ghostscript\n) print |
| 332 |
( to execute in a safer environment, but at the same time\n) print |
| 333 |
( have selected DELAYBIND. Unless you use this option with\n) print |
| 334 |
( care \(and specifically, remember to call .bindnow\) it is\n) print |
| 335 |
( possible that malicious code may be able to evade the\n) print |
| 336 |
( limited security offered by the SAFER option.\n) print flush |
| 337 |
} if |
| 338 |
.currentglobal //false .setglobal |
| 339 |
systemdict /.delaybind 2000 array .forceput |
| 340 |
systemdict /.delayinternalbind 2000 array .forceput |
| 341 |
.setglobal |
| 342 |
userdict /.delaycount 0 put |
| 343 |
userdict /.delayinternalcount 0 put |
| 344 |
% When we've done the delayed bind, we want to stop saving. |
| 345 |
% Detect this by the disappearance of .delaybind. |
| 346 |
/bind |
| 347 |
{ /.delaybind .systemvar dup length 0 ne |
| 348 |
{ .delaycount 2 index put |
| 349 |
.userdict /.delaycount .delaycount 1 add put |
| 350 |
} |
| 351 |
{ pop /.bind cvx exec |
| 352 |
} |
| 353 |
ifelse |
| 354 |
} .forcebind odef |
| 355 |
|
| 356 |
/.internalbind |
| 357 |
{ /.delayinternalbind .systemvar dup length 0 ne |
| 358 |
{ .delayinternalcount 2 index put |
| 359 |
.userdict /.delayinternalcount .delayinternalcount 1 add put |
| 360 |
} |
| 361 |
{ pop /.forcebind cvx exec |
| 362 |
} |
| 363 |
ifelse |
| 364 |
} .forcebind odef |
| 365 |
} executeonly if |
| 366 |
|
| 367 |
.currentglobal //true .setglobal |
| 368 |
/.undefinternalnameslist 10 dict def |
| 369 |
.setglobal |
| 370 |
|
| 371 |
% Under normal operation .undefinternalnames simply removes |
| 372 |
% the keys in the array parameter from the dictionary parameter. |
| 373 |
% Under DELAYBIND operation, we accumulate the names in dictionaries, |
| 374 |
% stored in .undefinternalnameslist, and then .bindow calls |
| 375 |
% .applyundefinternalnames once all binds have been applied. |
| 376 |
% The .undefinternalnameslist dictionary is a little odd in that it |
| 377 |
% uses the dictionary from which the keys should be undefined as the |
| 378 |
% 'key' and then the value is a dictionary whose key/value pairs are |
| 379 |
% both the names to be undefined. |
| 380 |
% |
| 381 |
% [array of names] <<dict from which to undef>> .undefinternalnames - |
| 382 |
/.undefinternalnames |
| 383 |
{ |
| 384 |
DELAYBIND |
| 385 |
{ |
| 386 |
.currentglobal //true .setglobal 3 1 roll |
| 387 |
dup //.undefinternalnameslist exch .knownget not |
| 388 |
{ |
| 389 |
128 dict dup 3 1 roll |
| 390 |
//.undefinternalnameslist 3 1 roll put |
| 391 |
}{exch pop} ifelse |
| 392 |
exch |
| 393 |
{ |
| 394 |
dup 2 index 3 1 roll put |
| 395 |
} forall |
| 396 |
pop |
| 397 |
.setglobal |
| 398 |
} |
| 399 |
{ |
| 400 |
exch |
| 401 |
{ |
| 402 |
1 index exch .forceundef |
| 403 |
} executeonly forall |
| 404 |
pop |
| 405 |
} executeonly ifelse |
| 406 |
} .forcebind def |
| 407 |
|
| 408 |
/.applyundefinternalnames |
| 409 |
{ |
| 410 |
//.undefinternalnameslist |
| 411 |
{ |
| 412 |
{ |
| 413 |
pop |
| 414 |
1 index exch .forceundef |
| 415 |
} executeonly forall |
| 416 |
pop |
| 417 |
} executeonly forall |
| 418 |
} .forcebind def |
| 419 |
|
| 420 |
%**************** BACKWARD COMPATIBILITY **************** |
| 421 |
/hwsizedict mark /HWSize //null .dicttomark readonly def |
| 422 |
/copyscanlines { % <device> <y> <string> copyscanlines <substr> |
| 423 |
0 3 1 roll 3 index //hwsizedict .getdeviceparams |
| 424 |
exch pop exch pop aload pop 3 2 roll |
| 425 |
0 exch //null exch .getbitsrect exch pop |
| 426 |
} .internalbind odef |
| 427 |
currentdict /hwsizedict .undef |
| 428 |
/getdeviceprops |
| 429 |
{ //null .getdeviceparams |
| 430 |
} .internalbind odef |
| 431 |
|
| 432 |
% NOTE: Note sure why/if this needs to be a separate operator. Consider rolling this |
| 433 |
% implementation into /putdeviceprops ? |
| 434 |
/.putdeviceprops |
| 435 |
{ //null //true counttomark 1 add 3 roll .putdeviceparams |
| 436 |
dup type /booleantype ne |
| 437 |
{ dup mark eq { /unknown /rangecheck } if |
| 438 |
counttomark 4 add 1 roll cleartomark pop pop pop |
| 439 |
/.putdeviceprops .systemvar exch signalerror |
| 440 |
} |
| 441 |
if |
| 442 |
} .internalbind odef |
| 443 |
/.writecvs { 0 .writecvp } .internalbind odef |
| 444 |
|
| 445 |
%**************** DEPRECATED PROCEDURES **************** |
| 446 |
%**************** DO NOT USE THESE IN NEW CODE **************** |
| 447 |
% 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 |
| 448 |
/max { .max } .internalbind def % use .max instead |
| 449 |
/min { .min } .internalbind def % use .min instead |
| 450 |
%**************** END OF BACKWARD COMPATIBILITY SECTION **************** |
| 451 |
|
| 452 |
% Utility for removing all entries from a dictionary |
| 453 |
/.PurgeDict % <dict> .PurgeDict - |
| 454 |
{ { //true |
| 455 |
1 index { pop exch pop //false exit |
| 456 |
} forall |
| 457 |
{ exit |
| 458 |
} if |
| 459 |
1 index exch undef |
| 460 |
} loop |
| 461 |
pop |
| 462 |
} .internalbind def |
| 463 |
|
| 464 |
% Define predefined procedures substituting for operators, |
| 465 |
% in alphabetical order. |
| 466 |
|
| 467 |
userdict /#copies 1 put |
| 468 |
% Adobe implementations don't accept /[ or /], so we don't either. |
| 469 |
([) cvn |
| 470 |
/mark load def |
| 471 |
(]) cvn |
| 472 |
{counttomark array astore exch pop} odef |
| 473 |
% |
| 474 |
% - initgraphics - |
| 475 |
% |
| 476 |
% Although the internal routine gs_initgraphics resets the color space, |
| 477 |
% it does not reset the color space we store in the 'interpreter' |
| 478 |
% graphics state (so that we can hand it back in currentcolorspace). |
| 479 |
% So we need to do that in the PostScript world. |
| 480 |
% |
| 481 |
% |
| 482 |
/initgraphics |
| 483 |
{ initgraphics systemdict /DeviceGray_array get setcolorspace } |
| 484 |
.forcebind odef |
| 485 |
|
| 486 |
/currentmatrix { |
| 487 |
dup type /arraytype ne |
| 488 |
{ /currentmatrix load /typecheck signalerror } if |
| 489 |
dup length 6 ne |
| 490 |
{ /currentmatrix load /rangecheck signalerror } if |
| 491 |
.currentmatrix 6 .argindex astore pop |
| 492 |
} odef |
| 493 |
|
| 494 |
% We have to guard against the BeginPage procedure not popping its operand. |
| 495 |
% This is really stupid, but the Genoa CET does it. |
| 496 |
/.beginpage { % - .beginpage - |
| 497 |
.updatematrices |
| 498 |
.currentshowpagecount { |
| 499 |
.currentpagedevice pop |
| 500 |
dup //null ne { /BeginPage .knownget } { pop //false } ifelse { |
| 501 |
% Stack: ... pagecount proc |
| 502 |
count 2 .execn |
| 503 |
% Stack: ... ..???.. oldcount |
| 504 |
count 1 add exch sub { pop } repeat |
| 505 |
} { |
| 506 |
pop |
| 507 |
} ifelse |
| 508 |
} if |
| 509 |
} .forcebind odef |
| 510 |
|
| 511 |
% Guard similarly against EndPage not popping its operand. |
| 512 |
/.endpage { % <reason> .endpage <print_bool> |
| 513 |
.updatematrices |
| 514 |
.currentshowpagecount { |
| 515 |
1 index .currentpagedevice pop |
| 516 |
dup //null ne { /EndPage .knownget } { pop //false } ifelse { |
| 517 |
% Stack: ... reason pagecount reason proc |
| 518 |
count 2 .execn |
| 519 |
% Stack: ... ..???.. print oldcount |
| 520 |
count 2 add exch sub { exch pop } repeat |
| 521 |
} { |
| 522 |
pop pop 2 ne |
| 523 |
} ifelse |
| 524 |
} { |
| 525 |
2 ne |
| 526 |
} ifelse |
| 527 |
} .forcebind odef |
| 528 |
|
| 529 |
% Define .currentnumcopies so it consults the NumCopies device parameter. |
| 530 |
/.numcopiesdict mark |
| 531 |
/NumCopies dup |
| 532 |
.dicttomark readonly def |
| 533 |
/.currentnumcopies |
| 534 |
{ currentdevice //.numcopiesdict .getdeviceparams |
| 535 |
dup type /integertype eq |
| 536 |
{ exch pop exch pop } |
| 537 |
{ cleartomark #copies } |
| 538 |
ifelse |
| 539 |
} .forcebind odef |
| 540 |
|
| 541 |
/setcolorscreen where { pop % not in all Level 1 configurations |
| 542 |
/currentcolorscreen |
| 543 |
{ .currenthalftone |
| 544 |
{ { 60.0 exch 0.0 exch 3 copy 6 copy } % halftone - not possible |
| 545 |
{ 3 copy 6 copy } % screen |
| 546 |
{ } % colorscreen |
| 547 |
} |
| 548 |
exch get exec |
| 549 |
} odef |
| 550 |
} if |
| 551 |
/currentscreen |
| 552 |
{ .currenthalftone |
| 553 |
{ { 60.0 exch 0.0 exch } % halftone - not possible |
| 554 |
{ } % screen |
| 555 |
{ 12 3 roll 9 { pop } repeat } % colorscreen |
| 556 |
} |
| 557 |
exch get exec |
| 558 |
} odef |
| 559 |
/.echo /echo load def |
| 560 |
userdict /.echo.mode //true put |
| 561 |
/echo {dup /.echo.mode exch store .echo} odef |
| 562 |
/.eexec_param_dict mark |
| 563 |
/eexec //true |
| 564 |
/seed 55665 |
| 565 |
.dicttomark readonly def |
| 566 |
/eexec { |
| 567 |
% Rebind .currentresourcefile if it is the source for the eexec. |
| 568 |
dup //.eexec_param_dict //filterdict /eexecDecode get exec |
| 569 |
cvx exch .currentresourcefile eq |
| 570 |
//systemdict begin { {exec} .execasresource } { exec } ifelse |
| 571 |
% Only pop systemdict if it is still the top element, |
| 572 |
% because this is apparently what Adobe interpreters do. |
| 573 |
currentdict //systemdict eq { end } if |
| 574 |
} odef |
| 575 |
% erasepage mustn't use gsave/grestore, because we call it before |
| 576 |
% the graphics state stack has been fully initialized. |
| 577 |
/erasepage |
| 578 |
{ /currentcolor where |
| 579 |
{ pop currentcolor currentcolorspace { setcolorspace setcolor } } |
| 580 |
{ /currentcmykcolor where |
| 581 |
{ pop currentcmykcolor { setcmykcolor } } |
| 582 |
{ currentrgbcolor { setrgbcolor } } |
| 583 |
ifelse |
| 584 |
} |
| 585 |
ifelse |
| 586 |
currentoverprint //false setoverprint 1 setgray .fillpage setoverprint |
| 587 |
exec |
| 588 |
} odef |
| 589 |
% Define a procedure for clearing the error indication. |
| 590 |
/.clearerror |
| 591 |
{ $error /newerror //false put |
| 592 |
$error /errorname //null put |
| 593 |
$error /errorinfo //null put |
| 594 |
0 .setoserrno |
| 595 |
} .internalbind def |
| 596 |
|
| 597 |
% To satisfy the Genoa FTS, executive must be a procedure, not an operator. |
| 598 |
% Define the procedure used by .runfile, .runstdin and .runstring |
| 599 |
% for executing user input. |
| 600 |
% This is called with a procedure or executable file on the operand stack. |
| 601 |
/.execute { % <obj> .execute <stopped> |
| 602 |
stopped $error /newerror get and |
| 603 |
{ /handleerror .systemvar exec flush //true } { //false } ifelse |
| 604 |
} .internalbind def |
| 605 |
% Define an execute analogue of runlibfile0. |
| 606 |
/execute0 { % <obj> execute0 - |
| 607 |
//.execute exec { /execute0 cvx 1 .quit } if |
| 608 |
} .internalbind def |
| 609 |
/executive |
| 610 |
{ { prompt |
| 611 |
{ (%statementedit) (r) .systemvmfile } stopped |
| 612 |
{ pop pop $error /errorname get /undefinedfilename eq |
| 613 |
{ //.clearerror exec exit } if % EOF |
| 614 |
/handleerror .systemvar exec //null % ioerror?? |
| 615 |
} |
| 616 |
if |
| 617 |
cvx { .runexec } //.execute exec pop |
| 618 |
} loop |
| 619 |
} .internalbind def |
| 620 |
currentdict /.execute .undef |
| 621 |
|
| 622 |
/filter |
| 623 |
{ //filterdict 1 .argindex .knownget |
| 624 |
{ exch pop exec } |
| 625 |
{ /filter .systemvar /undefined signalerror } |
| 626 |
ifelse |
| 627 |
} odef |
| 628 |
% Internal uses of stopped that aren't going to do a stop if an error occurs |
| 629 |
% should use .internalstopped to avoid setting newerror et al. |
| 630 |
/.internalstopped { //null 1 .stopped //null ne } .internalbind def |
| 631 |
% handleerror procedure as mentioned in the "Operators" section of the PLRM Section 8.2 |
| 632 |
% This invokes the handleerror procedure from errordict (unless we are running under a |
| 633 |
% JOBSERVER where we want to always use a defined error handler (many error handlers in |
| 634 |
% 'wild' PostScript files are broken and don't indicate the error in any useful fashion). |
| 635 |
% |
| 636 |
% We run the handleerror procedure using .internalstopped so that broken error handlers |
| 637 |
% won't cause nested errors (Unexpected Error conditions). |
| 638 |
/handleerror |
| 639 |
//systemdict /JOBSERVER get{ |
| 640 |
{ /.GShandleerror .systemvar //.internalstopped exec pop } .internalbind % always use .GShandleerror. |
| 641 |
} { |
| 642 |
{ /errordict .systemvar /handleerror get //.internalstopped exec pop } .internalbind % PLRM standard errorhandling |
| 643 |
} ifelse def |
| 644 |
/identmatrix [1.0 0.0 0.0 1.0 0.0 0.0] readonly def |
| 645 |
/identmatrix { |
| 646 |
dup type /arraytype ne { /identmatrix load /typecheck signalerror } if |
| 647 |
dup length 6 ne { /identmatrix load /rangecheck signalerror } if |
| 648 |
dup 0 //identmatrix putinterval |
| 649 |
} odef |
| 650 |
/languagelevel 1 def % gs_lev2.ps may change this |
| 651 |
/makeimagedevice { //false makewordimagedevice } odef |
| 652 |
/matrix { 6 array identmatrix } odef |
| 653 |
|
| 654 |
/.promptmsg { |
| 655 |
(GS) print |
| 656 |
count 0 ne { (<) print count =only } if |
| 657 |
(>) print flush |
| 658 |
} .internalbind def |
| 659 |
/prompt { flush flushpage //systemdict /NOPROMPT get not { //.promptmsg exec} if } .internalbind def |
| 660 |
currentdict /.promptmsg .undef |
| 661 |
|
| 662 |
/pstack { 0 1 count 3 sub { index == } for } .internalbind def |
| 663 |
/putdeviceprops |
| 664 |
{ .putdeviceprops { erasepage } if } .internalbind odef |
| 665 |
/quit { /quit load 0 .quit } odef |
| 666 |
/run { dup type /filetype ne { (r) .systemvmfile } if |
| 667 |
% We must close the file when execution terminates, |
| 668 |
% regardless of the state of the stack, |
| 669 |
% and then propagate an error, if any. |
| 670 |
cvx //null {.runexec} .errorexec |
| 671 |
} odef |
| 672 |
% Execute a file. |
| 673 |
% Level 2 uses 2 .stop to clear the e-stack for a successful startjob: |
| 674 |
% we detect that here, since we need to handle this even if we start out |
| 675 |
% without job control in effect. |
| 676 |
% |
| 677 |
% What we push on the e-stack is the following to be executed in this order: |
| 678 |
% <lit-file|fileproc> .runexec1 <lit-file|fileproc> .runexec2 |
| 679 |
/.runexec1 { % <file|fileproc> .runexec1 - |
| 680 |
dup type /filetype ne { cvx exec } if |
| 681 |
cvx //null 2 .stopped |
| 682 |
% If we got back here from a startjob, just keep going. |
| 683 |
% startjob replaces the null on the o-stack with a procedure |
| 684 |
% to be executed when we get back here. |
| 685 |
dup //null ne { exec //true } { pop //false } ifelse |
| 686 |
} .internalbind def |
| 687 |
/.runexec2 { % <continue> <file|fileproc> .runexec2 - |
| 688 |
exch { |
| 689 |
.runexec |
| 690 |
} { |
| 691 |
dup type /filetype ne { cvx exec } if |
| 692 |
closefile |
| 693 |
} ifelse |
| 694 |
} .internalbind def |
| 695 |
/.runexec { % <file|fileproc> .runexec - |
| 696 |
cvlit /.runexec1 cvx 1 index /.runexec2 cvx 4 .execn |
| 697 |
} .internalbind def |
| 698 |
% The following is only for compatibility with Adobe interpreters. |
| 699 |
/setdash { |
| 700 |
0 .argindex type dup /integertype eq exch /realtype eq or not { |
| 701 |
/setdash .systemvar /typecheck signalerror |
| 702 |
} if |
| 703 |
//setdash |
| 704 |
} odef |
| 705 |
/setdevice |
| 706 |
{ |
| 707 |
.setdevice |
| 708 |
{ |
| 709 |
mark |
| 710 |
{ % Reset the halftone since the device may differ |
| 711 |
currenthalftone |
| 712 |
dup type /dicttype eq |
| 713 |
{ sethalftone } |
| 714 |
{ pop } |
| 715 |
ifelse |
| 716 |
} |
| 717 |
stopped |
| 718 |
cleartomark |
| 719 |
erasepage |
| 720 |
} |
| 721 |
if |
| 722 |
} |
| 723 |
odef |
| 724 |
/setlinecap { |
| 725 |
dup 2 gt { /setlinecap .systemvar /rangecheck signalerror } if |
| 726 |
.setlinecap |
| 727 |
} odef |
| 728 |
/setlinejoin { |
| 729 |
dup 2 gt { /setlinejoin .systemvar /rangecheck signalerror } if |
| 730 |
.setlinejoin |
| 731 |
} odef |
| 732 |
/setmatrix { |
| 733 |
dup type /arraytype ne { |
| 734 |
dup type /packedarraytype ne { |
| 735 |
/setmatrix load /typecheck signalerror |
| 736 |
} if |
| 737 |
} if |
| 738 |
dup length 6 ne { /setmatrix load /rangecheck signalerror } if |
| 739 |
dup aload pop .setmatrix pop |
| 740 |
} odef |
| 741 |
|
| 742 |
/.confirmread { |
| 743 |
//systemdict /TTYPAUSE get { |
| 744 |
(/dev/tty) (r) file dup read pop pop closefile |
| 745 |
} { |
| 746 |
.echo.mode //false echo |
| 747 |
(%stdin) (r) file dup read { |
| 748 |
dup (\n) 0 get eq { pop pop } { .unread } ifelse |
| 749 |
} { |
| 750 |
pop |
| 751 |
} ifelse echo |
| 752 |
} ifelse |
| 753 |
} .internalbind def |
| 754 |
|
| 755 |
/.confirm { |
| 756 |
//systemdict /DISPLAYING get //systemdict /NOPAUSE get not //systemdict /TTYPAUSE get or and { |
| 757 |
% Print a message (unless NOPAGEPROMPT or NOPROMPT is true) |
| 758 |
% and wait for the user to type something. |
| 759 |
% If the user just types a newline, flush it. |
| 760 |
//systemdict /NOPAGEPROMPT get //systemdict /NOPROMPT get or { pop } { print flush } ifelse |
| 761 |
//.confirmread exec |
| 762 |
} { |
| 763 |
pop |
| 764 |
} ifelse |
| 765 |
} .internalbind def |
| 766 |
|
| 767 |
% In LanguageLevel 3, copypage erases the page. |
| 768 |
/copypage { |
| 769 |
.languagelevel 3 ge |
| 770 |
dup { 0 } { 1 } ifelse .endpage .doneshowpage { |
| 771 |
.currentnumcopies 1 index .outputpage |
| 772 |
(>>copypage, press <return> to continue<<\n) //.confirm exec |
| 773 |
dup { erasepage } if |
| 774 |
} if pop |
| 775 |
systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if |
| 776 |
.beginpage |
| 777 |
} .forcebind odef |
| 778 |
|
| 779 |
/showpage { |
| 780 |
0 .endpage .doneshowpage { |
| 781 |
.currentnumcopies //true .outputpage |
| 782 |
(>>showpage, press <return> to continue<<\n) //.confirm exec |
| 783 |
% Uncomment the following line, and use a Memento build to track |
| 784 |
% blocks that are created and not destroyed between each successive |
| 785 |
% page. |
| 786 |
% 2 .vmreclaim .mementolistnewblocks |
| 787 |
initgraphics |
| 788 |
currentoverprint //false setoverprint 1 setcolor |
| 789 |
.fillpage |
| 790 |
setoverprint 0 setcolor |
| 791 |
} |
| 792 |
{ initgraphics } ifelse |
| 793 |
systemdict /..page_default_spaces .knownget { //.PurgeDict exec } if |
| 794 |
.beginpage |
| 795 |
} .forcebind odef |
| 796 |
|
| 797 |
% Code output by Adobe Illustrator relies on the fact that |
| 798 |
% `stack' is a procedure, not an operator!!! |
| 799 |
/stack { 0 1 count 3 sub { index = } for } .internalbind def |
| 800 |
/start { //systemdict /BATCH get { //null 0 .quit } { executive } ifelse } def |
| 801 |
/store { % Don't alter operands before completing. |
| 802 |
1 .argindex where { 2 index 2 index put pop pop } { def } ifelse |
| 803 |
} odef |
| 804 |
/.typenames mark .typenames counttomark packedarray exch pop def |
| 805 |
/type { |
| 806 |
//.typenames .type |
| 807 |
} odef |
| 808 |
currentdict /.typenames .undef |
| 809 |
% When running in Level 1 mode, this interpreter is supposed to be |
| 810 |
% compatible with PostScript "version" 54.0 (I think). |
| 811 |
/version (54.0) readonly def |
| 812 |
/.wheredict 10 dict def |
| 813 |
/.where /where load def |
| 814 |
/where { |
| 815 |
//.wheredict 1 .argindex .knownget { exec } { .where } ifelse |
| 816 |
} odef |
| 817 |
|
| 818 |
% internaldict is defined in systemdict, but the dictionary is allocated |
| 819 |
% in local VM. However, the procedure must be global, since it is an |
| 820 |
% "operator" and must be bind-able into global procedures. |
| 821 |
/.makeinternaldict { |
| 822 |
.currentglobal //true .setglobal |
| 823 |
[ /dup .systemvar 1183615869 /eq .systemvar |
| 824 |
[ /pop .systemvar //null ] cvx |
| 825 |
//false .setglobal |
| 826 |
dup 1 10 dict .forceput % proc is global, dict is local |
| 827 |
//true .setglobal |
| 828 |
[ /internaldict /cvx .systemvar /invalidaccess /signalerror cvx ] cvx |
| 829 |
/ifelse .systemvar |
| 830 |
] cvx executeonly |
| 831 |
exch .setglobal |
| 832 |
} def |
| 833 |
systemdict /internaldict dup .makeinternaldict .makeoperator |
| 834 |
.forceput % proc is local, systemdict is global |
| 835 |
currentdict /.makeinternaldict .undef |
| 836 |
|
| 837 |
% Define some additional built-in procedures (beyond the ones defined by |
| 838 |
% the PostScript Language Reference Manual). |
| 839 |
% Warning: these are not guaranteed to stay the same from one release |
| 840 |
% to the next! |
| 841 |
/concatstrings % (str1) (str2) concatstrings (str1str2) |
| 842 |
{ exch dup length 2 index length add string % str2 str1 new |
| 843 |
dup dup 4 2 roll copy % str2 new new new1 |
| 844 |
length 4 -1 roll putinterval |
| 845 |
} .internalbind def |
| 846 |
/copyarray |
| 847 |
{ dup length array copy } .internalbind def |
| 848 |
% Copy a dictionary per the Level 2 spec even in Level 1. |
| 849 |
/.copydict % <fromdict> <todict> .copydict <todict> |
| 850 |
{ dup 3 -1 roll { put dup } forall pop } .internalbind def |
| 851 |
/findlibfile { |
| 852 |
.systemvmlibfile { dup .filename pop exch //true } { //false } ifelse |
| 853 |
} odef |
| 854 |
/.growdictlength % get size for growing a dictionary |
| 855 |
{ length 3 mul 2 idiv 1 add |
| 856 |
} .internalbind def |
| 857 |
/.growdict % grow a dictionary |
| 858 |
{ dup //.growdictlength exec .setmaxlength |
| 859 |
} .internalbind def |
| 860 |
/.growput % put, grow the dictionary if needed |
| 861 |
{ 2 index length 3 index maxlength eq |
| 862 |
{ 3 copy pop known not { 2 index //.growdict exec} if |
| 863 |
} if |
| 864 |
put |
| 865 |
} .internalbind def |
| 866 |
% .localvmarray may be an operator: see zsysvm.c. |
| 867 |
/.localvmarray where { |
| 868 |
pop |
| 869 |
} { |
| 870 |
/.localvmarray { |
| 871 |
.currentglobal //false .setglobal |
| 872 |
exch array exch .setglobal |
| 873 |
} .internalbind def |
| 874 |
} ifelse |
| 875 |
/.localvmdict where { |
| 876 |
pop |
| 877 |
} { |
| 878 |
/.localvmdict { |
| 879 |
.currentglobal //false .setglobal |
| 880 |
exch dict exch .setglobal |
| 881 |
} .internalbind def |
| 882 |
} ifelse |
| 883 |
/.packtomark |
| 884 |
{ counttomark packedarray exch pop } .internalbind def |
| 885 |
/runlibfile |
| 886 |
{ % We don't want to .internalbind 'run' into this procedure, |
| 887 |
% since run may get redefined. |
| 888 |
findlibfile |
| 889 |
{ exch pop /run .systemvar exec } |
| 890 |
{ /undefinedfilename signalerror } |
| 891 |
ifelse |
| 892 |
} .internalbind def |
| 893 |
/signalerror % <object> <errorname> signalerror - |
| 894 |
{ /errordict .systemvar exch get exec } .internalbind def |
| 895 |
/signaloperror { % <object> <errorname> signaloperror - |
| 896 |
% Same as signalerror, except that if we are inside a pseudo-operator |
| 897 |
% or .errorexec, we use its error object, just as errors generated by |
| 898 |
% real operators do. |
| 899 |
/errordict .systemvar exch get |
| 900 |
.finderrorobject { 3 -1 roll pop exch } if |
| 901 |
exec |
| 902 |
} .internalbind def |
| 903 |
|
| 904 |
% Define the =[only] procedures. Also define =print, |
| 905 |
% which is used by some PostScript programs even though |
| 906 |
% it isn't documented anywhere. |
| 907 |
/write=only { |
| 908 |
.writecvs |
| 909 |
} .internalbind def |
| 910 |
/write= { |
| 911 |
1 index exch write=only (\n) writestring |
| 912 |
} .internalbind def |
| 913 |
/=only { (%stdout) (w) file exch write=only } .internalbind odef |
| 914 |
/= { =only (\n) print } .internalbind def |
| 915 |
/=print /=only load def |
| 916 |
% Temporarily define == as = for the sake of runlibfile0. |
| 917 |
/== /= load def |
| 918 |
|
| 919 |
% Function to purge a named device from the device cache. This is required if we |
| 920 |
% want to 'reset' a device. The setpagedevice implementation, when it creates a |
| 921 |
% device instance, stores it in a cache. Next time we select a device we look in |
| 922 |
% the cache and, if we find we cached it, then we use the cached device. |
| 923 |
% |
| 924 |
% Presumably this is intended as an optimisation, but it defeats the expected use |
| 925 |
% of save and restore wihth devices because, after we restore a device away it is |
| 926 |
% not destroyed, it is in the cache. Requesting the same named device will return |
| 927 |
% the cached device, crucially *without* resetting any of its parameters. In |
| 928 |
% particular NumPages which is used to number output files and is a read-only parameter. |
| 929 |
% |
| 930 |
% /name uncachedevice - |
| 931 |
% |
| 932 |
/uncachedevice |
| 933 |
{ |
| 934 |
% Check we've been given a name |
| 935 |
dup type /nametype eq |
| 936 |
{ |
| 937 |
% Check the name isn't the current device. Check both /Name |
| 938 |
% and /OutputDevice. There seem to be some conditions where |
| 939 |
% only one is present. |
| 940 |
% |
| 941 |
currentpagedevice /Name known |
| 942 |
{ |
| 943 |
dup currentpagedevice /Name get eq |
| 944 |
} |
| 945 |
{ |
| 946 |
//false |
| 947 |
}ifelse |
| 948 |
currentpagedevice /OutputDevice known |
| 949 |
{ |
| 950 |
1 index currentpagedevice /OutputDevice get eq |
| 951 |
} |
| 952 |
{ |
| 953 |
//false |
| 954 |
}ifelse |
| 955 |
|
| 956 |
% We tested /Name and /OutputDevice to see if they exist, if they do |
| 957 |
% we checked them against the requested device. If either matches the requested |
| 958 |
% device we report an error, otherwise we remove the device from the cache. |
| 959 |
% |
| 960 |
or |
| 961 |
{ |
| 962 |
(*** ERROR: Can't uncache the current device\n) print |
| 963 |
/uncachedevice /invalidaccess signalerror |
| 964 |
} |
| 965 |
{ |
| 966 |
% Make sure devicedict exists, if it does not, ignore |
| 967 |
% the request because this code doesn't know how to |
| 968 |
% deal with this PostScript itnerpreter. |
| 969 |
/devicedict where |
| 970 |
{ |
| 971 |
% Get devicedict out of its containing dictionary |
| 972 |
/devicedict get dup % stack: /device -devicedict- -devicedict- |
| 973 |
|
| 974 |
% Check if the device we were given is known |
| 975 |
2 index known % stack: /device -devicedict- bool |
| 976 |
{ |
| 977 |
% device was known, get the key/value pair from devicedict |
| 978 |
dup 2 index get % stack: /device -devicedict- value |
| 979 |
|
| 980 |
% We expect the value in devicedict to be an array, check it is |
| 981 |
dup type /arraytype eq |
| 982 |
{ |
| 983 |
dup 1 null put % stack: /device -devicedict- [-device- null] |
| 984 |
3 -1 roll exch % stack: -devicedict- /device [-device- null] |
| 985 |
put % stack: - |
| 986 |
} |
| 987 |
{ |
| 988 |
% Value in devicedict associated with the named key is not an array |
| 989 |
/uncachedevice /typecheck signalerror |
| 990 |
} ifelse |
| 991 |
} |
| 992 |
{ |
| 993 |
% The named key is not present in devicedict |
| 994 |
/uncachedevice /undefined signalerror |
| 995 |
} ifelse |
| 996 |
} if |
| 997 |
} ifelse |
| 998 |
} |
| 999 |
{ |
| 1000 |
% The parameter we were given wasn't a name type |
| 1001 |
/uncachedevice /typecheck signalerror |
| 1002 |
} ifelse |
| 1003 |
} bind readonly odef |
| 1004 |
|
| 1005 |
% Function to purge all but the current device from the device cache |
| 1006 |
% |
| 1007 |
% - purgedevicecache - |
| 1008 |
% |
| 1009 |
/purgedevicecache |
| 1010 |
{ |
| 1011 |
% Find devicedict, if it doesn't exist just exit silently, we don't know |
| 1012 |
% how to deal with this PostScript interpreter |
| 1013 |
/devicedict where |
| 1014 |
{ |
| 1015 |
% Get devicedict from the containing dictionary |
| 1016 |
/devicedict get |
| 1017 |
% For each key/value pair in devicedict |
| 1018 |
{ |
| 1019 |
pop % Discard the value |
| 1020 |
dup currentpagedevice /Name get eq not % Check if the key is the same as the current device |
| 1021 |
{ |
| 1022 |
uncachedevice % If not, purge the device from the cache |
| 1023 |
} |
| 1024 |
{ |
| 1025 |
pop % Don't purge the current device |
| 1026 |
} ifelse |
| 1027 |
} forall |
| 1028 |
} if |
| 1029 |
} bind readonly odef |
| 1030 |
|
| 1031 |
/finddevice { % <devicename> finddevice <device> |
| 1032 |
/devicedict .systemvar exch get |
| 1033 |
dup 1 get //null eq { |
| 1034 |
% This is the first request for this type of device. |
| 1035 |
% Create a default instance now. |
| 1036 |
% Stack: [proto null] |
| 1037 |
.currentglobal //true .setglobal exch |
| 1038 |
dup dup 0 get //false .copydevice2 1 exch put |
| 1039 |
exch .setglobal |
| 1040 |
} if 1 get |
| 1041 |
} .internalbind odef |
| 1042 |
|
| 1043 |
% The following procedures are documented. |
| 1044 |
|
| 1045 |
% Run a resource file. This allows us to distinguish resource objects |
| 1046 |
% from objects coming from input files. |
| 1047 |
userdict /.currentresourcefile //null put |
| 1048 |
/.execasresource { % <file> <proc|runfile> .execasresource - |
| 1049 |
/stopped .systemvar |
| 1050 |
/.currentresourcefile .uservar |
| 1051 |
% Stack: file proc -stopped- currfile |
| 1052 |
.userdict /.currentresourcefile 5 index cvlit put |
| 1053 |
2 .execn % stopped <file> |
| 1054 |
.userdict /.currentresourcefile 3 -1 roll put |
| 1055 |
{ stop } if |
| 1056 |
} .internalbind def |
| 1057 |
/.runresource { % <file> .runresource - |
| 1058 |
{ /run .systemvar exec } .execasresource |
| 1059 |
} .internalbind def |
| 1060 |
|
| 1061 |
% Convenience function (documented extension) |
| 1062 |
/.shellarguments % -> shell_arguments true (or) false |
| 1063 |
{ /ARGUMENTS where |
| 1064 |
{ /ARGUMENTS get dup type /arraytype eq |
| 1065 |
{ aload pop /ARGUMENTS //null store //true } |
| 1066 |
{ pop //false } |
| 1067 |
ifelse } |
| 1068 |
{ //false } ifelse |
| 1069 |
} .internalbind def |
| 1070 |
|
| 1071 |
% Define the procedure that the C code uses for running files |
| 1072 |
% named on the command line. |
| 1073 |
/.runfile { |
| 1074 |
{ runlibfile } execute0 |
| 1075 |
} def |
| 1076 |
% Define the procedure that the C code uses for running piped input. |
| 1077 |
% We don't use the obvious { (%stdin) run }, because we want the file to be |
| 1078 |
% reopened if a startjob does a restore. |
| 1079 |
/.runstdin { |
| 1080 |
{ { (%stdin) (r) file cvx } .runexec } execute0 |
| 1081 |
} .internalbind def |
| 1082 |
% Define the procedure that the C code uses for running commands |
| 1083 |
% given on the command line with -c. We turn the string into a file so that |
| 1084 |
% .runexec can do the right thing with a startjob. |
| 1085 |
/.runstring { |
| 1086 |
0 0 .systemvmstring .systemvmSFD cvx { .runexec } execute0 |
| 1087 |
} .internalbind def |
| 1088 |
|
| 1089 |
% Define the procedure that the C code uses to set up for executing |
| 1090 |
% a string that may be received in pieces. |
| 1091 |
% |
| 1092 |
% Immediate evaluation doesn't work on operators (like .needinput) |
| 1093 |
% so calling .runstringbegin will throw an undefined error if we |
| 1094 |
% undefined .needinput so it cannot be accessed outside the init |
| 1095 |
% code. But, we can store the operator in an array, use immediate |
| 1096 |
% evaluation on the array to get the operator, then undefined the |
| 1097 |
% array (and because they are both of the same name, the operator |
| 1098 |
% get undefined too). |
| 1099 |
% This prevents random Postscript from erroneously calling .needinput |
| 1100 |
% and forcing the interpreter into an invalid state. |
| 1101 |
/.needinput |
| 1102 |
1 .systemvmarray dup 0 /.needinput load put |
| 1103 |
def |
| 1104 |
/.runstringbegin { |
| 1105 |
1 .systemvmarray dup 0 //.needinput 0 get put cvx % { .needinput } in systemvm |
| 1106 |
0 0 .systemvmstring .systemvmSFD cvx .runexec |
| 1107 |
} .internalbind def |
| 1108 |
|
| 1109 |
% Define a special version of runlibfile that aborts on errors. |
| 1110 |
/runlibfile0 |
| 1111 |
{ cvlit dup dup /.currentfilename exch def |
| 1112 |
{ findlibfile not { stop } if } |
| 1113 |
stopped |
| 1114 |
{ (Can't find \(or open\) initialization file ) print |
| 1115 |
.currentfilename == flush /runlibfile0 cvx 1 .quit |
| 1116 |
} if |
| 1117 |
exch pop cvx |
| 1118 |
{ stopped } 0 get 3 -1 roll 2 array astore cvx exec |
| 1119 |
/.currentfilename exch store |
| 1120 |
{ (While reading ) print .currentfilename print (:\n) print flush |
| 1121 |
/handleerror .systemvar exec /runlibfile0 1 .quit |
| 1122 |
} if |
| 1123 |
} .internalbind def |
| 1124 |
% Temporarily substitute it for the real runlibfile. |
| 1125 |
/.runlibfile /runlibfile load def |
| 1126 |
/runlibfile //runlibfile0 def |
| 1127 |
currentdict /runlibfile0 .undef |
| 1128 |
|
| 1129 |
% Create the error handling machinery. |
| 1130 |
% Define the standard error handlers. |
| 1131 |
% The interpreter has created the ErrorNames array. |
| 1132 |
/.unstoppederrorhandler % <command> <errorname> .unstoppederrorhandler - |
| 1133 |
{ % This is the handler that gets used for recursive errors, |
| 1134 |
% or errors outside the scope of a 'stopped'. |
| 1135 |
2 copy //systemdict /SHORTERRORS get |
| 1136 |
{ (%%[ Error: ) print =only flush |
| 1137 |
(; OffendingCommand: ) print =only ( ]%%) = |
| 1138 |
} |
| 1139 |
{ (Unrecoverable error: ) print =only flush |
| 1140 |
( in ) print =only (\n) print flush |
| 1141 |
count 2 gt |
| 1142 |
{ (Operand stack:\n ) print |
| 1143 |
count 1 sub -1 2 { ( ) print index =only flush } for |
| 1144 |
(\n) =only flush |
| 1145 |
} if |
| 1146 |
} |
| 1147 |
ifelse |
| 1148 |
-1 0 1 //ErrorNames length 1 sub |
| 1149 |
{ dup //ErrorNames exch get 3 index eq |
| 1150 |
{ not exch pop exit } { pop } ifelse |
| 1151 |
} |
| 1152 |
for exch pop .quit |
| 1153 |
} .internalbind def |
| 1154 |
/.acquire_$error { |
| 1155 |
//systemdict /$error get |
| 1156 |
} .internalbind def |
| 1157 |
|
| 1158 |
/.errorhandler % <command> <errorname> .errorhandler - |
| 1159 |
{ % Detect an internal 'stopped'. |
| 1160 |
1 .instopped { //null eq { pop pop stop } if } if |
| 1161 |
//.acquire_$error exec /.inerror get 1 .instopped { pop } { pop //true } ifelse |
| 1162 |
{ //.unstoppederrorhandler exec |
| 1163 |
} if % detect error recursion |
| 1164 |
//.acquire_$error exec /globalmode .currentglobal //false .setglobal put |
| 1165 |
//.acquire_$error exec /.inerror //true put |
| 1166 |
//.acquire_$error exec /newerror //true put |
| 1167 |
//.acquire_$error exec exch /errorname exch put |
| 1168 |
//.acquire_$error exec exch /command exch put |
| 1169 |
//.acquire_$error exec /errorinfo known not { //.acquire_$error exec /errorinfo //null put } if |
| 1170 |
//.acquire_$error exec /recordstacks get //.acquire_$error exec /errorname get /VMerror ne and |
| 1171 |
{ % Attempt to store the stack contents atomically. |
| 1172 |
count array astore dup //.acquire_$error exec /ostack 4 -1 roll |
| 1173 |
% Grab the execstack, then remove to two elements that are from |
| 1174 |
% this error handler (not interesting). |
| 1175 |
countexecstack array execstack dup length 2 sub 0 exch getinterval |
| 1176 |
//.acquire_$error exec /estack 3 -1 roll |
| 1177 |
countdictstack array dictstack //.acquire_$error exec /dstack 3 -1 roll |
| 1178 |
put put put aload pop |
| 1179 |
} |
| 1180 |
{ //.acquire_$error exec /dstack .undef |
| 1181 |
//.acquire_$error exec /estack .undef |
| 1182 |
//.acquire_$error exec /ostack .undef |
| 1183 |
} |
| 1184 |
ifelse |
| 1185 |
//.acquire_$error exec /position currentfile status |
| 1186 |
{ currentfile { fileposition } //.internalstopped exec { pop //null } if |
| 1187 |
} |
| 1188 |
{ % If this was a scanner error, the file is no longer current, |
| 1189 |
% but the command holds the file, which may still be open. |
| 1190 |
//.acquire_$error exec /command get dup type /filetype eq |
| 1191 |
{ { fileposition } //.internalstopped exec { pop //null } if } |
| 1192 |
{ pop //null } |
| 1193 |
ifelse |
| 1194 |
} |
| 1195 |
ifelse put |
| 1196 |
% During initialization, we don't reset the allocation |
| 1197 |
% mode on errors. |
| 1198 |
//.acquire_$error exec /globalmode get //.acquire_$error exec /.nosetlocal get and .setglobal |
| 1199 |
//.acquire_$error exec /.inerror //false put |
| 1200 |
stop |
| 1201 |
} .internalbind def |
| 1202 |
currentdict /.unstoppederrorhandler .undef |
| 1203 |
|
| 1204 |
% Define the standard handleerror. We break out the printing procedure |
| 1205 |
% (.printerror) so that it can be extended for binary output |
| 1206 |
% if the Level 2 facilities are present. |
| 1207 |
/.printerror_long % long error printout, |
| 1208 |
% $error is on the dict stack |
| 1209 |
{ % Push the (anonymous) stack printing procedure. |
| 1210 |
% <heading> <==flag> <override-name> <stackname> proc |
| 1211 |
{ |
| 1212 |
currentdict exch .knownget % stackname defined in $error? |
| 1213 |
{ |
| 1214 |
4 1 roll % stack: <stack> <head> <==flag> <over> |
| 1215 |
/errordict .systemvar exch .knownget % overridename defined? |
| 1216 |
{ |
| 1217 |
exch pop exch pop exec % call override with <stack> |
| 1218 |
} |
| 1219 |
{ |
| 1220 |
exch print exch % print heading. stack <==flag> <stack> |
| 1221 |
1 index not { (\n) =only } if |
| 1222 |
{ 1 index { (\n ) } { ( ) } ifelse print |
| 1223 |
dup type /dicttype eq |
| 1224 |
{ |
| 1225 |
(--dict:) print |
| 1226 |
dup rcheck { |
| 1227 |
dup length =only (/) print dup maxlength =only |
| 1228 |
dup wcheck not { ((ro)) print } if |
| 1229 |
} if |
| 1230 |
/gcheck where { |
| 1231 |
pop gcheck { ((G)) } { ((L)) } ifelse print |
| 1232 |
} { |
| 1233 |
pop |
| 1234 |
} ifelse (--) print |
| 1235 |
} |
| 1236 |
{ |
| 1237 |
dup type /stringtype eq 2 index or |
| 1238 |
{ ==only } { =only } ifelse |
| 1239 |
} ifelse |
| 1240 |
} forall |
| 1241 |
pop |
| 1242 |
} |
| 1243 |
ifelse % overridden |
| 1244 |
} |
| 1245 |
{ pop pop pop |
| 1246 |
} |
| 1247 |
ifelse % stack known |
| 1248 |
} |
| 1249 |
|
| 1250 |
(\nOperand stack:) OSTACKPRINT /.printostack /ostack 4 index exec |
| 1251 |
(\nExecution stack:) ESTACKPRINT /.printestack /estack 4 index exec |
| 1252 |
(\nBacktrace:) //true /.printbacktrace /backtrace 4 index exec |
| 1253 |
(\nDictionary stack:) //false /.printdstack /dstack 4 index exec |
| 1254 |
() = |
| 1255 |
pop % printing procedure |
| 1256 |
|
| 1257 |
errorname /VMerror eq |
| 1258 |
{ (VM status:) print mark vmstatus |
| 1259 |
counttomark { ( ) print counttomark -1 roll dup =only } repeat |
| 1260 |
cleartomark (\n) =only |
| 1261 |
} if |
| 1262 |
|
| 1263 |
.languagelevel 2 ge |
| 1264 |
{ (Current allocation mode is ) print |
| 1265 |
globalmode { (global\n) } { (local\n) } ifelse print |
| 1266 |
} if |
| 1267 |
|
| 1268 |
.oserrno dup 0 ne |
| 1269 |
{ (Last OS error: ) print |
| 1270 |
errorname /VMerror ne |
| 1271 |
{ dup .oserrorstring { =only (\n) print pop } { =only (\n) print } ifelse } |
| 1272 |
{ =only } |
| 1273 |
ifelse |
| 1274 |
} |
| 1275 |
{ pop |
| 1276 |
} |
| 1277 |
ifelse |
| 1278 |
|
| 1279 |
position //null ne |
| 1280 |
{ (Current file position is ) print position = } |
| 1281 |
if |
| 1282 |
|
| 1283 |
} .internalbind def |
| 1284 |
/.printerror |
| 1285 |
{ |
| 1286 |
//.acquire_$error exec begin newerror |
| 1287 |
{ |
| 1288 |
/command load errorname //systemdict /SHORTERRORS get |
| 1289 |
{ (%%[ Error: ) print =only flush |
| 1290 |
(; OffendingCommand: ) print =only |
| 1291 |
errorinfo dup //null eq { |
| 1292 |
pop |
| 1293 |
} { |
| 1294 |
(;\nErrorInfo:) print |
| 1295 |
dup type /arraytype eq |
| 1296 |
{ { ( ) print =only } forall } |
| 1297 |
{ ( ) print =only } |
| 1298 |
ifelse |
| 1299 |
} ifelse |
| 1300 |
( ]%%) = flush |
| 1301 |
} |
| 1302 |
{ (Error: ) print ==only flush |
| 1303 |
( in ) print ==only flush |
| 1304 |
errorinfo dup //null eq { |
| 1305 |
pop |
| 1306 |
} { |
| 1307 |
(\nAdditional information: ) print ==only flush |
| 1308 |
} ifelse |
| 1309 |
//.printerror_long exec |
| 1310 |
} |
| 1311 |
ifelse |
| 1312 |
//.clearerror exec flush |
| 1313 |
} |
| 1314 |
{ % newerror is //false, test to see if user has set handleerror to a different |
| 1315 |
% routine, if so execute it, otherwise, just return. This code deals with the |
| 1316 |
% Genoa issue of setting /handleerror, and then calling it, without an error |
| 1317 |
% being set. We were erroring in this case, due to /command load failing. |
| 1318 |
|
| 1319 |
//JOBSERVER { |
| 1320 |
/errordict .systemvar /handleerror get /.GShandleerror .systemvar ne |
| 1321 |
} { |
| 1322 |
//false |
| 1323 |
} ifelse |
| 1324 |
{ /errordict .systemvar begin /handleerror load //.internalstopped exec pop end |
| 1325 |
} |
| 1326 |
if |
| 1327 |
} |
| 1328 |
ifelse % newerror |
| 1329 |
end |
| 1330 |
flush |
| 1331 |
} .internalbind def |
| 1332 |
currentdict /.acquire_$error .undef |
| 1333 |
currentdict /.printerror_long .undef |
| 1334 |
|
| 1335 |
% Define $error. This must be in local VM. |
| 1336 |
.currentglobal //false .setglobal |
| 1337 |
currentdict /$error 40 dict .forceput % $error is local, systemdict is global |
| 1338 |
% newerror, errorname, command, errorinfo, |
| 1339 |
% ostack, estack, dstack, recordstacks, |
| 1340 |
% binary, globalmode, |
| 1341 |
% .inerror, .nosetlocal, position, |
| 1342 |
% plus extra space for badly designed error handers. |
| 1343 |
$error begin |
| 1344 |
/newerror //false def |
| 1345 |
/recordstacks //true def |
| 1346 |
/binary //false def |
| 1347 |
/globalmode .currentglobal def |
| 1348 |
/.inerror //false def |
| 1349 |
/.nosetlocal //true def |
| 1350 |
/position //null def |
| 1351 |
/errorinfo //null def |
| 1352 |
end |
| 1353 |
% Define errordict similarly. It has one entry per error name, |
| 1354 |
% plus handleerror. However, some astonishingly badly written PostScript |
| 1355 |
% files require it to have at least one empty slot. |
| 1356 |
currentdict /errordict ErrorNames length 3 add dict |
| 1357 |
.forceput % errordict is local, systemdict is global |
| 1358 |
.setglobal % back to global VM |
| 1359 |
% gserrordict contains all the default error handling methods, but unlike |
| 1360 |
% errordict it is noaccess after creation (also it is in global VM). |
| 1361 |
% When running 'SAFER', we'll ignore the contents of errordict, which |
| 1362 |
% may have been tampered with by the running job, and always use gserrordict |
| 1363 |
% gserrordict also contains any non-standard errors, for better compatibility |
| 1364 |
% with Adobe. |
| 1365 |
% |
| 1366 |
% NOTE: the name gserrordict is known to the interpreter. |
| 1367 |
/gserrordict ErrorNames length 3 add dict def |
| 1368 |
% Register an error in errordict. We make this a procedure because we only |
| 1369 |
% register the Level 1 errors here: the rest are registered by "feature" |
| 1370 |
% files. However, ErrorNames contains all of the error names regardless of |
| 1371 |
% what features are included, so we have to "know" that VMerror is the last |
| 1372 |
% Level 1 error. |
| 1373 |
/.registererror2 % <dict> <name> .registererror - |
| 1374 |
{ .currentglobal //true .setglobal % create procs in global VM |
| 1375 |
3 1 roll |
| 1376 |
mark 1 index systemdict /.errorhandler get /exec load //.packtomark exec cvx put |
| 1377 |
.setglobal |
| 1378 |
} .internalbind def |
| 1379 |
/.registererror % <name> .registererror - |
| 1380 |
{ errordict exch //.registererror2 exec |
| 1381 |
} .internalbind def |
| 1382 |
currentdict /.registererror2 .undef |
| 1383 |
|
| 1384 |
ErrorNames |
| 1385 |
{ .registererror} forall |
| 1386 |
errordict begin |
| 1387 |
% The handlers for interrupt and timeout are special; there is no |
| 1388 |
% 'current object', so they push their own name. |
| 1389 |
{ /interrupt /timeout } |
| 1390 |
{ mark 1 index dup systemdict /.errorhandler get /exec load //.packtomark exec cvx def |
| 1391 |
} forall |
| 1392 |
/handleerror % this key is 'well known' and some PS may redefine it |
| 1393 |
{ /.printerror .systemvar exec |
| 1394 |
} .internalbind def |
| 1395 |
end % errordict |
| 1396 |
|
| 1397 |
gserrordict /unknownerror errordict /unknownerror get put |
| 1398 |
errordict /unknownerror .undef |
| 1399 |
|
| 1400 |
/.SAFERERRORLIST ErrorNames def |
| 1401 |
/.setsafererrors |
| 1402 |
{ |
| 1403 |
% Put all the requested handlers in gserrordict |
| 1404 |
gserrordict |
| 1405 |
//.SAFERERRORLIST |
| 1406 |
{ |
| 1407 |
dup /unknownerror eq |
| 1408 |
{pop} |
| 1409 |
{ |
| 1410 |
dup errordict exch get 2 index 3 1 roll put |
| 1411 |
}ifelse |
| 1412 |
}forall |
| 1413 |
noaccess pop |
| 1414 |
//systemdict /.setsafeerrors .forceundef |
| 1415 |
//systemdict /.SAFERERRORLIST .forceundef |
| 1416 |
} .internalbind odef |
| 1417 |
|
| 1418 |
SAFERERRORS {.setsafererrors} if |
| 1419 |
|
| 1420 |
% Define a stable private copy of handleerror that we will always use under |
| 1421 |
% JOBSERVER mode. |
| 1422 |
/.GShandleerror errordict /handleerror get def |
| 1423 |
|
| 1424 |
% Define the [write]==[only] procedures. |
| 1425 |
/.dict 8 dict dup |
| 1426 |
begin def |
| 1427 |
/.cvp {1 index exch 1 .writecvp} .internalbind def |
| 1428 |
/.p {1 index exch writestring} .internalbind def |
| 1429 |
/.p1 {2 index exch writestring} .internalbind def |
| 1430 |
/.p2 {3 index exch writestring} .internalbind def |
| 1431 |
/.print |
| 1432 |
{ dup type .dict exch .knownget { exec } { .cvp } ifelse |
| 1433 |
} .internalbind def |
| 1434 |
/arraytype |
| 1435 |
{dup rcheck |
| 1436 |
{() exch dup xcheck |
| 1437 |
{({) .p2 |
| 1438 |
{exch .p1 |
| 1439 |
1 index exch .print pop ( )} forall |
| 1440 |
(})} |
| 1441 |
{([) .p2 |
| 1442 |
{exch .p1 |
| 1443 |
1 index exch .print pop ( )} forall |
| 1444 |
(])} |
| 1445 |
ifelse exch pop .p} |
| 1446 |
{.cvp} |
| 1447 |
ifelse} .internalbind def |
| 1448 |
/packedarraytype /arraytype load def |
| 1449 |
{//.dict begin .print pop end} |
| 1450 |
.bind |
| 1451 |
end |
| 1452 |
|
| 1453 |
/write==only exch def |
| 1454 |
/write== {1 index exch write==only (\n) writestring} .internalbind def |
| 1455 |
/==only { (%stdout) (w) file exch write==only } .internalbind def |
| 1456 |
/== {==only (\n) print} .internalbind def |
| 1457 |
% Define [write]===[only], an extension that prints dictionaries |
| 1458 |
% in readable form and doesn't truncate strings. |
| 1459 |
/.dict /write==only load 0 get dup length 2 add dict .copydict dup |
| 1460 |
|
| 1461 |
begin def |
| 1462 |
/dicttype |
| 1463 |
{ dup rcheck |
| 1464 |
{ (<< ) .p1 |
| 1465 |
{ 2 index 3 -1 roll .print pop ( ) .p1 |
| 1466 |
1 index exch .print pop ( ) .p |
| 1467 |
} |
| 1468 |
forall (>>) .p |
| 1469 |
} |
| 1470 |
{ .cvp |
| 1471 |
} |
| 1472 |
ifelse |
| 1473 |
} .internalbind def |
| 1474 |
/stringtype |
| 1475 |
{ 1 index exch 2 .writecvp |
| 1476 |
} .internalbind def |
| 1477 |
|
| 1478 |
{//.dict begin .print pop end} |
| 1479 |
.internalbind |
| 1480 |
end |
| 1481 |
|
| 1482 |
/write===only exch def |
| 1483 |
/write=== {1 index exch write===only (\n) writestring} .internalbind def |
| 1484 |
/===only { (%stdout) (w) file exch write===only } .internalbind def |
| 1485 |
/=== { ===only (\n) print } .internalbind def |
| 1486 |
|
| 1487 |
% Create the initialization queue. |
| 1488 |
1183615869 internaldict dup |
| 1489 |
/.delayed_init_queue 10 dict put |
| 1490 |
|
| 1491 |
/.schedule_init % <priority> <proc> .schedule_init - |
| 1492 |
{ |
| 1493 |
1183615869 internaldict begin |
| 1494 |
.delayed_init_queue 2 index known { |
| 1495 |
end |
| 1496 |
(.delayed_init_queue priority conflict with ) print 1 index = |
| 1497 |
/.schedule_init cvx /configurationerror signalerror |
| 1498 |
} if |
| 1499 |
.delayed_init_queue 3 1 roll .growput |
| 1500 |
end |
| 1501 |
} .internalbind def |
| 1502 |
|
| 1503 |
begin |
| 1504 |
/.execute_scheduled_inits % - .execute_scheduled_inits - |
| 1505 |
{ |
| 1506 |
2 dict begin |
| 1507 |
/.newdelayed_init_queue |
| 1508 |
mark |
| 1509 |
1183615869 internaldict /.delayed_init_queue get {} forall |
| 1510 |
.dicttomark def |
| 1511 |
{ |
| 1512 |
0 //null .newdelayed_init_queue { % maxp {} p {} |
| 1513 |
3 index 2 index lt { |
| 1514 |
4 2 roll |
| 1515 |
} if |
| 1516 |
pop pop |
| 1517 |
} forall |
| 1518 |
exch .newdelayed_init_queue exch undef |
| 1519 |
dup //null eq { |
| 1520 |
pop exit |
| 1521 |
} if |
| 1522 |
exec |
| 1523 |
} loop |
| 1524 |
currentdict /.newdelayed_init_queue undef |
| 1525 |
end |
| 1526 |
} .internalbind def |
| 1527 |
end |
| 1528 |
|
| 1529 |
(END PROCS) VMDEBUG |
| 1530 |
|
| 1531 |
% Define the font directory. |
| 1532 |
currentdict |
| 1533 |
/FontDirectory //false .setglobal 100 dict //true .setglobal |
| 1534 |
.forceput % FontDirectory is local, systemdict is global |
| 1535 |
|
| 1536 |
% Define the encoding dictionary. |
| 1537 |
/EncodingDirectory 16 dict def % enough for Level 2 + PDF standard encodings |
| 1538 |
|
| 1539 |
% Define .findencoding. (This is redefined in Level 2.) |
| 1540 |
/.findencoding |
| 1541 |
{ //EncodingDirectory exch get exec |
| 1542 |
} .internalbind def |
| 1543 |
/.defineencoding |
| 1544 |
{ //EncodingDirectory 3 1 roll put |
| 1545 |
} .internalbind def |
| 1546 |
% If we've got the composite font extensions, define findencoding. |
| 1547 |
% To satisfy the Genoa FTS, findencoding must be a procedure, not an operator. |
| 1548 |
/rootfont where { pop /findencoding { .findencoding } def } if |
| 1549 |
|
| 1550 |
% Define .registerencoding. |
| 1551 |
% NOTE: This procedure no longer does anything, but it must continue to |
| 1552 |
% exist for the sake of toolbin/encs2c.ps. |
| 1553 |
/.registerencoding { % <index> <array> .registerencoding - |
| 1554 |
pop pop |
| 1555 |
} .internalbind odef |
| 1556 |
|
| 1557 |
% Load StandardEncoding. |
| 1558 |
%% Replace 1 (gs_std_e.ps) |
| 1559 |
(gs_std_e.ps) dup runlibfile VMDEBUG |
| 1560 |
|
| 1561 |
% Load ISOLatin1Encoding. |
| 1562 |
%% Replace 1 (gs_il1_e.ps) |
| 1563 |
(gs_il1_e.ps) dup runlibfile VMDEBUG |
| 1564 |
|
| 1565 |
% Define stubs for the Symbol and Dingbats encodings. |
| 1566 |
% Note that the first element of the procedure must be the file name, |
| 1567 |
% since gs_lev2.ps extracts it to set up the Encoding resource category. |
| 1568 |
|
| 1569 |
/SymbolEncoding { /SymbolEncoding .findencoding } bind def |
| 1570 |
%% Replace 3 (gs_sym_e.ps) |
| 1571 |
EncodingDirectory /SymbolEncoding |
| 1572 |
{ (gs_sym_e.ps) //systemdict begin runlibfile SymbolEncoding end } |
| 1573 |
bind put |
| 1574 |
|
| 1575 |
/DingbatsEncoding { /DingbatsEncoding .findencoding } bind def |
| 1576 |
%% Replace 3 (gs_dbt_e.ps) |
| 1577 |
EncodingDirectory /DingbatsEncoding |
| 1578 |
{ (gs_dbt_e.ps) //systemdict begin runlibfile DingbatsEncoding end } |
| 1579 |
bind put |
| 1580 |
|
| 1581 |
(END FONTDIR/ENCS) VMDEBUG |
| 1582 |
|
| 1583 |
% Special handling for device parameters. Must follow definition of 'type' |
| 1584 |
% make -dPDFA equivalent to -dPDFA=1 (backwards compatible) |
| 1585 |
currentdict /PDFA known { PDFA type /booleantype eq { /PDFA 1 def } if } if |
| 1586 |
% make -dPDFX equivalent to -dPDFX=3 (backwards compatible) |
| 1587 |
currentdict /PDFX known { PDFX type /booleantype eq { /PDFX 3 def } if } if |
| 1588 |
|
| 1589 |
% Construct a dictionary of all available devices. |
| 1590 |
% These are (read-only) device prototypes that can't be |
| 1591 |
% installed or have their parameters changed. For this reason, |
| 1592 |
% the value in the dictionary is actually a 2-element writable array, |
| 1593 |
% to allow us to create a default instance of the prototype on demand. |
| 1594 |
|
| 1595 |
% Loop until the .getdevice gets a rangecheck. |
| 1596 |
errordict /rangecheck 2 copy get |
| 1597 |
errordict /rangecheck { pop stop } put % pop the command |
| 1598 |
0 { {dup .getdevice exch 1 add} loop} //.internalstopped exec pop |
| 1599 |
1 add dict /devicedict 1 index def |
| 1600 |
begin % 2nd copy of count is on stack |
| 1601 |
{ dup .devicename exch |
| 1602 |
dup wcheck { dup } { //null } ifelse 2 array astore def |
| 1603 |
} repeat |
| 1604 |
end |
| 1605 |
put % errordict /rangecheck |
| 1606 |
.clearerror |
| 1607 |
/devicenames devicedict { pop } forall devicedict length packedarray def |
| 1608 |
|
| 1609 |
% Determine the default device. |
| 1610 |
/defaultdevice //systemdict /DISPLAYING get |
| 1611 |
{ //systemdict /DEVICE .knownget |
| 1612 |
{ devicedict 1 index known not |
| 1613 |
{ (Unknown device: ) print = |
| 1614 |
flush /defaultdevice cvx 1 .quit |
| 1615 |
} |
| 1616 |
if |
| 1617 |
} |
| 1618 |
{ .getdefaultdevice .devicename |
| 1619 |
} |
| 1620 |
ifelse |
| 1621 |
} |
| 1622 |
{ /nullpage |
| 1623 |
} |
| 1624 |
ifelse |
| 1625 |
/.defaultdevicename 1 index def |
| 1626 |
finddevice % make a copy |
| 1627 |
def |
| 1628 |
devicedict /Default devicedict .defaultdevicename get put |
| 1629 |
|
| 1630 |
(END DEVS) VMDEBUG |
| 1631 |
|
| 1632 |
% Define statusdict, for the benefit of programs |
| 1633 |
% that think they are running on a LaserWriter or similar printer. |
| 1634 |
%% Replace 1 (gs_statd.ps) |
| 1635 |
(gs_statd.ps) runlibfile |
| 1636 |
|
| 1637 |
(END STATD) VMDEBUG |
| 1638 |
|
| 1639 |
% Load the standard font environment. |
| 1640 |
%% Replace 1 (gs_fonts.ps) |
| 1641 |
(gs_fonts.ps) runlibfile |
| 1642 |
|
| 1643 |
(END GS_FONTS) VMDEBUG |
| 1644 |
|
| 1645 |
% Define the default halftone screen and BG/UCR functions now, so that |
| 1646 |
% it will bind in the original definitions of set[color]screen. |
| 1647 |
% We make this a procedure so we can call it again when switching devices. |
| 1648 |
|
| 1649 |
% Use an ordered dither for low-resolution devices. |
| 1650 |
/.setloreshalftone { % <dpi> .setloreshalftone - |
| 1651 |
% The following 'ordered dither' spot function was contributed by |
| 1652 |
% Gregg Townsend. Thanks, Gregg! |
| 1653 |
16.001 div 0 % not 16: avoids rounding problems |
| 1654 |
{ 1 add 7.9999 mul cvi exch 1 add 7.9999 mul cvi 16 mul add < |
| 1655 |
0E 8E 2E AE 06 86 26 A6 0C 8C 2C AC 04 84 24 A4 |
| 1656 |
CE 4E EE 6E C6 46 E6 66 CC 4C EC 6C C4 44 E4 64 |
| 1657 |
3E BE 1E 9E 36 B6 16 96 3C BC 1C 9C 34 B4 14 94 |
| 1658 |
FE 7E DE 5E F6 76 D6 56 FC 7C DC 5C F4 74 D4 54 |
| 1659 |
01 81 21 A1 09 89 29 A9 03 83 23 A3 0B 8B 2B AB |
| 1660 |
C1 41 E1 61 C9 49 E9 69 C3 43 E3 63 CB 4B EB 6B |
| 1661 |
31 B1 11 91 39 B9 19 99 33 B3 13 93 3B BB 1B 9B |
| 1662 |
F1 71 D1 51 F9 79 D9 59 F3 73 D3 53 FB 7B DB 5B |
| 1663 |
0D 8D 2D AD 05 85 25 A5 0F 8F 2F AF 07 87 27 A7 |
| 1664 |
CD 4D ED 6D C5 45 E5 65 CF 4F EF 6F C7 47 E7 67 |
| 1665 |
3D BD 1D 9D 35 B5 15 95 3F BF 1F 9F 37 B7 17 97 |
| 1666 |
FD 7D DD 5D F5 75 D5 55 FF 7F DF 5F F7 77 D7 57 |
| 1667 |
02 82 22 A2 0A 8A 2A AA 00 80 20 A0 08 88 28 A8 |
| 1668 |
C2 42 E2 62 CA 4A EA 6A C0 40 E0 60 C8 48 E8 68 |
| 1669 |
32 B2 12 92 3A BA 1A 9A 30 B0 10 90 38 B8 18 98 |
| 1670 |
F2 72 D2 52 FA 7A DA 5A F0 70 D0 50 F8 78 D8 58 |
| 1671 |
> exch get 256 div |
| 1672 |
} |
| 1673 |
bind |
| 1674 |
% Use correct, per-plane screens for CMYK devices only. |
| 1675 |
//systemdict /setcolorscreen known processcolors 4 eq and |
| 1676 |
{ 3 copy 6 copy //setcolorscreen } |
| 1677 |
{ //setscreen } |
| 1678 |
ifelse |
| 1679 |
} .internalbind def |
| 1680 |
/.setloresscreen { % <dpi> .setloresscreen - |
| 1681 |
.setloreshalftone |
| 1682 |
0 array cvx settransfer % Genoa CET won't accept a packed array! |
| 1683 |
/setstrokeadjust where { pop //true setstrokeadjust } if |
| 1684 |
} .internalbind def |
| 1685 |
% Use a 45-degree spot screen for high-resolution devices. |
| 1686 |
% The PS3 CET insists that the screen be an array and not a packedarray (!). |
| 1687 |
currentpacking //false setpacking |
| 1688 |
/.linescreen |
| 1689 |
% The following screen algorithm is used by permission of the author. |
| 1690 |
{ ((C) 1989 Berthold K.P. Horn) pop |
| 1691 |
1 add 180 mul cos 1 0.08 add mul exch 2 add 180 mul cos |
| 1692 |
1 0.08 sub mul add 2 div |
| 1693 |
} |
| 1694 |
bind readonly def |
| 1695 |
setpacking |
| 1696 |
/.sethireshalftone { % <dpi> .sethireshalftone <doscreen> |
| 1697 |
% According to information published by Hewlett-Packard, |
| 1698 |
% they use a 60 line screen on 300 DPI printers and |
| 1699 |
% an 85 line screen on 600 DPI printers. |
| 1700 |
% However, we use a 106 line screen, which produces smoother- |
| 1701 |
% looking shades but fewer of them (32 vs. 50). |
| 1702 |
% 46 was suggested as a good frequency value for printers |
| 1703 |
% between 200 and 400 DPI, so we use it for lower resolutions. |
| 1704 |
% Imagesetters need even higher frequency screens. |
| 1705 |
//systemdict /DITHERPPI known |
| 1706 |
{ //systemdict /DITHERPPI get |
| 1707 |
} |
| 1708 |
{ dup cvi 100 idiv 15 .min |
| 1709 |
{//null 46 46 60 60 60 106 106 106 106 133 133 133 133 133 150} |
| 1710 |
exch get |
| 1711 |
} |
| 1712 |
ifelse |
| 1713 |
1 index 4.01 div .min % at least a 4x4 cell |
| 1714 |
45 |
| 1715 |
//.linescreen |
| 1716 |
% Determine whether we have lots of process colors. |
| 1717 |
% If so, don't bother with color screening or gamma correction. |
| 1718 |
% Also don't do gamma correction on very high-resolution devices. |
| 1719 |
% (This should depend on dot gain, not resolution, but we don't |
| 1720 |
% currently have a way to determine this.) Ignore missing components |
| 1721 |
% (*Values = 1). |
| 1722 |
currentdevice mark |
| 1723 |
/RedValues 0 /GreenValues 0 /BlueValues 0 /GrayValues 0 |
| 1724 |
.dicttomark .getdeviceparams |
| 1725 |
counttomark 2 idiv 1 sub |
| 1726 |
{ exch pop dup 1 le |
| 1727 |
{ pop } |
| 1728 |
{ exch dup 1 le |
| 1729 |
{ pop } |
| 1730 |
{ .min } |
| 1731 |
ifelse |
| 1732 |
} |
| 1733 |
ifelse |
| 1734 |
} |
| 1735 |
repeat |
| 1736 |
exch pop exch pop 32 lt 4 index 800 lt and 5 1 roll |
| 1737 |
% Stack: doscreen dpi freq angle proc |
| 1738 |
% Ghostscript currently doesn't use correct, per-plane halftones |
| 1739 |
% unless setcolorscreen has been executed. Since these are |
| 1740 |
% computationally much more expensive than binary halftones, |
| 1741 |
% we check to make sure they are really warranted, i.e., we have |
| 1742 |
% a high-resolution CMYK device (i.e., not a display) with |
| 1743 |
% fewer than 5 bits per plane (i.e., not a true-color device). |
| 1744 |
4 -1 roll 150 ge |
| 1745 |
{ /setcolorscreen where |
| 1746 |
{ pop //systemdict /COLORSCREEN known |
| 1747 |
{ //systemdict /COLORSCREEN get} |
| 1748 |
{ 3 index } |
| 1749 |
ifelse |
| 1750 |
dup //false ne |
| 1751 |
{ 4 1 roll 3 copy 6 copy 13 -1 roll |
| 1752 |
% For really high-quality screening on printers, we need to |
| 1753 |
% give each plane its own screen angle. Unfortunately, |
| 1754 |
% this currently has very large space and time costs. |
| 1755 |
//true eq % true => different angles, |
| 1756 |
% 0 => same angles |
| 1757 |
{ { 45 90 15 75 } { 3 1 roll exch pop 12 3 roll } forall |
| 1758 |
} |
| 1759 |
if //setcolorscreen |
| 1760 |
} |
| 1761 |
{ pop //setscreen % false => single binary screen |
| 1762 |
} |
| 1763 |
ifelse |
| 1764 |
} |
| 1765 |
{ //setscreen % setcolorscreen not known |
| 1766 |
} |
| 1767 |
ifelse |
| 1768 |
} |
| 1769 |
{ //setscreen % not high resolution |
| 1770 |
} |
| 1771 |
ifelse |
| 1772 |
} .internalbind def |
| 1773 |
/.sethiresscreen { % <dpi> .sethiresscreen |
| 1774 |
.sethireshalftone % pushes true if a screen halftone used |
| 1775 |
% Stack: doscree |
| 1776 |
{ |
| 1777 |
% Set the transfer function to lighten up the grays. |
| 1778 |
% Parameter values closer to 1 are better for devices with |
| 1779 |
% less dot spreading; lower values are better with more spreading. |
| 1780 |
% The value 0.8 is a compromise that will probably please no one! |
| 1781 |
% |
| 1782 |
% Because of a bug in FrameMaker, we have to accept operands |
| 1783 |
% outside the valid range of [0..1]. |
| 1784 |
{ |
| 1785 |
dup dup 0.0 gt exch 1.0 lt and |
| 1786 |
{ |
| 1787 |
0.8 exp |
| 1788 |
} |
| 1789 |
if |
| 1790 |
} |
| 1791 |
} |
| 1792 |
{ |
| 1793 |
% Set the transfer function to the identity. |
| 1794 |
0 array cvx % Genoa CET won't accept a packed array! |
| 1795 |
} |
| 1796 |
ifelse |
| 1797 |
settransfer |
| 1798 |
/setstrokeadjust where |
| 1799 |
{ pop //false setstrokeadjust } |
| 1800 |
if |
| 1801 |
|
| 1802 |
% Increase fill adjustment so that we effectively use Adobe's |
| 1803 |
% any-part-of-pixel rule. |
| 1804 |
0.5 dup .setfilladjust2 |
| 1805 |
} .internalbind def |
| 1806 |
|
| 1807 |
% Set the default screen and BG/UCR. |
| 1808 |
% We define the proc here, rather than inline in .setdefaultbgucr |
| 1809 |
% for the benefit of gs_cet.ps so jobs that do anything that causes |
| 1810 |
% .setdefaultbgucr to be called will still get the redefined proc |
| 1811 |
% in gs_cet.ps |
| 1812 |
(%.defaultbgrucrproc) cvn { pop 0 } def |
| 1813 |
|
| 1814 |
/.setdefaultbgucr { |
| 1815 |
systemdict /setblackgeneration known { |
| 1816 |
(%.defaultbgrucrproc) cvn load dup |
| 1817 |
setblackgeneration setundercolorremoval |
| 1818 |
} if |
| 1819 |
} .internalbind def |
| 1820 |
/.useloresscreen { % - .useloresscreen <bool> |
| 1821 |
% Compute min(|dpi x|,|dpi y|) as the definition of the resolution. |
| 1822 |
72 72 matrix defaultmatrix dtransform abs exch abs .min |
| 1823 |
dup 150 lt //systemdict /DITHERPPI known not and |
| 1824 |
} .internalbind def |
| 1825 |
|
| 1826 |
/.gsgetdeviceprop % <device> <propname> gsgetdeviceprop <value> |
| 1827 |
{ 2 copy mark exch //null .dicttomark .getdeviceparams |
| 1828 |
dup mark eq % if true, not found |
| 1829 |
{ pop dup /undefined signalerror } |
| 1830 |
{ 5 1 roll pop pop pop pop } |
| 1831 |
ifelse |
| 1832 |
} .internalbind def |
| 1833 |
|
| 1834 |
% The following implementation uses LL2 extensions, but only in stopped |
| 1835 |
% contexts so that with LL1, the .set??reshalftone will be used. |
| 1836 |
% |
| 1837 |
% - .getdefaulthalftone <halftonedict> true if default found |
| 1838 |
% false |
| 1839 |
/.getdefaulthalftone { |
| 1840 |
% try the device to see if it has a default halftone |
| 1841 |
{ currentdevice /HalftoneDefault //.gsgetdeviceprop exec } //.internalstopped exec |
| 1842 |
{ pop pop //false } % no device property |
| 1843 |
{ dup type /dicttype eq { //true } { pop //false } ifelse } |
| 1844 |
ifelse |
| 1845 |
% stack: <halftonedict> true if default found |
| 1846 |
% false not found |
| 1847 |
dup not |
| 1848 |
{ % device did not provide a default, try Resource |
| 1849 |
pop { /Default /Halftone /findresource .systemvar exec } //.internalstopped exec |
| 1850 |
{ pop pop //false } { //true } ifelse |
| 1851 |
} |
| 1852 |
if |
| 1853 |
} .internalbind def |
| 1854 |
currentdict /.gsgetdeviceprop .forceundef |
| 1855 |
|
| 1856 |
/.setdefaulthalftone { |
| 1857 |
//.getdefaulthalftone exec |
| 1858 |
{ sethalftone } |
| 1859 |
{ % default not found |
| 1860 |
//.useloresscreen exec { .setloreshalftone } { .sethireshalftone pop } ifelse |
| 1861 |
} |
| 1862 |
ifelse |
| 1863 |
} .internalbind def |
| 1864 |
|
| 1865 |
/.setdefaultscreen { |
| 1866 |
//.useloresscreen exec { .setloresscreen } { .sethiresscreen } ifelse |
| 1867 |
//.setdefaultbgucr exec |
| 1868 |
} .internalbind def |
| 1869 |
currentdict /.setdefaultbgucr .undef |
| 1870 |
currentdict /.useloresscreen .undef |
| 1871 |
|
| 1872 |
% Rendering intent mapping for setcolorrendering1 and PDF interpreter |
| 1873 |
/.renderingintentdict mark |
| 1874 |
/Perceptual 0 |
| 1875 |
/RelativeColorimetric 1 |
| 1876 |
/Saturation 2 |
| 1877 |
/AbsoluteColorimetric 3 |
| 1878 |
.dicttomark readonly def |
| 1879 |
|
| 1880 |
% Load basic color support |
| 1881 |
%% Replace 1 (gs_cspace.ps) |
| 1882 |
(gs_cspace.ps) runlibfile |
| 1883 |
|
| 1884 |
(END BASIC COLOR) VMDEBUG |
| 1885 |
|
| 1886 |
% Load image support |
| 1887 |
%% Replace 1 (gs_img.ps) |
| 1888 |
(gs_img.ps) runlibfile |
| 1889 |
|
| 1890 |
(END IMAGE) VMDEBUG |
| 1891 |
|
| 1892 |
% Auxiliary procedures for generating file name templates. |
| 1893 |
|
| 1894 |
% Convert a path name into a string suitable for filenameforall |
| 1895 |
% For example: (a\\b*?c) to (a\\\\b\\*\\?c) |
| 1896 |
/.makepathtemplate { % str1 -- str2 |
| 1897 |
dup length dup add string 0 % result string up to twice the size |
| 1898 |
0 1 4 index length 1 sub { |
| 1899 |
3 index exch get |
| 1900 |
dup 92 eq { % \ -> \\ |
| 1901 |
2 index 2 index 92 |
| 1902 |
put |
| 1903 |
exch 1 add exch |
| 1904 |
} |
| 1905 |
if |
| 1906 |
dup 42 eq { % * -> \* |
| 1907 |
2 index 2 index 92 |
| 1908 |
put |
| 1909 |
exch 1 add exch |
| 1910 |
} |
| 1911 |
if |
| 1912 |
dup 63 eq { % ? -> \? |
| 1913 |
2 index 2 index 92 |
| 1914 |
put |
| 1915 |
exch 1 add exch |
| 1916 |
} |
| 1917 |
if |
| 1918 |
2 index 2 index 3 -1 roll put 1 add |
| 1919 |
} for |
| 1920 |
0 exch getinterval exch pop |
| 1921 |
} .internalbind def |
| 1922 |
|
| 1923 |
% false <dir_list> <template> .generate_dir_list_templates_with_length <t1> ... <tN> |
| 1924 |
% true <dir_list> <template> .generate_dir_list_templates_with_length <t1> <l1> ... <tN> <ln> |
| 1925 |
% |
| 1926 |
% Generates various valid templates combining a directory list with a given template. |
| 1927 |
% With 'true' operand it also returns lengths of directory pathes. |
| 1928 |
% |
| 1929 |
% Example1 (DOS, Windows) : |
| 1930 |
% false [(/gs/lib) (/gs/Resource/) (\gs8.00\Resource)] (*/*) --> |
| 1931 |
% (/gs/lib/*/*) (/gs/Resource/*/*) (\\gs8.00\\Resource/*/*) |
| 1932 |
% |
| 1933 |
% Example2 (OpenVMS) : |
| 1934 |
% false [(gs:[lib]) (gs:[Resource]) (gs800:[Resource)] (*]*) --> |
| 1935 |
% ((gs:[lib.*]*) [gs:[Resource.*]*) ([gs800:[Resource.*]*) |
| 1936 |
% |
| 1937 |
/.generate_dir_list_templates_with_length |
| 1938 |
{ % [dl] (templ) |
| 1939 |
% We need to convert paths into templates, |
| 1940 |
% because it can include '\' on DOS. |
| 1941 |
% In same time, the <template> must not convert, |
| 1942 |
% because it is already a template. |
| 1943 |
% Besides that, we cannot combine template using .file_name_combine, |
| 1944 |
% because template syntax breaks the platform path syntax. |
| 1945 |
% To resolve this, we first convert the <template> into |
| 1946 |
% a fake filename, and combine it with path, |
| 1947 |
% obtaining a correct separator. Then we replace |
| 1948 |
% the fake file name with the given template. |
| 1949 |
% |
| 1950 |
|
| 1951 |
% Create the fake file name : |
| 1952 |
dup dup length string copy % b [dl] (templ) (ffn) |
| 1953 |
(*) 0 get (?) 0 get (\\) 0 get (x) 0 get 0 0 % b [dl] (templ) (ffn) * ? \ x i j |
| 1954 |
{ 1 index 7 index length ge { exit } if |
| 1955 |
6 index 2 index get % b [dl] (templ) (ffn) * ? \ x i j c |
| 1956 |
dup 7 index eq % b [dl] (templ) (ffn) * ? \ x i j c bool |
| 1957 |
1 index 7 index eq or { % *? |
| 1958 |
pop 2 index |
| 1959 |
} if % b [dl] (templ) (ffn) * ? \ x i j C |
| 1960 |
dup 5 index eq { % \ |
| 1961 |
3 2 roll 1 add 3 1 roll % b [dl] (templ) (ffn) * ? \ x i' j C |
| 1962 |
2 index 8 index length ge { pop exit } if |
| 1963 |
pop 6 index 2 index get % b [dl] (templ) (ffn) * ? \ x i' j C' |
| 1964 |
} if |
| 1965 |
7 index 2 index 3 2 roll put % b [dl] (templ) (ffn) * ? \ x i' j |
| 1966 |
1 add exch 1 add exch % b [dl] (templ) (ffn) * ? \ x i'' j' |
| 1967 |
} loop % b [dl] (templ) (ffn) * ? \ x i j |
| 1968 |
6 1 roll pop % b [dl] (templ) (ffn) j * ? \ x |
| 1969 |
exch pop exch pop exch pop exch % b [dl] (templ) (ffn) x j |
| 1970 |
{ dup 3 index length ge { exit } if |
| 1971 |
3 copy exch put |
| 1972 |
1 add |
| 1973 |
} loop |
| 1974 |
pop pop % b [dl] (templ) (ffn) |
| 1975 |
|
| 1976 |
% An internal procedure : |
| 1977 |
{ % {} b [dl] (templ) (ffn) (dffn) |
| 1978 |
dup length |
| 1979 |
2 index length sub % drop "ffn", remaining "ldffn" = length of the "directory" part |
| 1980 |
exch % {} b [dl] (templ) (ffn) ldffn (dffn) |
| 1981 |
//.makepathtemplate exec % {} b [dl] (templ) (ffn) ldffn (Dffn) |
| 1982 |
dup % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) |
| 1983 |
4 index length dup % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) templL templL |
| 1984 |
2 index length % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) templL templL DffnL |
| 1985 |
exch sub % {} b [dl] (templ) (ffn) ldffn (Dffn) (Dffn) templL i |
| 1986 |
exch getinterval % {} b [dl] (templ) (ffn) ldffn (Dffn) (suffix) |
| 1987 |
4 index exch copy pop % {} b [dl] (templ) (ffn) ldffn (dt) |
| 1988 |
5 index { |
| 1989 |
exch % {} b [dl] (templ) (ffn) (dt) ldffn |
| 1990 |
7 2 roll % (dt) ldffn {} b [dl] (templ) (ffn) |
| 1991 |
} { |
| 1992 |
exch pop % {} b [dl] (templ) (ffn) (dt) |
| 1993 |
6 1 roll % (dt) {} b [dl] (templ) (ffn) |
| 1994 |
} ifelse |
| 1995 |
} |
| 1996 |
5 1 roll % {} b [dl] (templ) (ffn) |
| 1997 |
|
| 1998 |
% Generate templates : |
| 1999 |
dup .file_name_is_absolute { |
| 2000 |
dup % {} b [dl] (templ) (ffn) (ffn) |
| 2001 |
5 index exec % (t1) {} b [dl] (templ) (ffn) |
| 2002 |
} { |
| 2003 |
2 index { % ... {} b [dl] (templ) (ffn) (d) |
| 2004 |
1 index % ... {} b [dl] (templ) (ffn) (d) (ffn) |
| 2005 |
//false .file_name_combine { % ... {} b [dl] (templ) (ffn) (dffn) |
| 2006 |
5 index exec % ... (t1) ?l1 {} b [dl] (templ) (ffn) |
| 2007 |
} { % ... {} b [dl] (templ) (ffn) (d) (ffn) |
| 2008 |
pop pop % ... {} b [dl] (templ) (ffn) |
| 2009 |
} ifelse |
| 2010 |
} forall |
| 2011 |
} ifelse % (t1) ?l1 (t2) ?l2 ... (tN) ?ln {} b [dl] (templ) (ffn) |
| 2012 |
pop pop pop pop pop % (t1) ?l1 (t2) ?l2 ... (tN) ?ln |
| 2013 |
} .forcebind odef |
| 2014 |
currentdict /.makepathtemplate .undef |
| 2015 |
|
| 2016 |
% <dir_list> <template> .generate_dir_list_templates <t1> ... <tN> |
| 2017 |
% |
| 2018 |
% Generates various valid templates combining a directory list with a given template. |
| 2019 |
% It's the 'false' case of the function above. |
| 2020 |
% |
| 2021 |
/.generate_dir_list_templates |
| 2022 |
{ //false 3 1 roll //.generate_dir_list_templates_with_length |
| 2023 |
} .forcebind odef |
| 2024 |
|
| 2025 |
% Load the initialization files for optional features. |
| 2026 |
%% Replace 4 INITFILES |
| 2027 |
systemdict /INITFILES known |
| 2028 |
{ INITFILES { <00> search { exch pop dup runlibfile VMDEBUG }{ dup runlibfile VMDEBUG exit } ifelse } .forcebind loop |
| 2029 |
} |
| 2030 |
if |
| 2031 |
|
| 2032 |
% If Level 2 (or higher) functionality is implemented, enable it now. |
| 2033 |
/.setlanguagelevel where { |
| 2034 |
pop 2 .setlanguagelevel |
| 2035 |
% If the resource machinery is loaded, fix up some things now. |
| 2036 |
/.fixresources where { pop .fixresources } if |
| 2037 |
} if |
| 2038 |
/ll3dict where { |
| 2039 |
pop 3 .setlanguagelevel |
| 2040 |
} if |
| 2041 |
|
| 2042 |
(END INITFILES) VMDEBUG |
| 2043 |
|
| 2044 |
% Create a null font. This is the initial font. |
| 2045 |
8 dict dup begin |
| 2046 |
/FontMatrix [ 1 0 0 1 0 0 ] readonly def |
| 2047 |
/FontType 3 def |
| 2048 |
/FontName () def |
| 2049 |
/Encoding StandardEncoding def |
| 2050 |
/FontBBox { 0 0 0 0 } readonly def % executable is bogus, but customary ... |
| 2051 |
/BuildChar { pop pop 0 0 setcharwidth } .internalbind def |
| 2052 |
/PaintType 0 def % shouldn't be needed! |
| 2053 |
end |
| 2054 |
/NullFont exch definefont setfont |
| 2055 |
|
| 2056 |
% Define NullFont as the font. |
| 2057 |
/NullFont currentfont def |
| 2058 |
|
| 2059 |
% Load initial fonts from FONTPATH directories, Fontmap file, |
| 2060 |
% and/or .getccfont as appropriate. |
| 2061 |
.loadinitialfonts |
| 2062 |
currentdict /.loadinitialfonts .undef |
| 2063 |
|
| 2064 |
% Remove NullFont from FontDirectory, so it can't be accessed by mistake. |
| 2065 |
/undefinefont where { |
| 2066 |
pop /NullFont undefinefont |
| 2067 |
} { |
| 2068 |
FontDirectory /NullFont .undef |
| 2069 |
} ifelse |
| 2070 |
|
| 2071 |
(END FONTS) VMDEBUG |
| 2072 |
|
| 2073 |
% Restore the real definition of runlibfile. |
| 2074 |
/runlibfile /.runlibfile load def |
| 2075 |
currentdict /.runlibfile .undef |
| 2076 |
|
| 2077 |
% Bind all the operators defined as procedures. |
| 2078 |
/.bindoperators % binds operators in currentdict |
| 2079 |
{ |
| 2080 |
currentdict |
| 2081 |
{ dup type /operatortype eq |
| 2082 |
{ |
| 2083 |
% This might be a real operator, so bind might cause a typecheck |
| 2084 |
{.forcebind} //.internalstopped exec pop |
| 2085 |
} |
| 2086 |
if pop pop |
| 2087 |
} forall |
| 2088 |
} def |
| 2089 |
DELAYBIND not { |
| 2090 |
.bindoperators |
| 2091 |
%% if not DELAYBIND, undef this now. Otherwise defer to .bindnow |
| 2092 |
//systemdict /.bindoperators .undef |
| 2093 |
} if |
| 2094 |
|
| 2095 |
% Establish a default environment. |
| 2096 |
|
| 2097 |
defaultdevice |
| 2098 |
% The following line used to skip setting of page size and resolution if |
| 2099 |
% NODISPLAY was selected. We think this was only to save time and memory, |
| 2100 |
% and it is a bad idea because it prevents setting the resolution in this |
| 2101 |
% situation, which pstoedit (among other programs) relies on. |
| 2102 |
%DISPLAYING not { setdevice (%END DISPLAYING) .skipeof } if |
| 2103 |
|
| 2104 |
% If the paper size is not specifed and the device defaults to |
| 2105 |
% letter or A4 paper, select the DEFAULTPAPERSIZE. |
| 2106 |
systemdict /DEFAULTPAPERSIZE known not { |
| 2107 |
% Use .defaultpapersize if it returns a known paper size |
| 2108 |
.defaultpapersize { |
| 2109 |
statusdict /.pagetypeprocs get 1 index known { |
| 2110 |
systemdict exch /DEFAULTPAPERSIZE exch put |
| 2111 |
} { |
| 2112 |
QUIET { |
| 2113 |
pop |
| 2114 |
} { |
| 2115 |
(Unknown .defaultpapersize: ) print ==only (.) = |
| 2116 |
} ifelse |
| 2117 |
} ifelse |
| 2118 |
} if |
| 2119 |
} if |
| 2120 |
systemdict /DEFAULTPAPERSIZE known |
| 2121 |
systemdict /PAPERSIZE known not and |
| 2122 |
systemdict /DEVICEWIDTH known not and |
| 2123 |
systemdict /DEVICEHEIGHT known not and |
| 2124 |
systemdict /DEVICEWIDTHPOINTS known not and |
| 2125 |
systemdict /DEVICEHEIGHTPOINTS known not and |
| 2126 |
{ |
| 2127 |
defaultdevice mark /PageSize //null .dicttomark .getdeviceparams |
| 2128 |
.dicttomark /PageSize get |
| 2129 |
dup 0 get 0.5 add cvi 612 eq 1 index 1 get 0.5 add cvi 792 eq and |
| 2130 |
1 index 0 get 0.5 add cvi 595 eq 2 index 1 get 0.5 add cvi 842 eq and |
| 2131 |
or exch pop |
| 2132 |
{ |
| 2133 |
% the default paper size was letter, so replace it with DEFAULTPAPERSIZE |
| 2134 |
/PAPERSIZE DEFAULTPAPERSIZE def |
| 2135 |
} if |
| 2136 |
} |
| 2137 |
if |
| 2138 |
|
| 2139 |
systemdict /DEVICEWIDTH known |
| 2140 |
systemdict /DEVICEHEIGHT known or |
| 2141 |
systemdict /DEVICEWIDTHPOINTS known or |
| 2142 |
systemdict /DEVICEHEIGHTPOINTS known or |
| 2143 |
systemdict /DEVICEXRESOLUTION known or |
| 2144 |
systemdict /DEVICEYRESOLUTION known or |
| 2145 |
systemdict /PAPERSIZE known or |
| 2146 |
not { (%END DEVICE) .skipeof } if |
| 2147 |
% Let DEVICE{WIDTH,HEIGHT}[POINTS] override PAPERSIZE. |
| 2148 |
systemdict /PAPERSIZE known |
| 2149 |
systemdict /DEVICEWIDTH known not and |
| 2150 |
systemdict /DEVICEHEIGHT known not and |
| 2151 |
systemdict /DEVICEWIDTHPOINTS known not and |
| 2152 |
systemdict /DEVICEHEIGHTPOINTS known not and { |
| 2153 |
% Convert the paper size to device dimensions. |
| 2154 |
statusdict /.pagetypeprocs get PAPERSIZE .knownget { |
| 2155 |
dup 0 get /DEVICEWIDTHPOINTS exch def |
| 2156 |
1 get /DEVICEHEIGHTPOINTS exch def |
| 2157 |
} { |
| 2158 |
(Unknown paper size: ) print PAPERSIZE ==only (.) = |
| 2159 |
} ifelse |
| 2160 |
} if |
| 2161 |
% Adjust the device parameters per the command line. |
| 2162 |
% It is possible to specify resolution, pixel size, and page size; |
| 2163 |
% since any two of these determine the third, conflicts are possible. |
| 2164 |
% We simply pass them to .setdeviceparams and let it sort things out. |
| 2165 |
mark /HWResolution //null /HWSize //null /PageSize //null .dicttomark |
| 2166 |
.getdeviceparams .dicttomark begin |
| 2167 |
mark |
| 2168 |
% Check for resolution. |
| 2169 |
/DEVICEXRESOLUTION where dup |
| 2170 |
{ exch pop HWResolution 0 DEVICEXRESOLUTION put } |
| 2171 |
if |
| 2172 |
/DEVICEYRESOLUTION where dup |
| 2173 |
{ exch pop HWResolution 1 DEVICEYRESOLUTION put } |
| 2174 |
if |
| 2175 |
or { /HWResolution HWResolution } if |
| 2176 |
% Check for device sizes specified in pixels. |
| 2177 |
/DEVICEWIDTH where dup |
| 2178 |
{ exch pop HWSize 0 DEVICEWIDTH put } |
| 2179 |
if |
| 2180 |
/DEVICEHEIGHT where dup |
| 2181 |
{ exch pop HWSize 1 DEVICEHEIGHT put } |
| 2182 |
if |
| 2183 |
or { /HWSize HWSize } if |
| 2184 |
% Check for device sizes specified in points. |
| 2185 |
/DEVICEWIDTHPOINTS where dup |
| 2186 |
{ exch pop PageSize 0 DEVICEWIDTHPOINTS put } |
| 2187 |
if |
| 2188 |
/DEVICEHEIGHTPOINTS where dup |
| 2189 |
{ exch pop PageSize 1 DEVICEHEIGHTPOINTS put } |
| 2190 |
if |
| 2191 |
or { /PageSize PageSize } if |
| 2192 |
% Check whether any parameters were set. |
| 2193 |
dup mark eq { pop defaultdevice } { defaultdevice putdeviceprops } ifelse |
| 2194 |
end |
| 2195 |
%END DEVICE |
| 2196 |
% Set any device properties defined on the command line. |
| 2197 |
% If BufferSpace is defined but not MaxBitmap, set MaxBitmap to BufferSpace. |
| 2198 |
systemdict /BufferSpace known |
| 2199 |
systemdict /MaxBitmap known not and |
| 2200 |
{ systemdict /MaxBitmap BufferSpace put |
| 2201 |
} if |
| 2202 |
dup getdeviceprops |
| 2203 |
counttomark 2 idiv |
| 2204 |
{ systemdict 2 index known |
| 2205 |
{ pop dup load counttomark 2 roll } |
| 2206 |
{ pop pop } |
| 2207 |
ifelse |
| 2208 |
} repeat |
| 2209 |
counttomark dup 0 ne |
| 2210 |
{ 2 add -1 roll putdeviceprops } |
| 2211 |
{ pop pop } |
| 2212 |
ifelse |
| 2213 |
% If the initial device parameters are invalid, the setdevice may fail. |
| 2214 |
% Trap this and produce a reasonable error message. |
| 2215 |
{ setdevice } % does an erasepage |
| 2216 |
INITDEBUG { exec //false } { //.internalstopped exec } ifelse { |
| 2217 |
(%stderr) (w) file dup |
| 2218 |
(**** Unable to open the initial device, quitting.\n) writestring |
| 2219 |
flushfile |
| 2220 |
1 .quit |
| 2221 |
} if |
| 2222 |
|
| 2223 |
% If the media size is fixed, update the current page device dictionary. |
| 2224 |
FIXEDMEDIA |
| 2225 |
dup { pop systemdict /.currentpagedevice known } if |
| 2226 |
dup { pop .currentpagedevice exch pop } if |
| 2227 |
not { (%END MEDIA) .skipeof } if |
| 2228 |
currentpagedevice dup length dict .copydict |
| 2229 |
dup /Policies |
| 2230 |
% Stack: <pagedevice> <pagedevice> /Policies |
| 2231 |
1 index /InputAttributes |
| 2232 |
2 copy get dup length dict .copydict |
| 2233 |
% Stack: <pagedevice> <pagedevice> /Policies <pagedevice> |
| 2234 |
% /InputAttributes <inputattrs'> |
| 2235 |
dup 0 2 copy get dup length dict .copydict |
| 2236 |
% Stack: <pagedevice> <pagedevice> /Policies <pagedevice> |
| 2237 |
% /InputAttributes <inputattrs'> <inputattrs'> 0 <attrs0'> |
| 2238 |
dup /PageSize 7 index /PageSize get |
| 2239 |
put % PageSize in 0 |
| 2240 |
put % 0 in InputAttributes |
| 2241 |
put % InputAttributes in pagedevice |
| 2242 |
% Also change the page size policy so we don't get an error. |
| 2243 |
% Stack: <pagedevice> <pagedevice> /Policies |
| 2244 |
2 copy get dup length dict .copydict |
| 2245 |
% Stack: <pagedevice> <pagedevice> /Policies <policies'> |
| 2246 |
dup /PageSize 7 put % PageSize in Policies |
| 2247 |
put % Policies in pagedevice |
| 2248 |
.setpagedevice |
| 2249 |
%END MEDIA |
| 2250 |
|
| 2251 |
% Set up the interpreter context version of -dUSeCIEColor option |
| 2252 |
% so that .getuseciecolor has the correct value (see gs_setpd.ps) |
| 2253 |
/setpagedevice where { |
| 2254 |
pop systemdict /UseCIEColor known { |
| 2255 |
mark /UseCIEColor UseCIEColor /..StartupGlobal //true .dicttomark setpagedevice |
| 2256 |
} if |
| 2257 |
} if |
| 2258 |
|
| 2259 |
%END DISPLAYING |
| 2260 |
|
| 2261 |
(END DEVICE) VMDEBUG |
| 2262 |
|
| 2263 |
% Establish a default upper limit in the character cache, |
| 2264 |
% namely, enough room for a 18-point character at the resolution |
| 2265 |
% of the default device, or for a character consuming 1% of the |
| 2266 |
% maximum cache size, whichever is larger. |
| 2267 |
mark |
| 2268 |
% Compute limit based on character size. |
| 2269 |
18 dup dtransform |
| 2270 |
exch abs cvi 31 add 32 idiv 4 mul % X raster |
| 2271 |
exch abs cvi mul % Y |
| 2272 |
% Compute limit based on allocated space. |
| 2273 |
cachestatus pop pop pop pop pop exch pop 0.01 mul cvi |
| 2274 |
.max dup 10 idiv exch |
| 2275 |
setcacheparams |
| 2276 |
% Conditionally disable the character cache. |
| 2277 |
NOCACHE { 0 setcachelimit } if |
| 2278 |
|
| 2279 |
(END CONFIG) VMDEBUG |
| 2280 |
|
| 2281 |
% Initialize graphics. |
| 2282 |
|
| 2283 |
.setdefaultscreen |
| 2284 |
initgraphics |
| 2285 |
|
| 2286 |
% The interpreter relies on there being at least 2 entries |
| 2287 |
% on the graphics stack. Establish the second one now. |
| 2288 |
gsave |
| 2289 |
|
| 2290 |
% Define some control sequences as no-ops. |
| 2291 |
% This is a hack to get around problems |
| 2292 |
% in some common PostScript-generating applications. |
| 2293 |
<04> cvn JOBSERVER { |
| 2294 |
{ { clear cleardictstack //false 0 .startnewjob } 2 .stop } .internalbind |
| 2295 |
} { |
| 2296 |
{ } |
| 2297 |
} ifelse def |
| 2298 |
<1b> cvn |
| 2299 |
.actonuel % UEL is <esc>%-12345X and acts the same as ^D |
| 2300 |
{systemdict (.forceinterp_exit) cvn known {//true} {//false} ifelse} |
| 2301 |
{//false} ifelse |
| 2302 |
|
| 2303 |
{ |
| 2304 |
{ |
| 2305 |
currentfile (%-12345X) .peekstring pop (%-12345X) eq |
| 2306 |
{ currentfile .forceinterp_exit } if |
| 2307 |
} |
| 2308 |
} |
| 2309 |
{ |
| 2310 |
{currentfile (%-12345X) .peekstring pop (%-12345X) eq <04> cvn load if} |
| 2311 |
} ifelse .internalbind def |
| 2312 |
|
| 2313 |
<1b45> cvn { } def % PJL reset prologue (ESC E) |
| 2314 |
<1b451b> cvn <1b> cvn load def % PJL reset epilogue (ESC E + UEL) |
| 2315 |
(\001M) cvn % TBCP initiator |
| 2316 |
{ (\n!! ERROR !!\n) print |
| 2317 |
(In-job PJL tried to select TBCP communications Protocol which is no longer supported.\n) print |
| 2318 |
(You must recreate the input file without requiring TBCP support.\n\n) print |
| 2319 |
/TBCPDecode /filter /undefined signalerror. |
| 2320 |
} odef |
| 2321 |
/@PJL % H-P job control |
| 2322 |
{ |
| 2323 |
% Windows 2000 driver includes PJL into %%BeginFeature block. |
| 2324 |
% Identify this from the pattern on the stack: countdictstack lucas mark |
| 2325 |
% and fail the feature request. |
| 2326 |
|
| 2327 |
count 3 ge { |
| 2328 |
dup mark eq { |
| 2329 |
2 index countdictstack eq { |
| 2330 |
1 index /lucas where { /lucas get eq } { pop //false } ifelse { |
| 2331 |
stop |
| 2332 |
} if |
| 2333 |
} if |
| 2334 |
} if |
| 2335 |
} if |
| 2336 |
currentfile //=string readline pop pop |
| 2337 |
} .internalbind def |
| 2338 |
|
| 2339 |
% Install the EPS handler if needed |
| 2340 |
systemdict /EPSBoundingBoxInit known { EPSBoundingBoxInit } if |
| 2341 |
systemdict /EPSBoundingBoxInit .forceundef |
| 2342 |
|
| 2343 |
%% ---------------- SAFER stuff BEGIN -------------------%% |
| 2344 |
% If we want a "safer" system, disable some obvious ways to cause havoc. |
| 2345 |
.currentglobal //true .setglobal |
| 2346 |
/SAFETY 2 dict |
| 2347 |
dup /safe //false put |
| 2348 |
dup /tempfiles 10 dict noaccess put |
| 2349 |
readonly def |
| 2350 |
.setglobal |
| 2351 |
|
| 2352 |
/SAFERUndefinePostScriptOperators { |
| 2353 |
[ |
| 2354 |
% Used by our own test suite files |
| 2355 |
/.setdotlength % Bug687720.ps |
| 2356 |
/.sort /.setdebug /.mementolistnewblocks /getenv |
| 2357 |
/unread |
| 2358 |
/makeimagedevice |
| 2359 |
] |
| 2360 |
{systemdict exch .forceundef} forall |
| 2361 |
|
| 2362 |
//systemdict /SAFERUndefinePostScriptOperators .forceundef |
| 2363 |
} .forcebind def % must be bound and hidden for .forceundef |
| 2364 |
|
| 2365 |
/.lockfileaccess { |
| 2366 |
.currentpathcontrolstate |
| 2367 |
{ |
| 2368 |
//QUIET not |
| 2369 |
{ |
| 2370 |
(\n **** WARNING: .lockfileaccess or .setsafe called ****\n) print |
| 2371 |
( **** when file access controls are already active ****\n) print flush |
| 2372 |
} if |
| 2373 |
} |
| 2374 |
{ |
| 2375 |
[ |
| 2376 |
/FONTPATH .systemvar (*) .generate_dir_list_templates |
| 2377 |
/level2dict where { |
| 2378 |
pop |
| 2379 |
% Default resources : |
| 2380 |
[ currentsystemparams /GenericResourceDir get] (*) .generate_dir_list_templates |
| 2381 |
} if |
| 2382 |
/LIBPATH .systemvar (*) .generate_dir_list_templates |
| 2383 |
currentuserparams /ICCProfilesDir known { |
| 2384 |
[currentuserparams /ICCProfilesDir get] (*) |
| 2385 |
.generate_dir_list_templates |
| 2386 |
} if |
| 2387 |
] {/PermitFileReading exch .addcontrolpath} forall |
| 2388 |
|
| 2389 |
.activatepathcontrol |
| 2390 |
} ifelse |
| 2391 |
} .internalbind def |
| 2392 |
|
| 2393 |
/.locksafe_userparams { |
| 2394 |
SAFETY /safe get not { |
| 2395 |
<< |
| 2396 |
/PermitFileReading [ |
| 2397 |
currentuserparams /PermitFileReading get aload pop |
| 2398 |
/FONTPATH .systemvar (*) .generate_dir_list_templates |
| 2399 |
% Library files : |
| 2400 |
/LIBPATH .systemvar (*) .generate_dir_list_templates |
| 2401 |
% Resource files on OpenVMS requires a separate template (gs:[dir.*]*) |
| 2402 |
% because the (gs:[dir]*) doesn't cover them. |
| 2403 |
/LIBPATH .systemvar (*) .file_name_separator (*) |
| 2404 |
concatstrings concatstrings .generate_dir_list_templates |
| 2405 |
.languagelevel 2 ge { |
| 2406 |
% Default resources : |
| 2407 |
[ currentsystemparams /GenericResourceDir get] (*) .generate_dir_list_templates |
| 2408 |
% Default resources (OpenVMS, see comment above.) : |
| 2409 |
[ currentsystemparams /GenericResourceDir get] (*) .file_name_separator (*) |
| 2410 |
concatstrings concatstrings .generate_dir_list_templates |
| 2411 |
} if |
| 2412 |
currentuserparams /ICCProfilesDir known { |
| 2413 |
[currentuserparams /ICCProfilesDir get] (*) |
| 2414 |
.generate_dir_list_templates |
| 2415 |
} if |
| 2416 |
] |
| 2417 |
/LockFilePermissions //true |
| 2418 |
>> setuserparams |
| 2419 |
} |
| 2420 |
if |
| 2421 |
} .forcebind def |
| 2422 |
|
| 2423 |
|
| 2424 |
%% --- These are documented extensions --- |
| 2425 |
/.locksafe { |
| 2426 |
//.locksafe_userparams exec |
| 2427 |
//systemdict /getenv {pop //false} .forceput |
| 2428 |
% setpagedevice has the side effect of clearing the page, but |
| 2429 |
% we will just document that. Using setpagedevice keeps the device |
| 2430 |
% properties and pagedevice .LockSafetyParams in agreement even |
| 2431 |
% after a restore that changes the value to false. |
| 2432 |
currentglobal currentpagedevice gcheck setglobal % use correct VM space |
| 2433 |
<< /.LockSafetyParams //true >> setpagedevice |
| 2434 |
setglobal |
| 2435 |
//SAFETY /safe //true .forceput % overrides readonly |
| 2436 |
} .forcebind odef |
| 2437 |
|
| 2438 |
/.setsafe |
| 2439 |
{ |
| 2440 |
OLDSAFER { |
| 2441 |
SAFETY /safe get not { |
| 2442 |
<< |
| 2443 |
/PermitFileReading [ ] |
| 2444 |
/PermitFileWriting [ ] |
| 2445 |
/PermitFileControl [ ] |
| 2446 |
>> setuserparams |
| 2447 |
} |
| 2448 |
if |
| 2449 |
.locksafe |
| 2450 |
} |
| 2451 |
{ |
| 2452 |
//.lockfileaccess exec |
| 2453 |
DELAYBIND not { |
| 2454 |
//systemdict /SAFERUndefinePostScriptOperators .knownget {exec} if |
| 2455 |
} if |
| 2456 |
} |
| 2457 |
ifelse |
| 2458 |
} .forcebind odef |
| 2459 |
%% --- End documented extensions --- |
| 2460 |
|
| 2461 |
% This is only used during startup. Its required so that |
| 2462 |
% we can detect in setpagdevice that we are in fact in startup |
| 2463 |
% and allocate a *global* instead of local VM. We need it to be |
| 2464 |
% global to satisfy Display PostScript (see start of /setpagdevice |
| 2465 |
% in gs_setpd.ps) |
| 2466 |
% |
| 2467 |
/.locksafeglobal { |
| 2468 |
//.locksafe_userparams exec |
| 2469 |
systemdict /getenv {pop //false} put |
| 2470 |
% setpagedevice has the side effect of clearing the page, but |
| 2471 |
% we will just document that. Using setpagedevice keeps the device |
| 2472 |
% properties and pagedevice .LockSafetyParams in agreement even |
| 2473 |
% after a restore that changes the value to false. |
| 2474 |
currentglobal currentpagedevice gcheck setglobal % use correct VM space |
| 2475 |
<< /.LockSafetyParams //true |
| 2476 |
/..StartupGlobal //true |
| 2477 |
>> setpagedevice |
| 2478 |
setglobal |
| 2479 |
//SAFETY /safe //true .forceput % overrides readonly |
| 2480 |
} .forcebind def |
| 2481 |
|
| 2482 |
% See /.locksafeglobal above. |
| 2483 |
% |
| 2484 |
/.setsafeglobal { |
| 2485 |
OLDSAFER |
| 2486 |
{ |
| 2487 |
SAFETY /safe get not { |
| 2488 |
<< |
| 2489 |
/PermitFileReading [ ] |
| 2490 |
/PermitFileWriting [ ] |
| 2491 |
/PermitFileControl [ ] |
| 2492 |
>> setuserparams |
| 2493 |
} |
| 2494 |
if |
| 2495 |
//.locksafeglobal exec |
| 2496 |
} |
| 2497 |
{ |
| 2498 |
//.lockfileaccess exec |
| 2499 |
DELAYBIND not { |
| 2500 |
//systemdict /SAFERUndefinePostScriptOperators .knownget {exec} if |
| 2501 |
} if |
| 2502 |
} |
| 2503 |
ifelse |
| 2504 |
} .forcebind odef |
| 2505 |
|
| 2506 |
% If we are running in SAFER mode, lock things down |
| 2507 |
SAFER { .setsafeglobal } if |
| 2508 |
currentdict /.locksafe_userparams .undef |
| 2509 |
currentdict /.setsafeglobal .undef |
| 2510 |
currentdict /.locksafeglobal .undef |
| 2511 |
|
| 2512 |
%% ---------------- SAFER stuff END -------------------%% |
| 2513 |
|
| 2514 |
/UndefinePostScriptFilters { |
| 2515 |
[ |
| 2516 |
] |
| 2517 |
{filterdict exch undef} forall |
| 2518 |
} .forcebind def |
| 2519 |
|
| 2520 |
/UndefinePostScriptOperators { |
| 2521 |
% This list is of operators which no longer appear to be used, and which we do not believe |
| 2522 |
% to have any real use. For now we will undefine the operstors so they cannot easily be used |
| 2523 |
% but can be easily restored (just delete the name from the list in the array). In future |
| 2524 |
% we may remove the operator and the code implementation entirely. |
| 2525 |
[ |
| 2526 |
/.bitadd /.charboxpath /.cond /.runandhide /.popdevicefilter |
| 2527 |
/.execfile /.filenamesplit /.file_name_parent |
| 2528 |
/.setdefaultmatrix /.updatematrices /.isprocfilter /.unread /.psstringencode |
| 2529 |
/.buildsampledfunction /.isencapfunction /.currentaccuratecurves /.currentcurvejoin /.currentdashadapt /.currentdotlength |
| 2530 |
/.currentlimitclamp /.dotorientation /.setaccuratecurves /.setcurvejoin /.setdashadapt /.setdotorientation |
| 2531 |
/.setlimitclamp /.currentscreenlevels /.dashpath /.pathbbox /.identeq /.identne /.tokenexec /.pantonecallback |
| 2532 |
|
| 2533 |
% Used by our own test suite files |
| 2534 |
%/.setdotlength % Bug687720.ps |
| 2535 |
] |
| 2536 |
{systemdict exch .forceundef} forall |
| 2537 |
|
| 2538 |
% This list of operators are used internally by various parts of the Ghostscript startup code. |
| 2539 |
% Since each operator is a potential security vulnerability, and any operator listed here |
| 2540 |
% is not required once the initialisation is complete and functions are bound, we undefine |
| 2541 |
% the ones that aren't needed at runtime. |
| 2542 |
[ |
| 2543 |
/.callinstall /.callbeginpage /.callendpage |
| 2544 |
/.currentstackprotect /.setstackprotect /.errorexec /.finderrorobject /.installsystemnames /.bosobject /.fontbbox |
| 2545 |
/.type1execchar /.type2execchar /.type42execchar /.setweightvector /.getuseciecolor /processcolors /.includecolorspace |
| 2546 |
/.execn /.instopped /.stop /.stopped /.setcolorrendering /.setdevicecolorrendering /.buildcolorrendering1 /.builddevicecolorrendering1 |
| 2547 |
/.TransformPQR_scale_WB0 /.TransformPQR_scale_WB1 /.TransformPQR_scale_WB2 /.currentoverprintmode /.copydevice2 |
| 2548 |
/.devicename /.doneshowpage /.getbitsrect /.getdevice /.getdefaultdevice /.getdeviceparams /.gethardwareparams |
| 2549 |
/makewordimagedevice /.outputpage /.putdeviceparams /.setdevice /.currentshowpagecount |
| 2550 |
/.setpagedevice /.currentpagedevice /.knownundef /.setmaxlength /.rectappend /.initialize_dsc_parser /.parse_dsc_comments |
| 2551 |
/.fillCIDMap /.fillIdentityCIDMap /.buildcmap /.filenamelistseparator /.libfile /.getfilename |
| 2552 |
/.file_name_combine /.file_name_is_absolute /.file_name_separator /.file_name_directory_separator /.file_name_current /.filename |
| 2553 |
/.peekstring /.writecvp /.setupUnicodeDecoder /.jbig2makeglobalctx /.registerfont /.parsecff |
| 2554 |
/.getshowoperator /.getnativefonts /.beginform /.endform /.get_form_id /.repeatform /.reusablestream /.rsdparams |
| 2555 |
/.buildfunction /.sethpglpathmode /.currenthpglpathmode |
| 2556 |
/.currenthalftone /.sethalftone5 /.image1 /.imagemask1 /.image3 /.image4 |
| 2557 |
/.getiodevice /.getdevparms /.putdevparams |
| 2558 |
/.matchmedia /.matchpagesize /.defaultpapersize |
| 2559 |
/.oserrno /.setoserrno /.oserrorstring /.getCPSImode |
| 2560 |
/.getscanconverter /.setscanconverter /.type1encrypt /.type1decrypt/.languagelevel /.setlanguagelevel /.eqproc /.fillpage |
| 2561 |
/.shfill /.argindex /.bytestring /.namestring /.stringbreak /.stringmatch /.globalvmarray /.globalvmdict /.globalvmpackedarray /.globalvmstring |
| 2562 |
/.localvmarray /.localvmdict /.localvmpackedarray /.localvmstring /.systemvmarray /.systemvmdict /.systemvmpackedarray /.systemvmstring /.systemvmfile /.systemvmlibfile |
| 2563 |
/.systemvmSFD /.settrapparams /.currentsystemparams /.currentuserparams /.getsystemparam /.getuserparam /.setsystemparams /.setuserparams |
| 2564 |
/.checkpassword /.currentglobal /.gcheck /.imagepath /.currentoutputdevice |
| 2565 |
/.type /.writecvs /.setSMask /.currentSMask /.needinput /.countexecstack /.execstack |
| 2566 |
/filterdict /.cidfonttypes /.colorrenderingtypes |
| 2567 |
/.formtypes /.halftonetypes /.imagetypes /.imagemasktypes |
| 2568 |
/.patterntypes /.shadingtypes /.wheredict /.renderingintentdict |
| 2569 |
/.currentmatrix /.setmatrix |
| 2570 |
/.setlinecap /.setlinejoin /.sizeimagebox /.systemvmcheck |
| 2571 |
/.forceinterp_exit /.actonuel |
| 2572 |
/.init_otto_font_file |
| 2573 |
/.composefontdict |
| 2574 |
/.type1build |
| 2575 |
/.buildnativefontmap |
| 2576 |
/.completefont |
| 2577 |
/.definefakefonts |
| 2578 |
/.fontnameproperties |
| 2579 |
/.growfontdict |
| 2580 |
/.substitutefont /.substitutefontname |
| 2581 |
/.FontDirectory |
| 2582 |
/.charkeys |
| 2583 |
/.makesfnts |
| 2584 |
/.pickcmap |
| 2585 |
/.loadttcidfont |
| 2586 |
/.loadpdfttfont |
| 2587 |
/obind |
| 2588 |
/odef |
| 2589 |
/.packtomark |
| 2590 |
/.putdeviceprops |
| 2591 |
/putdeviceprops |
| 2592 |
/getdeviceprops |
| 2593 |
/finddevice |
| 2594 |
/.growdict /.growdictlength |
| 2595 |
/.userdict /.uservar |
| 2596 |
/.getdefaulthalftone |
| 2597 |
/.registererror |
| 2598 |
/.PurgeDict |
| 2599 |
/.runresource |
| 2600 |
/.numicc_components |
| 2601 |
/.set_outputintent |
| 2602 |
/.internalstopped |
| 2603 |
/.generate_dir_list_templates /.generate_dir_list_templates_with_length |
| 2604 |
/.type11mapcid /.type9mapcid |
| 2605 |
/.clearerror |
| 2606 |
/.beginpage /.endpage |
| 2607 |
/.getpath |
| 2608 |
/.confirm /.confirmread |
| 2609 |
/.tempfile |
| 2610 |
|
| 2611 |
% Used by a free user in the Library of Congress. Apparently this is used to |
| 2612 |
% draw a partial page, which is then filled in by the results of a barcode |
| 2613 |
% scanner and SQL database lookup. Its not clear to us exactly why this needs to be |
| 2614 |
% done as a partial page, but its easiest to restore the operator, and it seems like |
| 2615 |
% its a reasonably safe operator to restore, for the *very* few devices on which |
| 2616 |
% it will have any effect. Currently this uses the 'sync_output' device method |
| 2617 |
% to transfer the partial page, in future we may use a spec_op instead. |
| 2618 |
%/flushpage |
| 2619 |
|
| 2620 |
% Used by our own test suite files |
| 2621 |
%/.fileposition %image-qa.ps |
| 2622 |
|
| 2623 |
% Either our code uses these in ways which mean they can't be undefined, or they are used directly by |
| 2624 |
% test files/utilities, or engineers expressed a desire to keep them visible. |
| 2625 |
% |
| 2626 |
%/currentdevice /.sort /.buildfont0 /.buildfont1 /.buildfont2 /.buildfont3 /.buildfont4 /.buildfont9 /.buildfont10 /.buildfont11 |
| 2627 |
%/.buildfont32 /.buildfont42 /.swapcolors |
| 2628 |
%/currentdevice /.quit /.setuseciecolor /.needinput /.setoverprintmode /.special_op /.dicttomark /.knownget |
| 2629 |
%/.FAPIBuildGlyph /.FAPIBuildChar /.FAPIBuildGlyph9 |
| 2630 |
%/.max /.min /.setglobal |
| 2631 |
%/.setdebug /.mementolistnewblocks /getenv |
| 2632 |
] |
| 2633 |
{systemdict exch .forceundef} forall |
| 2634 |
|
| 2635 |
% level 2 operators, undefine from both systemdict and level2dict |
| 2636 |
[ |
| 2637 |
/.execform1 |
| 2638 |
/.getdevparams |
| 2639 |
/.setuserparams2 |
| 2640 |
/.startjob |
| 2641 |
/.checkFilePermitparams |
| 2642 |
/.copyparam |
| 2643 |
/.setdevicecolorrendering1 |
| 2644 |
/.buildpattern1 |
| 2645 |
/.findcategory |
| 2646 |
/.execinstall |
| 2647 |
/.findfontop |
| 2648 |
|
| 2649 |
% Couldn't figure out how to do these yet |
| 2650 |
% /.checkparamtype |
| 2651 |
% /.startnewjob |
| 2652 |
] |
| 2653 |
dup {level2dict exch .forceundef} forall |
| 2654 |
{systemdict exch .forceundef} forall |
| 2655 |
|
| 2656 |
% undef stuff from statusdict |
| 2657 |
[ |
| 2658 |
% /.setpagesize |
| 2659 |
] |
| 2660 |
{statusdict exch .forceundef} forall |
| 2661 |
|
| 2662 |
//systemdict /UndefinePostScriptFilters .forceundef |
| 2663 |
//systemdict /UndefinePostScriptOperators .forceundef |
| 2664 |
} .forcebind def % must be bound and hidden for .forceundef |
| 2665 |
|
| 2666 |
% If we delayed binding, make it possible to do it later. |
| 2667 |
/.bindnow { |
| 2668 |
currentuserparams /IdiomRecognition .knownget { |
| 2669 |
1 dict dup /IdiomRecognition //false put setuserparams |
| 2670 |
} if |
| 2671 |
//systemdict begin .bindoperators end |
| 2672 |
% Temporarily disable the typecheck error. |
| 2673 |
errordict /typecheck 2 copy get |
| 2674 |
errordict /typecheck { pop } put % pop the command |
| 2675 |
0 1 .delaycount 1 sub { .delaybind exch get .forcebind pop } for |
| 2676 |
0 1 .delayinternalcount 1 sub { .delayinternalbind exch get .forcebind pop } for |
| 2677 |
//systemdict /.delaybind {} .forceput % reclaim the space |
| 2678 |
//systemdict /.delayinternalbind {} .forceput % reclaim the space |
| 2679 |
//systemdict /.bindnow .forceundef % ditto |
| 2680 |
.applyundefinternalnames |
| 2681 |
put |
| 2682 |
SAFER { |
| 2683 |
//systemdict /SAFERUndefinePostScriptOperators get exec |
| 2684 |
} if |
| 2685 |
//systemdict /UndefinePostScriptFilters get exec |
| 2686 |
//systemdict /UndefinePostScriptOperators get exec |
| 2687 |
//systemdict /.forcecopynew .forceundef % remove temptation |
| 2688 |
//systemdict /.forceput .forceundef % ditto |
| 2689 |
//systemdict /.undef .forceundef % ditto |
| 2690 |
//systemdict /.bindoperators .forceundef |
| 2691 |
//systemdict /.forceundef .forceundef % ditto |
| 2692 |
//systemdict /.undefinternalnames .forceundef |
| 2693 |
//systemdict /.applyundefinternalnames .forceundef |
| 2694 |
//systemdict /.undefinternalnameslist .forceundef |
| 2695 |
//systemdict /.internalbind .forceundef |
| 2696 |
//systemdict /.forcebind .forceundef |
| 2697 |
currentuserparams /IdiomRecognition known { |
| 2698 |
1 dict dup /IdiomRecognition 4 -1 roll put setuserparams |
| 2699 |
} if |
| 2700 |
} .forcebind def |
| 2701 |
|
| 2702 |
% Turn off array packing, since some PostScript code assumes that |
| 2703 |
% procedures are writable. |
| 2704 |
//false setpacking |
| 2705 |
|
| 2706 |
(END INIT) VMDEBUG |
| 2707 |
|
| 2708 |
/.currentuserparams where { |
| 2709 |
pop |
| 2710 |
% Remove real user params from psuserparams. |
| 2711 |
mark .currentuserparams counttomark 2 idiv { |
| 2712 |
pop psuserparams exch undef |
| 2713 |
} repeat pop |
| 2714 |
% Update the copy of the user parameters. |
| 2715 |
mark .currentuserparams counttomark 2 idiv { |
| 2716 |
userparams 3 1 roll .forceput % userparams is read-only |
| 2717 |
} executeonly repeat pop |
| 2718 |
% Turn on idiom recognition, if available. |
| 2719 |
currentuserparams /IdiomRecognition known { |
| 2720 |
/IdiomRecognition //true .definepsuserparam |
| 2721 |
} if |
| 2722 |
psuserparams readonly pop |
| 2723 |
systemdict /.definepsuserparam undef |
| 2724 |
% Save a copy of userparams for use with save/restore |
| 2725 |
% (and, if implemented, context switching). |
| 2726 |
.currentglobal //false .setglobal |
| 2727 |
mark userparams { } forall .dicttomark readonly |
| 2728 |
currentdict exch /userparams exch .forceput % systemdict is read-only |
| 2729 |
.setglobal |
| 2730 |
} executeonly if |
| 2731 |
/.currentsystemparams where { |
| 2732 |
pop |
| 2733 |
% Remove real system params from pssystemparams. |
| 2734 |
mark .currentsystemparams counttomark 2 idiv { |
| 2735 |
pop pssystemparams exch .forceundef |
| 2736 |
} executeonly repeat pop |
| 2737 |
} if |
| 2738 |
|
| 2739 |
% Set up AlignToPixels : |
| 2740 |
|
| 2741 |
/AlignToPixels where { |
| 2742 |
mark /AlignToPixels 2 index /AlignToPixels get .dicttomark setuserparams |
| 2743 |
/AlignToPixels undef |
| 2744 |
} if |
| 2745 |
|
| 2746 |
% Set up GridFitTT : |
| 2747 |
|
| 2748 |
/GridFitTT where { |
| 2749 |
mark /GridFitTT 2 index /GridFitTT get .dicttomark setuserparams |
| 2750 |
/GridFitTT undef |
| 2751 |
} if |
| 2752 |
|
| 2753 |
% Establish local VM as the default. |
| 2754 |
//false /setglobal where { pop setglobal } { .setglobal } ifelse |
| 2755 |
$error /.nosetlocal //false put |
| 2756 |
|
| 2757 |
(END GLOBAL) VMDEBUG |
| 2758 |
|
| 2759 |
% Add the fake fonts to LocalFontDirectory. |
| 2760 |
//.definefakefonts exec % current VM is local |
| 2761 |
|
| 2762 |
% Execute scheduled inits : |
| 2763 |
1183615869 internaldict /.execute_scheduled_inits get exec |
| 2764 |
currentdict /.schedule_init undef |
| 2765 |
%currentdict /.execute_scheduled_inits undef |
| 2766 |
%currentdict /.delayed_init_queue undef |
| 2767 |
|
| 2768 |
% Make global and local FontDirectory read-only. |
| 2769 |
FontDirectory readonly pop |
| 2770 |
/GlobalFontDirectory where { pop GlobalFontDirectory readonly pop } if |
| 2771 |
|
| 2772 |
% If we are using DELAYBIND we have to defer the undefinition |
| 2773 |
% until .bindnow. |
| 2774 |
DELAYBIND not { |
| 2775 |
//systemdict /UndefinePostScriptFilters get exec |
| 2776 |
//systemdict /UndefinePostScriptOperators get exec |
| 2777 |
} if |
| 2778 |
end |
| 2779 |
|
| 2780 |
% Clean up VM, and enable GC. Use .vmreclaim to force the GC. |
| 2781 |
/vmreclaim where |
| 2782 |
{ pop //systemdict /NOGC get not { 2 .vmreclaim 0 vmreclaim } if |
| 2783 |
} if |
| 2784 |
systemdict /.vmreclaim .undef |
| 2785 |
level2dict /.vmreclaim .undef |
| 2786 |
|
| 2787 |
% Do this before systemdict is locked (see below for additional CETMODE setup using gs_cet.ps) |
| 2788 |
systemdict /CETMODE .knownget { |
| 2789 |
{ |
| 2790 |
(gs_cet.ps) runlibfile |
| 2791 |
} if |
| 2792 |
} if |
| 2793 |
systemdict /.makeoperator .undef % must be after gs_cet.ps |
| 2794 |
systemdict /.setCPSImode .undef % must be after gs_cet.ps |
| 2795 |
|
| 2796 |
DELAYBIND not { |
| 2797 |
systemdict /.bindnow .undef % We only need this for DELAYBIND |
| 2798 |
systemdict /.internalbind .undef |
| 2799 |
systemdict /.forcebind .undef |
| 2800 |
systemdict /.forcecopynew .undef % remove temptation |
| 2801 |
systemdict /.forceput .undef % ditto |
| 2802 |
systemdict /.forceundef .undef % ditto |
| 2803 |
systemdict /.undefinternalnames .undef |
| 2804 |
systemdict /.applyundefinternalnames .undef |
| 2805 |
systemdict /.undefinternalnameslist .undef |
| 2806 |
} if |
| 2807 |
|
| 2808 |
% Can't remove this one until the last minute :-) |
| 2809 |
DELAYBIND not { |
| 2810 |
systemdict /.undef .undef |
| 2811 |
} if |
| 2812 |
|
| 2813 |
WRITESYSTEMDICT { |
| 2814 |
SAFER { |
| 2815 |
(\n *** WARNING - you have selected SAFER, indicating you want Ghostscript\n) print |
| 2816 |
( to execute in a safer environment, but at the same time\n) print |
| 2817 |
( have selected WRITESYSTEMDICT. Unless you use this option with\n) print |
| 2818 |
( care and specifically, remember to execute code like:\n) print |
| 2819 |
( "systemdict readonly pop"\n) print |
| 2820 |
( it is possible that malicious code may be able to evade the\n) print |
| 2821 |
( limited security offered by the SAFER option.\n) print flush |
| 2822 |
}if |
| 2823 |
} |
| 2824 |
{ |
| 2825 |
systemdict readonly pop |
| 2826 |
} ifelse |
| 2827 |
|
| 2828 |
(END GC) VMDEBUG |
| 2829 |
|
| 2830 |
% The Adobe AGM_Core used by Illustrator 9 has some code that breaks |
| 2831 |
% if the 'product' is not (Adobe PostScript Parser). A bug has been |
| 2832 |
% submitted to Adobe since this also fails with Acrobat Distiller. |
| 2833 |
% As a temporary work around, the following HACK will work for |
| 2834 |
% devices without spot color support. Once Ghostscript can |
| 2835 |
% support DeviceN and spot color separations this will need to |
| 2836 |
% be 'true' in some cases. |
| 2837 |
userdict /AGM_preserve_spots //false put |
| 2838 |
|
| 2839 |
% The interpreter will run the initial procedure (start). |