From 3ed2c2cd54f961a300ff3951d48d26b809ed71e1 Mon Sep 17 00:00:00 2001 From: GloamXun Date: Sat, 21 Nov 2026 06:03:17 +0800 Subject: [PATCH] Print DVI dictionary warnings on their own TeX lines --- .../src/execution/engine/pdf_catalog.rs | 5 +- docs/P2_M1_PROGRESS.md | 13 +++- tests/native_pdf_config.rs | 59 +++++++++++++++++++ 3 files changed, 75 insertions(+), 2 deletions(-) diff --git a/crates/texrra-tex-core/src/execution/engine/pdf_catalog.rs b/crates/texrra-tex-core/src/execution/engine/pdf_catalog.rs index 539373c..595a5b6 100644 --- a/crates/texrra-tex-core/src/execution/engine/pdf_catalog.rs +++ b/crates/texrra-tex-core/src/execution/engine/pdf_catalog.rs @@ -156,8 +156,11 @@ impl Executor { let text = format!( "pdfTeX warning (\\{command}): not allowed in DVI mode (\\pdfoutput <= 0); ignoring it" ); + let destination = WriteDestination::TerminalAndLog; files - .observe_message(&text) + .observe_raw_diagnostic(destination, "\n") + .and_then(|_| files.observe_inline_diagnostic(destination, &text)) + .and_then(|_| files.observe_raw_diagnostic(destination, "\n")) .map_err(|error| self.error(error, self.current))?; self.events.push(Event::Message { text, diff --git a/docs/P2_M1_PROGRESS.md b/docs/P2_M1_PROGRESS.md index 2887d5e..7998633 100644 --- a/docs/P2_M1_PROGRESS.md +++ b/docs/P2_M1_PROGRESS.md @@ -1509,7 +1509,7 @@ LaTeX 后端结构目的地分支。 以选择实际悬挂字符。空断字标记保留在右侧悬挂字偶之后。 三份 pdfTeX INITEX 对照的原始列表、词框和 144 dpi 栅格完全一致。 -覆盖正负取值、字体隔离、组内开关、数值扫描、`\lastkern`、连字、 +17项定向回归通过。覆盖正负取值、字体隔离、组内开关、数值扫描、`\lastkern`、连字、 显式与自动断字及段落两侧悬挂。自动断字按上游在现有自动字偶处分段 搜索。第一版的空断字标记顺序差异及原样失败保留在 target/p2-autokern-native。schema50 重载了含真实自动字偶的盒, @@ -1524,6 +1524,17 @@ df4a0061c782c22ce469d99e5aa8cafd8febe7226185e1861b42ff05f4c57e38, 616875262bf2aeb58823cd9389a9b10a4097b9576f9867e0ff56a7edd9c7efd7。 [TeX Live pdfTeX 实现](https://github.com/TeX-Live/texlive-source/blob/trunk/texk/web2c/pdftexdir/pdftex.web) +### DVI 模式的 PDF 字典警告 + +`\pdfinfo` 与 `\pdfcatalog` 被 DVI 模式忽略时,诊断遵循 pdfTeX 的 +check_pdfoutput。警告前后换行,警告正文按79列输出,保留警告与 +`\message`、`\write`16 的实际先后顺序。普通消息的输出行为和已保留的 +事件正文继续使用原有路径。5项 PDF 配置回归通过;原探针在终端和 +日志里的警告区间都与参考逐字节一致。证据在 +target/p2-pdf-warning-lines-native,回执 SHA-256 +c9f4f3f6cbe8f8bdfedaae35ed85bda92850773b2ef0e0f4e1d14c271d264598。 +[TeX Live pdfTeX 实现](https://github.com/TeX-Live/texlive-source/blob/trunk/texk/web2c/pdftexdir/pdftex.web) + ### PDF 字面中的矩阵与来源映射 来源映射与 PDF 写入共用设备原点的取整。实际字面中的 `q`、`Q` 和 diff --git a/tests/native_pdf_config.rs b/tests/native_pdf_config.rs index ec48fb5..45a7440 100644 --- a/tests/native_pdf_config.rs +++ b/tests/native_pdf_config.rs @@ -276,3 +276,62 @@ fn byte_pdf_profile_uses_real_absolute_comparisons_and_device_options() { } fs::remove_dir_all(dir).unwrap(); } + +#[test] +fn dvi_dictionary_warnings_keep_their_own_wrapped_lines() { + let root = directory(); + let oracle = directory(); + let source = r"\catcode123=1 \catcode125=2 +\pdfoutput=0 +\message{BEFORE-INFO} +\pdfinfo{/Title (ignored)} +\immediate\write16{AFTER-INFO} +\pdfcatalog{/Lang (en)} +\message{AFTER-CATALOG} +\end"; + for path in [&root, &oracle] { + fs::write(path.join("probe.tex"), source).unwrap(); + } + let actual = native_fonts::command() + .current_dir(&root) + .env("TEXRRA_STATE_DIR", root.join("state")) + .args([ + "native", + "--job", + "--initex", + "--etex", + "probe.tex", + "native.pdf", + ]) + .output() + .unwrap(); + let expected = Command::new("pdftex") + .current_dir(&oracle) + .args([ + "-ini", + "-etex", + "-interaction=nonstopmode", + "-halt-on-error", + "probe.tex", + ]) + .output() + .unwrap(); + assert!(actual.status.success(), "{actual:?}"); + assert!(expected.status.success(), "{expected:?}"); + let between_messages = |bytes: &[u8]| { + let text = std::str::from_utf8(bytes).unwrap(); + let start = text.find("BEFORE-INFO").unwrap(); + let end = text.find("AFTER-CATALOG").unwrap(); + text[start..end].to_owned() + }; + assert_eq!( + between_messages(&actual.stderr), + between_messages(&expected.stdout) + ); + assert_eq!( + between_messages(&fs::read(root.join("native.log")).unwrap()), + between_messages(&fs::read(oracle.join("probe.log")).unwrap()) + ); + fs::remove_dir_all(root).unwrap(); + fs::remove_dir_all(oracle).unwrap(); +}