Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1221 > unrolled thread

save restore problem - is it possible to use it in this way?

Started bywojtulek@gmail.com
First post2013-01-04 08:39 -0800
Last post2013-01-07 06:38 -0800
Articles 4 — 4 participants

Back to article view | Back to comp.lang.postscript


Contents

  save restore problem - is it possible to use it in this way? wojtulek@gmail.com - 2013-01-04 08:39 -0800
    Re: save restore problem - is it possible to use it in this way? ken <ken@spamcop.net> - 2013-01-04 16:40 +0000
    Re: save restore problem - is it possible to use it in this way? luser- -droog <mijoryx@yahoo.com> - 2013-01-04 10:10 -0800
      Re: save restore problem - is it possible to use it in this way? John Deubert <john@acumentraining.com> - 2013-01-07 06:38 -0800

#1221 — save restore problem - is it possible to use it in this way?

Fromwojtulek@gmail.com
Date2013-01-04 08:39 -0800
Subjectsave restore problem - is it possible to use it in this way?
Message-ID<7f92a7b6-e0fa-4481-b50a-9ba3aa56be07@googlegroups.com>
Hello!

I have a problem with postscript file. Probably I've found the issue, but I'm still not sure ;)

I know what I can save and restore some properties with the use of save-restore pair:

...
save
...
restore
...


but what about this way?

...
save 
...
save
...
restore
...
restore

Should it be ok too?
If yes then probably there is something wrong with the stack between save and restore and restore have wrong data on the stack? How to check it? PS file has more than 1k lines :/

Best regards,
Wojtek


[toc] | [next] | [standalone]


#1222

Fromken <ken@spamcop.net>
Date2013-01-04 16:40 +0000
Message-ID<MPG.2b511661af912eca9898a3@usenet.plus.net>
In reply to#1221
In article <7f92a7b6-e0fa-4481-b50a-9ba3aa56be07@googlegroups.com>, 
wojtulek@gmail.com says...
> 
> Hello!
> 
> I have a problem with postscript file. Probably I've found the issue, but I'm still not sure ;)
> 
> I know what I can save and restore some properties with the use of save-restore pair:
> 
> ...
> save
> ...
> restore
> ...
> 
> 
> but what about this way?
> 
> ...
> save 
> ...
> save
> ...
> restore
> ...
> restore
> 
> Should it be ok too?

Yes, saves and restores (like gsave/grestore) are on a stack.

> If yes then probably there is something wrong with the stack between save and restore and restore have wrong data on the stack? 

Possibly, yes.

> How to check it? PS file has more than 1k lines :/

You need to inspect the stack, pstack willl help here. There is no 
really easy way to debug this.

			Ken

[toc] | [prev] | [next] | [standalone]


#1223

Fromluser- -droog <mijoryx@yahoo.com>
Date2013-01-04 10:10 -0800
Message-ID<0e0e2def-ead5-467b-8ce9-3729ed1cd0ad@googlegroups.com>
In reply to#1221
On Friday, January 4, 2013 10:39:09 AM UTC-6, wojt...@gmail.com wrote:

> Should it be ok too?
> 
> If yes then probably there is something wrong with the stack between save and restore and restore have wrong data on the stack? How to check it? PS file has more than 1k lines :/

If you can't trust the stack, trust the dictionary.

/saveobjectA save def

/saveobjectB save def

saveobjectB restore

saveobjectA restore

[toc] | [prev] | [next] | [standalone]


#1226

FromJohn Deubert <john@acumentraining.com>
Date2013-01-07 06:38 -0800
Message-ID<2013010706381659521-john@acumentrainingcom>
In reply to#1223
On 2013-01-04 18:10:00 +0000, luser- -droog said:

> On Friday, January 4, 2013 10:39:09 AM UTC-6, wojt...@gmail.com wrote:
> 
>> Should it be ok too?
>> 
>> If yes then probably there is something wrong with the stack between 
>> save and restore and restore have wrong data on the stack? How to check 
>> it? PS file has more than 1k lines :/
> 
> If you can't trust the stack, trust the dictionary.
> 
> /saveobjectA save def
> 
> /saveobjectB save def
> 
> saveobjectB restore
> 
> saveobjectA restore

I'd go a step further and say you should absolutely not use the operand 
stack to store the save objects created by save and used by restore; 
too much opportunity for things to go wrong. It is much better to put 
the objects into a key-value pair, as droog says above.

If you absolutely must leave the saveobject on the stack (perhaps 
because you're working with existing code written by someone else), 
then you can test the top of the stack before executing restore:

dup type /savetype
{ restore }{ ... handle or head off typecheck error here ... } ifelse

- John

-- 
========
John Deubert
Acumen Training
PostScript & PDF Engineering Classes & Consulting
www.acumentraining.com

Learn PostScript programming techniques
Read the free Acumen Journal
acumentraining.com/acumenjournal.html

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web