[cups.general] How does "stopped cleartomark" work?

Helge Blischke h.blischke at srz.de
Wed Apr 26 06:24:07 PDT 2006


Johannes Meixner wrote:
> Hello,
> 
> CUPS' pstops filter (form CUPS version 1.1.23) adds printer
> specific features like
> --------------------------------------------------------------
> [{
> %%BeginFeature: *PageSize A4
> <</PageSize[595 842]/ImagingBBox null>>setpagedevice
> %%EndFeature
> } stopped cleartomark
> --------------------------------------------------------------
> 
> I do not understand how "[ {...} stopped cleartomark" works.
> 
> Acording to the Adobe PostScript Language Reference (3. edition)
> "stopped" leaves "false" on the stack if {...} returns noramlly
> and "true" otherwise but regardless of the outcome
> "cleartomark" is executed in any case.
> 
> I am missing the "if" as in Adobe's example for "stopped":
> "{...} stopped {handleerror} if"
> 
> Why is there no "if" or why is there "stopped" when nothing
> depends on its outcome?
> 
> 
> Kind Regards
> Johannes Meixner

The stopped operator is used in this context catch possible errors by the
PostScript program itself; otherwise the program would abort with a PostScript error.
The following cleartomark is used to remove whatever a failing feature request
would have left on the operand stack.

An example:
look at the following code:

[{<</Duplex true>>setpagedevice} stopped cleartomark

If the printer in question *can* duplex, the setpagedevice statement would leave nothing
on the stack, the stopped operator would leave false, and the cleartomark would trash
this value, including the mark.
But if the printer has no installed duplexer, the setpagedevice statement would probably
fail with a configuration error, ans what is left on the stack is - AFAIK - dependent
on the version of the PS interpreter (it sould leave the original operands on the stack,
but prior to a version which I don't remember there may be some additional junk as well).
In this case the stopped operator prevents the PS program to be aborted with this error
and causes a true value pushed onto the stack; the following cleartomark simly removes
whatever the failing setpagedevice has left on the operand stack.

Any questions left?

Helge


-- 
Helge Blischke
Softwareentwicklung
SRZ Berlin | Firmengruppe besscom
http://www.srz.de




More information about the cups mailing list