Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.postscript > #1555
| Path | csiph.com!usenet.pasdenom.info!aioe.org!rt.uk.eu.org!feed.xsnews.nl!border-3.ams.xsnews.nl!post-feeder-02.xsnews.nl!frontend-F10-15.ams.news.kpn.nl |
|---|---|
| From | Cecil Westerhof <Cecil@decebal.nl> |
| Newsgroups | comp.lang.postscript |
| Subject | Re: Checking the stack is empty at the end of the program |
| Organization | Decebal Computing |
| References | <874nba9xyd.fsf@Aspire.decebal.nl> <kpKdnZ6ZmNZFJmTMnZ2dnUVZ_qWdnZ2d@earthlink.com> <cfac3023-1d88-463d-ae51-927c3f9cfa36@googlegroups.com> <87txj9951i.fsf@Aspire.decebal.nl> <0034540c-4d60-42b6-9d32-f3357f719636@googlegroups.com> <87pptx8zip.fsf@Aspire.decebal.nl> <d7307707-edf3-4dde-805b-e789439e340b@googlegroups.com> <a9d5917e-62ba-4a6f-bf29-4dc5e1166ee2@googlegroups.com> <b2a30f33-795a-4a93-ba63-2e3338b92c53@googlegroups.com> |
| X-Face | "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR<J%a^F2lh4[N~Yz4 nSp#c+aQo1b5=?HcNEkQ7QzF<])O3X4MDL/AYjys&*mt>,v+Pti8=Vi/Z"g^?b"E |
| X-Homepage | http://www.decebal.nl/ |
| Date | Thu, 01 Aug 2013 15:45:05 +0200 |
| Message-ID | <87d2px8qzi.fsf@Aspire.decebal.nl> (permalink) |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux) |
| Cancel-Lock | sha1:5hHDL6NKFdWV4smJ83zH3Q1to3o= |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| Lines | 124 |
| NNTP-Posting-Host | 77.171.42.144 |
| X-Trace | 1375365601 news.kpn.nl 12856 77.171.42.144@kpn/77.171.42.144:48264 |
| Xref | csiph.com comp.lang.postscript:1555 |
Show key headers only | View raw
Op donderdag 1 aug 2013 13:23 CEST schreef luser:
> On Thursday, August 1, 2013 5:56:09 AM UTC-5, luser- -droog wrote:
>> On Thursday, August 1, 2013 5:53:20 AM UTC-5, luser- -droog wrote:
>>
>>> On Thursday, August 1, 2013 5:40:46 AM UTC-5, Cecil Westerhof wrote:
>>
>>
>>
>>>> Works, thanks. Only one thing: I already showed the stack. Is it
>>
>>>> possible to circumvent the stack dumps?
>>
>>>
>>
>>>
>>
>>> Well, yeah. But aren't you going waaay overboard on this?
>>
>>>
>>
>>>
>>
>>>
>>
>>> Be that as it may, you can install your own error handler
>>
>>> in errordict.
>>
>>>
>>
>>> errordict/unregistered{
>>
>>> (Error: unregistered in ) print =
>>
>>
>>
>> interrupt %= stop
>>
>>
>>
>>> } put
>>
>>>
>>
>>>
>>
>>>
>>
>>> This is the procedure that signalerror looks up and calls.
>>
>>
>>
>> [remember to call `interrupt` or `stop` in the error handler
>>
>> or else it won't bail-out of the execution.]
>
> Actually, after looking at the error code again,
>
> http://code.google.com/p/xpost/source/browse/err.ps
>
> (borrowed from the book Inside Postscript),
> it's errordict/handleerror that you'd want to override.
> That's the procedure that prints out the error report.
>
> Although the above will probably work (maybe not, since
> we're explicitly calling signalerror), it bypasses
> several steps.
Now it works:
% to be called at the end of a program
% if stack empty (as it should be) say this
% otherwise signal this and show the stack
% ends the program to circumvent/signal it being called to soon
/endProgram {
count 0 eq {
(Stack empty at end of program) ==
quit
} {
count dup
1 eq {
(ERROR: object on stack at the end of the program) ==
} {
(ERROR: objects on stack at the end of the program) ==
} ifelse
{
(Unexpected object on stack: ) print
==
} repeat
errordict/handleerror {
interrupted
} put
/STACK-NOT-EMPTY cvx /unregistered signalerror
} ifelse
(This message should never be shown) ==
(If it is, the quit operater is overruled) ==
} def
And now I get:
$ psConvert.sh brainDump.ps
15:35:01: converting postscript
15:35:06: generating PDF
(ERROR: object on stack at the end of the program)
Unexpected object on stack: (test endProgram)
$
And when I cleanup the stack I get (default the PDF is converted to
PNG('s)):
$ psConvert.sh brainDump.ps
15:39:44: converting postscript
15:39:48: generating PDF
(Stack empty at end of program)
15:39:49: generating graphics
15:39:50: brainDump.ps converted
$
I am happy now: thanks.
By the way: what is the difference between interrupted and stop?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
Back to comp.lang.postscript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Checking the stack is empty at the end of the program Cecil Westerhof <Cecil@decebal.nl> - 2013-08-01 00:16 +0200
Re: Checking the stack is empty at the end of the program luser- -droog <mijoryx@yahoo.com> - 2013-07-31 15:41 -0700
Re: Checking the stack is empty at the end of the program Cecil Westerhof <Cecil@decebal.nl> - 2013-08-01 02:36 +0200
Re: Checking the stack is empty at the end of the program Dan Coby <adcoby@earthlink.net> - 2013-07-31 18:36 -0700
Re: Checking the stack is empty at the end of the program luser- -droog <mijoryx@yahoo.com> - 2013-07-31 23:53 -0700
Re: Checking the stack is empty at the end of the program Cecil Westerhof <Cecil@decebal.nl> - 2013-08-01 10:41 +0200
Re: Checking the stack is empty at the end of the program luser- -droog <mijoryx@yahoo.com> - 2013-08-01 02:37 -0700
Re: Checking the stack is empty at the end of the program Cecil Westerhof <Cecil@decebal.nl> - 2013-08-01 12:40 +0200
Re: Checking the stack is empty at the end of the program luser- -droog <mijoryx@yahoo.com> - 2013-08-01 03:53 -0700
Re: Checking the stack is empty at the end of the program luser- -droog <mijoryx@yahoo.com> - 2013-08-01 03:56 -0700
Re: Checking the stack is empty at the end of the program luser- -droog <mijoryx@yahoo.com> - 2013-08-01 04:23 -0700
Re: Checking the stack is empty at the end of the program Cecil Westerhof <Cecil@decebal.nl> - 2013-08-01 15:45 +0200
Re: Checking the stack is empty at the end of the program Cecil Westerhof <Cecil@decebal.nl> - 2013-08-01 13:18 +0200
Re: Checking the stack is empty at the end of the program luser- -droog <mijoryx@yahoo.com> - 2013-08-01 09:33 -0700
Re: Checking the stack is empty at the end of the program luser- -droog <mijoryx@yahoo.com> - 2013-08-01 18:25 -0700
csiph-web