Repository navigation
engine: \ProcessOptions optional-star peek must not strand the following token - #18
Merged
Merged
Conversation
…oken
peekStar() looked ahead for \ProcessOptions* with skipOptSpace()+getNext()+
back(): when no star followed, the peeked token was pushed back into a pending
token list, ahead of the base input it was scanned from. That is invisible until
\ProcessOptions then executes a class option whose code \input's a file. svjour's
[epj] option runs \InputIfFileExists{svepj.clo}{\let\journalopt\CurrentOption}{},
which splices svepj.clo into the base at the mouth position — landing it BETWEEN
the stranded token and the base tokens that followed. svjour's next source line,
\ifx\journalopt\@empty, had already had its \ifx peeked and stranded, so \ifx
bound to the loaded file's first token (\ProvidesFile{...}) instead of
\journalopt. The mismatched \ifx skipped to end-of-file, discarding the whole main
vertical list: the paper rendered 0 pages (arXiv 2604.26376, svjour/epj).
Make the optional-star lookahead non-destructive: snapshot the input with
markInput(), and on a non-star token restoreInput() instead of back(), leaving the
input exactly as it stood so a later file splice cannot slip in between the peeked
token and what follows it.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Fixes a whole-document swallow (0 pages) on svjour/epj papers such as arXiv 2604.26376.
Root cause
peekStar()(used by\ProcessOptionsand\DeclareOption) does a destructive lookahead for a*:skipOptSpace()+getNext()+back(). When no star follows, the peeked token isback()-ed into a pending token list — ahead of the base input it was scanned from.That is harmless until
\ProcessOptionsexecutes a class option whose code\inputs a companion file. svjour’s[epj]option runs:which splices
svepj.clointo the base at the mouth position — landing it between the stranded token and the base tokens that followed it. svjour’s very next source line is:\ProcessOptionspeeks for a star, reads and strands the following\ifx, then loadssvepj.clo. When the stranded\ifxfinally runs, its operands are no longer\journalopt\@emptybut the freshly-spliced file’s first token,\ProvidesFile{...}. The mismatched\ifxis false and skips to end-of-file (the runaway aggravated by\let\if@runhead\iftrue/\let\if@smartand\iftrueoperands being counted during the skip), discarding the entire main vertical list → 0 pages.Fix
Make the optional-star lookahead non-destructive: snapshot the input with
markInput(), and on a non-star tokenrestoreInput()instead ofback(). The input is left exactly as it stood, so a later file splice cannot slip in between the peeked token and what follows it.Verification
TestProcessOptionsPeekDoesNotStrandFollowingTokenreproduces the svjour/epj structure (class with\DeclareOption*{\InputIfFileExists{sv\CurrentOption.clo}{...}},\ProcessOptionsimmediately followed by\ifx\journalopt\@empty, plus a companionsvepj.clo). It fails before the fix (body swallowed, 0 pages) and passes after.main.tex, svjour/epj): 0 → 57 pages (173k glyph paths).go test ./...green;gofmtclean.🤖 Generated with Claude Code