diff --git a/crates/texrra-tex-core/src/execution/engine.rs b/crates/texrra-tex-core/src/execution/engine.rs index 1209bca..5880235 100644 --- a/crates/texrra-tex-core/src/execution/engine.rs +++ b/crates/texrra-tex-core/src/execution/engine.rs @@ -356,7 +356,6 @@ impl Executor { // Compatibility level for the eight-bit native PDF interface. // This is independent of the Route-D build version. const PDFTEX_VERSION: i32 = 140; - const PDFTEX_REVISION: &str = "22"; pub fn new(state: State, limits: Limits) -> Self { Self { @@ -999,7 +998,7 @@ impl Executor { self.print_tokens(&format!("{digest:X}"), token)?; } } - Pdftexrevision => self.print_tokens(Self::PDFTEX_REVISION, token)?, + Pdftexrevision => self.print_tokens(self.state.pdftex_revision(), token)?, Etexrevision => self.print_tokens(".6", token)?, Csname => { let name = self.csname(files)?; diff --git a/crates/texrra-tex-core/src/execution/format_image.rs b/crates/texrra-tex-core/src/execution/format_image.rs index ffb44e5..7e7b61a 100644 --- a/crates/texrra-tex-core/src/execution/format_image.rs +++ b/crates/texrra-tex-core/src/execution/format_image.rs @@ -8,9 +8,9 @@ use std::{ sync::{Arc, Mutex, OnceLock, Weak}, }; -const SCHEMA: u32 = 50; -const COMPATIBLE_SCHEMAS: [u32; 19] = [ - 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 44, 45, 46, 47, 48, 49, SCHEMA, +const SCHEMA: u32 = 51; +const COMPATIBLE_SCHEMAS: [u32; 20] = [ + 27, 28, 31, 32, 33, 34, 35, 36, 37, 38, 39, 43, 44, 45, 46, 47, 48, 49, 50, SCHEMA, ]; const ENGINE: &str = concat!("texrra-native/", env!("CARGO_PKG_VERSION")); diff --git a/crates/texrra-tex-core/src/execution/state.rs b/crates/texrra-tex-core/src/execution/state.rs index fe22fad..198d48c 100644 --- a/crates/texrra-tex-core/src/execution/state.rs +++ b/crates/texrra-tex-core/src/execution/state.rs @@ -603,6 +603,16 @@ mod ordered_map { } } +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] +enum PdftexRevision { + // A format created before revision identity was stored bootstrapped with 22. + #[default] + #[serde(rename = "22")] + R22, + #[serde(rename = "24")] + R24, +} + #[derive(Clone, Debug, PartialEq, Eq, Hash, serde::Serialize, serde::Deserialize)] pub struct State { #[serde(with = "ordered_map")] @@ -613,6 +623,8 @@ pub struct State { #[serde(with = "ordered_map")] pub(super) token_parameters: BTreeMap>, profile: Profile, + #[serde(default)] + pdftex_revision: PdftexRevision, initex: bool, #[serde(default)] input_profile: super::InputProfile, @@ -734,6 +746,7 @@ impl Default for State { toks: BTreeMap::new(), token_parameters: BTreeMap::new(), profile: Profile::Bootstrap, + pdftex_revision: PdftexRevision::R24, initex: false, input_profile: super::InputProfile::default(), endlinechar: 13, @@ -1389,6 +1402,12 @@ impl State { pub fn profile(&self) -> Profile { self.profile } + pub(super) fn pdftex_revision(&self) -> &'static str { + match self.pdftex_revision { + PdftexRevision::R22 => "22", + PdftexRevision::R24 => "24", + } + } pub fn tokens(&self, index: u16) -> Vec { self.toks.get(&index).cloned().unwrap_or_default() } diff --git a/crates/texrra-tex-core/tests/execution_format_image.rs b/crates/texrra-tex-core/tests/execution_format_image.rs index 3465530..2e5d156 100644 --- a/crates/texrra-tex-core/tests/execution_format_image.rs +++ b/crates/texrra-tex-core/tests/execution_format_image.rs @@ -21,12 +21,14 @@ fn source(name: &str, text: &str) -> SourceFile { #[test] fn legal_dump_loads_owned_format_state_into_a_new_job() { + let seed = SEED.replace(r"\dump", r"\edef\frozenrevision{\pdftexrevision}\dump"); let time = JobTime::new(2026, 1, 2, 123).unwrap(); let state = State::initex() .with_etex() + .with_input_profile(InputProfile::TeX8Bit) .with_job_time(JobTime::new(2025, 2, 3, 21).unwrap()); let dump = Executor::new(state.clone(), Limits::default()) - .run(source("seed.tex", SEED), &mut Host) + .run(source("seed.tex", &seed), &mut Host) .unwrap(); let format = FormatImage::from_dump(dump, Vec::new(), Vec::new()) .unwrap() @@ -42,10 +44,13 @@ fn legal_dump_loads_owned_format_state_into_a_new_job() { ) }; assert!(load(b"changed").is_err()); - let job = load(SEED.as_bytes()) + let job = load(seed.as_bytes()) .unwrap() .run( - source("document.tex", r"\message{\frozen-\the\count0}\end"), + source( + "document.tex", + r"\message{\frozen-\the\count0}\message{REV=\frozenrevision/\pdftexrevision}\end", + ), &mut Host, ) .unwrap(); @@ -57,7 +62,7 @@ fn legal_dump_loads_owned_format_state_into_a_new_job() { _ => None, }) .collect(); - assert_eq!(messages, ["HOOK=123", "READY-42"]); + assert_eq!(messages, ["HOOK=123", "READY-42", "REV=24/24"]); assert!(!job.state.is_initex()); assert!(!job.format_dumped); let mut corrupt = format.clone(); @@ -69,7 +74,7 @@ fn legal_dump_loads_owned_format_state_into_a_new_job() { .run(source("bad.tex", r"\begingroup\dump"), &mut Host) .unwrap_err(); assert!(grouped.message.contains("closed groups")); - let ordinary = load(SEED.as_bytes()) + let ordinary = load(seed.as_bytes()) .unwrap() .run(source("bad.tex", r"\dump"), &mut Host) .unwrap_err();