I find the output for the following code sequence surprising: gs -c '/a4{} def (png16m) selectdevice currentpagedevice quit' GPL Ghostscript 8.71 (2010-02-10) Copyright (C) 2010 Artifex Software, Inc. All rights reserved. This software comes with NO WARRANTY: see the file PUBLIC for details. Error: /rangecheck in --currentpagedevice-- Operand stack: (etc) I cannot see why '(png16m) selectdevice currentpagedevice' should fail if a4 is defined to a null procedure. It works fine if the '/a4{} def' is omitted. As setpagedevice includes an implicit currentpagedevice, gs -c '/a4{} def (png16m) selectdevice <<>> setpagedevice quit' also fails for any dictionary. The error occurs if any of the papersize operators known to gs is redefined (a3, letter, a4small, etc.) It seems to occur with most output devices too (png16m can be replaced by x11). It seems that something is iterating over .papertypenames and making assumptions about the form of the procedures defined there. MJR
See the comment in gs_statd.pd : % Note: these executable arrays should all begin with two % integers which are the width and height (see gs_setpd.ps). /11x17 {792 1224 //.setpagesize exec} bind def % 11x17 portrait /a3 {842 1191 //.setpagesize exec} bind def /a4 {595 842 //.setpagesize exec} bind def The fact that this restriction survives past the start-up time is a bug.
Created attachment 6502 [details] patch
Re-implement handling of named page sizes to avoid dependence on the definitions of compatibility operators (a4, letter, etc.) in userdict. The patch has been committed as a rev. 11517.