EOF that isn't
-
Guess what happens when you feed Adobe Distiller a file that ends like this:
(76 pages worth of stuff snipped) %%EOF 52)show 673 331 gm (Xenon)show 673 364 gm 1.02630 0.(.......................................)ashow 673 363 gm ( )show 673 522 gm (44)show 685 331 gm -0.32830 0.(Yakuza)ashow 685 368 gm 1.02940 0.(...................................)ashow 685 366 gm ( )show 685 509 gm 0.71441 0. 32 0.07144 0.(6, 44)awidthshow F T cp %%Trailer cd end %%Pages: 78 0 %%EOF
Yes, it throws a syntax error for the `)` after the 52 after the first `%%EOF`.
-
I love such obvious posts with random numbers and letters.
-
@neighborhoodbutcher They keep your brain from going stale.
-
@gurth if you figure this code out, there's not much left out of your brain.
-
I wonder if this has anything to do with how PDF files need to be read back to front; the file can contain multiple %%EOF markers and the last one should point to the previous one if the document was appended with "revisions".
Maybe this leaked into their PostScript interpreter as well? What happens if you remove the last
%%EOF
?
-
@jbert This is from a file originally created as PostScript ca. 1993. I’m not sure what has gone wrong with it, but everything after the first
%%EOF
is a duplicate of what’s immediately before it, except that toward the end it says%%Pages: 78 0
while in the bit I deleted, it says%%Pages: 76 0
.Deleting everything after the first
%%EOF
got Distiller to PDF the file correctly. Removing only the last%%EOF
wouldn’t work because the interpreter would still encounter the malformed52)
.I have a feeling this wasn’t a problem in 1993 because pretty much everybody with a use for PostScript files would have simply done
lpr file.ps
and found the printer to have spewed out an error after the real last page. Or so I suppose — I don’t have a PostScript printer to try it with, and even if I had, I don’t feel like wasting the paper to find out.@gąska said in EOF that isn't:
if you figure this code out, there's not much left out of your brain.
The numbers are just coordinates and stuff. I have some trouble imagining that you guys, who should all be experts at reading code, can’t figure out that there are two
%%EOF
s in the file when the bit I started off with says that that keyword (“comment” in PostScript jargon) signals the end of the file and (supposedly) the end of processing it.
-
@gurth %%EOF and coordinates are the easy part. But what the dots and the parentheses are for, I have no goddamn clue.
-
@gąska said in EOF that isn't:
@gurth %%EOF and coordinates are the easy part. But what the dots and the parentheses are for, I have no goddamn clue.
They print dots at that location, yeah?
-
@gąska said in EOF that isn't:
@gurth if you figure this code out, there's not much left out of your brain.
It's PostScript. I read it just fine.
I may also have brain damage.
-
@tsaukpaetra said in EOF that isn't:
@gąska said in EOF that isn't:
@gurth %%EOF and coordinates are the easy part. But what the dots and the parentheses are for, I have no goddamn clue.
They print dots at that location, yeah?
I thought that they indicate the position of the cat on the keyboard?
-
@gąska said in EOF that isn't:
@gurth %%EOF and coordinates are the easy part. But what the dots and the parentheses are for, I have no goddamn clue.
The last page of the document contains an index, with each line consisting of a word followed by a right-aligned page number, and dots to connect the two. The parentheses are apparently for PostScript’s benefit, enclosing the text to be output, much like
""
is used for strings in many other languages. So this bit:673 331 gm (Xenon)show 673 364 gm 1.02630 0.(.......................................)ashow 673 363 gm ( )show 673 522 gm (44)show
renders something like:
Xenon....................................... 44
Amazingly, I deduced this on my first real look at PostScript behind the scenes. I had a lot more trouble figuring out Distiller’s error message, specifically its stack trace, the entirety of which was:
52
-
@gurth wait, I was right? Holy fuck, that was just a guess!
-
FWIW, parentheses are how you do string literals in PS.