Closed Bug 283437 Opened 20 years ago Closed 18 years ago

[Postscript] If the page size is not set correctly, there will be a PostScript error "configurationerror"

Categories

(Core :: Printing: Output, defect)

x86
Linux
defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: leon.sha, Assigned: leon.sha)

Details

Attachments

(3 files, 1 obsolete file)

If the page size is not set correctly, there will be a PostScript error
"configurationerror"

ERROR: configurationerror
OFFENDING COMMAND: setpagedevice.

STACK:

-dictionary-
Attached patch PatchSplinter Review
I use "<<" here. This is a postscript level 2 operator.
But If the postscript interpreters only support level 1, it will not have
"setpagedevice". This part of postscript code will not be used by postscript
level 1 interpreters.
Attachment #175413 - Flags: review?(kherron+mozilla)
Assignee: printing → leon.sha
Comment on attachment 175413 [details] [diff] [review]
Patch

>   // Tell the printer what size paper it should use
>   fprintf(f,
>     "/setpagedevice where\n"			// Test for the feature
>-    "{ pop 1 dict\n"				// Set up a dictionary
>-    "  dup /PageSize [ %s %s ] put\n"		// Paper dimensions
>-    "  setpagedevice\n"				// Install settings
>+    "{ <<\n"

You need a "pop" here, as in the original. The "where" operator pushes a
dictionary on the stack which has to be removed.


>+    "  /PageSize [ %s %s ]\n"			// Paper dimensions
>+    "  /Policies <<\n"
>+    "  /PolicyNotFound 1\n"			// Ignore the wrong request

"PolicyNotFound" sets the default error handling policy. The patch sets an
explicit policy for PageSize errors, so setting the default policy isn't
necessary, is it? I'd rather be conservative and leave that out, particularly
given that we're in beta right now.

r=kherron provided you fix these. If you feel strongly about PolicyNotFound, we
can talk about it.
Attachment #175413 - Flags: review?(kherron+mozilla) → review+
Attachment #175792 - Flags: superreview?(roc)
(In reply to comment #2)
> (From update of attachment 175413 [details] [diff] [review] [edit])
> >   // Tell the printer what size paper it should use
> >   fprintf(f,
> >     "/setpagedevice where\n"			// Test for the feature
> >-    "{ pop 1 dict\n"				// Set up a dictionary
> >-    "  dup /PageSize [ %s %s ] put\n"		// Paper dimensions
> >-    "  setpagedevice\n"				// Install settings
> >+    "{ <<\n"
> 
> You need a "pop" here, as in the original. The "where" operator pushes a
> dictionary on the stack which has to be removed.
> 
> 
> >+    "  /PageSize [ %s %s ]\n"			// Paper dimensions
> >+    "  /Policies <<\n"
> >+    "  /PolicyNotFound 1\n"			// Ignore the wrong request
> 
> "PolicyNotFound" sets the default error handling policy. The patch sets an
> explicit policy for PageSize errors, so setting the default policy isn't
> necessary, is it? I'd rather be conservative and leave that out, particularly
> given that we're in beta right now.
> 
> r=kherron provided you fix these. If you feel strongly about PolicyNotFound, we
> can talk about it.
> 

Yes, you are right.
Attachment #175792 - Flags: superreview?(roc) → superreview+
Checking in nsPostScriptObj.cpp;
/cvsroot/mozilla/gfx/src/ps/nsPostScriptObj.cpp,v  <--  nsPostScriptObj.cpp
new revision: 1.118; previous revision: 1.117
done
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
(In reply to comment #1)
> Created an attachment (id=175413) [edit]
> Patch
> 
> I use "<<" here. This is a postscript level 2 operator.
> But If the postscript interpreters only support level 1, it will not have
> "setpagedevice". This part of postscript code will not be used by postscript
> level 1 interpreters.

https://bugzilla.mozilla.org/show_bug.cgi?id=234182#c11
It is very strange that when I use this method to test postscript language
level, gs give me an error.

---------------------
Error: /syntaxerror in -file-
Operand stack:
   false
---------------------

Is that to say that I can not use "<<" and ">>" even in "{}"?
Should I change this or it is just a gs's bug?

> Is that to say that I can not use "<<" and ">>" even in "{}"?
> Should I change this or it is just a gs's bug?
> 

I am wrong.
In the PostScript® LANGUAGE REFERENCE third edition page 783/912 d.3.4, there is
the warning. 

"If a program containing these constructs is sent to a LanguageLevel 1
interpreter, a syntaxerror will occur, even if the constructs appear only inside
procedures that are to be executed conditionally according to LanguageLevel."

Attached patch Use (<<) cvx exec to replace << (obsolete) — Splinter Review
Attachment #176715 - Flags: superreview?(roc)
Attachment #176715 - Flags: review?(kherron+mozilla)
Comment on attachment 176715 [details] [diff] [review]
Use (<<) cvx exec to replace <<


>     "/setpagedevice where\n"			// Test for the feature
>     "{ pop\n"
>-    "  <<\n"
>+    "  (<<) cvx exec\n"
>     "  /PageSize [ %s %s ]\n"			// Paper dimensions
>-    "  /Policies <<\n"
>+    "  /Policies (<<) cvx exec\n"
>     "  /PageSize 3\n"				// Select the nearest page size to fit
>-    "  >>\n"
>-    "  >> setpagedevice\n"				// Install settings
>+    "  (>>) cvx exec\n"
>+    "  (>>) cvx exec\n"
>+    "  setpagedevice\n"

I'm inclined to just go back to the level 1 syntax. It has fewer operators,
uses less stack, and IMHO is a little cleaner.

/setpagedevice where
{ pop 2 dict
  dup /PageSize [ %s %s ] put
  dup /Policies 1 dict
    dup /PageSize 3 put
  put
  setpagedevice
} if
Yes Ken, you are correct.
Attachment #176857 - Flags: superreview?(roc)
Attachment #176857 - Flags: review?(kherron+mozilla)
Attachment #176857 - Flags: review?(kherron+mozilla) → review+
Attachment #176715 - Attachment is obsolete: true
Attachment #176715 - Flags: superreview?(roc)
Attachment #176715 - Flags: review?(kherron+mozilla)
Attachment #176857 - Flags: superreview?(roc) → superreview+
Fix checked in.
(In reply to comment #9)
>     "  /PageSize 3\n"		// Select the nearest page size to fit

This change seems to have caused bug 324635.
Because of the bug 324635, user or printer driver should take care of the page size by itself. I'll mark this bug as invalid.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Status: REOPENED → RESOLVED
Closed: 20 years ago18 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: