Repository navigation
Fix #498, part of #505: EPS image sources read in turn, restore undoes dictionary changes (PLRM) - #540
Merged
Conversation
An image can take one data source per colour component (MultipleDataSources, or `colorimage` with multi true). The PostScript Language Reference (3rd ed., §4.10 "Images" and `image`/`colorimage` in chapter 8) has the operator read the sources in turn, the same amount from each. The reader drained each source on its own instead: when the sources are procedures reading one file a row at a time, the first plane took the rows of every component and the image came out in sheared horizontal bands, as in #498. - Data sources are read in turn by one reader, `read_sources`: a procedure once a round, a file or string a row a round, until each plane is full or its source ends. Single sources, procedure filters and masked images use it too; a string source resumes where it left off. - Tests (`tests_images.rs`, programs written from the reference): procedures reading one file in the dictionary and `colorimage` operand forms (fails without the fix), separate string sources, rows padded to a byte at 1, 2, 4, 12 and 16 bits with an odd width (one and several sources), Flate PNG predictors with every row filter at an odd width. The import fuzz vocabulary has several sources reading one file and sources of uneven lengths. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The PostScript Language Reference (3rd ed., §3.7.3 "Save and Restore") has `restore` reset composite objects in local VM to their values at the `save`. The reader only restored the graphics state, so dictionary entries changed between `save` and `restore` stayed changed: a program that counts its open saves in a dictionary and refuses to go past a depth stopped after that many saves in sequence, and the file fell back to its preview. EPS files with many images, each drawn between `save` and `restore`, are a likely case of #505; its reporter hasn't sent a file, so this is part of it. - While a `save` is open, `def`, `store`, `put`, `undef` and dictionary `copy` keep each entry's old value in a journal (counted against the memory budget); `restore` undoes it, newest change first, down to its save. A save restored already, itself or through an outer one, is no longer valid (`invalidrestore`, §3.7.3). - `cachestatus` reports a device's cache sizes (chapter 8) instead of zeros: its last value, the most bytes one cached glyph may take, is what programs divide by. - Tests (programs written from the reference): 100 saves counted in a dictionary under a depth limit, each dictionary change undone, saves restored twice, `cachestatus`'s glyph limit. Mutation-checked: without the journal or with a zero `cachestatus` the test fails. The import fuzz vocabulary has saves and restores around dictionary changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bflatastic
force-pushed
the
fix/eps-sources-restore
branch
from
October 8, 2026 16:44
aaf497c to
b43b15a
Compare
Member
Author
|
Full |
This was referenced Oct 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Redoes PR #507's two EPS import fixes using the PostScript Language Reference (3rd ed.) only. It's stacked on #535; review after it, or only the last two commits. Fixes #498. Part of #505.
Fix #498: an image's several data sources are read in turnimageandcolorimageoperators read multiple data sources in turn, the same amount from each (§4.10 "Images", chapter 8).read_sources, handles single sources, procedure filters and masked images too.tests_images.rs:colorimageoperand form;Part of #505:restoreputs dictionaries back as they were at thesave(§3.7.3)def,store,put,undefand dictionarycopykeep the old value of each entry they change in a journal, counted against the memory budget.restoreundoes those changes, newest first. Restoring a save that is no longer valid raisesinvalidrestore.cachestatusnow reports a device's cache sizes instead of zeros.restoreputs the count back. It fails without the journal, and also fails with a zerocachestatus.Dropped: #507's rule that stripped a
*Nsuffix from font names. No public spec or user file backs it.Comments cite PLRM sections. The import fuzz vocabulary covers several sources reading one file, sources of uneven lengths, and save/restore around dictionary changes. ROADMAP updated.
Checks
1c449b81), onorigin/main@ c0396c0.cargo xtask ci: all 7 steps passed (fmt, clippy, test with 3991 tests passing, assets, brands, layers, wasm).🤖 Generated with Claude Code