summaryrefslogtreecommitdiff
path: root/Resource
diff options
context:
space:
mode:
authorKen Sharp <ken.sharp@artifex.com>2022-05-24 14:26:55 +0100
committerKen Sharp <ken.sharp@artifex.com>2022-05-24 14:26:55 +0100
commit43822922aed7150f58ab3b228508695030574143 (patch)
tree5f176cded61f10b0413146389073655e13befbb3 /Resource
parent136824c8ec37160da9b956511305c0f4bc6a3338 (diff)
downloadghostpdl-43822922aed7150f58ab3b228508695030574143.tar.gz
GS + GhostPDF - Honour PDFSTOPONERROR
Previously we ran the PDF interpreter from the PostScript interface more or less totally in a stopped context, which meant that it never exited with an error status, even when the file had an error. We now use PDFSTOPONERROR to determine whether the PDF interpreter should run in a stopped context or should actually return a PostScript error, which makes the interpreter exit with a non-zero status. This causes two files, output from pdfwrite, to throw errors where they previously did not when tested on the cluster. This is actually correct behaviour when compared with the action of the old PDF interpreter.
Diffstat (limited to 'Resource')
-rw-r--r--Resource/Init/pdf_main.ps115
1 files changed, 80 insertions, 35 deletions
diff --git a/Resource/Init/pdf_main.ps b/Resource/Init/pdf_main.ps
index 0aa940d29..28e1e8268 100644
--- a/Resource/Init/pdf_main.ps
+++ b/Resource/Init/pdf_main.ps
@@ -801,7 +801,14 @@ currentdict /PDFSwitches undef
{
PDFFile //null eq not
{
- PDFFile {.PDFInfo} stopped not
+ PDFSTOPONERROR
+ {
+ PDFFile .PDFInfo //true
+ }
+ {
+ PDFFile {.PDFInfo} stopped not
+ } ifelse
+
{
dup /NumPages known
{
@@ -1015,32 +1022,50 @@ currentdict /PDFSwitches undef
/pget {2 copy known {get //true}{pop pop //false}ifelse}bind def
newpdf_gather_parameters
- {.PDFInit} stopped
- {
- /PDFFile //null def
- /PDFInfo //null def
- }
+ PDFSTOPONERROR
{
+ .PDFInit
/PDFFile exch def
pdfopen
/PDFInfo exch def
pop
+ }
+ {
+ {.PDFInit} stopped
+ {
+ /PDFFile //null def
+ /PDFInfo //null def
+ }
+ {
+ /PDFFile exch def
+ pdfopen
+ /PDFInfo exch def
+ pop
+ }ifelse
}ifelse
} bind def
/newpdf_pdfgetpage
{
dup 1 sub
- PDFFile exch {.PDFPageInfo} stopped
+ PDFSTOPONERROR
{
- pop pop
- ( **** Error: Couldn't get page info.\n) newpdf_pdfformaterror
- ( Output may be incorrect.\n) newpdf_pdfformaterror
- //null
- }{
+ PDFFile exch .PDFPageInfo
dup 3 -1 roll
/Page# exch put
- } ifelse
+ }
+ {
+ PDFFile exch {.PDFPageInfo} stopped
+ {
+ pop pop
+ ( **** Error: Couldn't get page info.\n) newpdf_pdfformaterror
+ ( Output may be incorrect.\n) newpdf_pdfformaterror
+ //null
+ }{
+ dup 3 -1 roll
+ /Page# exch put
+ } ifelse
+ }ifelse
} bind def
/newpdf_process_trailer_attrs
@@ -1060,17 +1085,24 @@ currentdict /PDFSwitches undef
/newpdf_pdfshowpage_finish
{
- /Page# get PDFFile exch 1 sub {.PDFDrawPage} stopped
+ PDFSTOPONERROR
{
- pop pop
- ( **** Error: Page drawing error occured.\n) newpdf_pdfformaterror
- ( Output may be incorrect.\n) newpdf_pdfformaterror
- } if
- {showpage} stopped
+ /Page# get PDFFile exch 1 sub .PDFDrawPage
+ showpage
+ }
{
- ( **** Error: Page drawing error occured.\n) newpdf_pdfformaterror
- ( Could not draw this page at all, page will be missing in the output.\n) newpdf_pdfformaterror
- } if
+ /Page# get PDFFile exch 1 sub {.PDFDrawPage} stopped
+ {
+ pop pop
+ ( **** Error: Page drawing error occured.\n) newpdf_pdfformaterror
+ ( Output may be incorrect.\n) newpdf_pdfformaterror
+ } if
+ {showpage} stopped
+ {
+ ( **** Error: Page drawing error occured.\n) newpdf_pdfformaterror
+ ( Could not draw this page at all, page will be missing in the output.\n) newpdf_pdfformaterror
+ } if
+ }ifelse
grestore
} bind def
@@ -1098,22 +1130,29 @@ currentdict /PDFSwitches undef
{
dup PDFFile //null ne
{
- PDFFile {.PDFStream} stopped
+ PDFSTOPONERROR
{
- pop pop
- ( **** Error: Couldn't initialise file.\n) newpdf_pdfformaterror
- ( Output may be incorrect.\n) newpdf_pdfformaterror
- <</NumPages 0>>
+ PDFFile .PDFStream
+ PDFFile .PDFInfo
}
{
- PDFFile {.PDFInfo} stopped
+ PDFFile {.PDFStream} stopped
{
- pop
- ( **** Error: Couldn't get page information.\n) newpdf_pdfformaterror
+ pop pop
+ ( **** Error: Couldn't initialise file.\n) newpdf_pdfformaterror
( Output may be incorrect.\n) newpdf_pdfformaterror
<</NumPages 0>>
- } if
- } ifelse
+ }
+ {
+ PDFFile {.PDFInfo} stopped
+ {
+ pop
+ ( **** Error: Couldn't get page information.\n) newpdf_pdfformaterror
+ ( Output may be incorrect.\n) newpdf_pdfformaterror
+ <</NumPages 0>>
+ } if
+ } ifelse
+ }ifelse
}
{
pop
@@ -1123,10 +1162,16 @@ currentdict /PDFSwitches undef
/newpdf_pdfclose
{
- PDFFile {.PDFClose} stopped
+ PDFSTOPONERROR
{
- pop
- } if
+ PDFFile .PDFClose
+ }
+ {
+ PDFFile {.PDFClose} stopped
+ {
+ pop
+ } if
+ }ifelse
} bind def
% <int> <int> dopdfpages -