Enable the portable PDF matching primitives in Windows builds

This commit is contained in:
gloamxun committed 2026-12-02 19:06:53 +08:00
1 parent 2b91828b45
commit cd891494e9
9 files changed
+6 -28

No files matched your search

+1 -10
View File
@@ -36,7 +36,6 @@ mod pdf_image;
mod pdf_form;
mod pdf_objects;
mod pdf_links;
#[cfg(all(target_os = "linux", target_env = "gnu"))]
pub(super) mod pdf_match;
mod quantities;
mod restores;
@@ -278,7 +277,6 @@ pub struct Executor {
pdf_loaded_space_font: Option<Arc<crate::native_font::NativeFont>>,
pdf_space_probe: Option<Arc<page::PdfSpaceProbe>>,
pdf_virtual_fonts: Arc<crate::native_font::JobVirtualFonts>,
#[cfg(all(target_os = "linux", target_env = "gnu"))]
pdf_last_match: Option<Arc<pdf_match::PdfMatch>>,
pdf_catalog_tokens: Vec<Token>,
pdf_outlines: Vec<crate::pdf_device::catalog::PdfOutline<Vec<Token>>>,
@@ -653,7 +651,6 @@ impl Executor {
pdf_loaded_space_font: None,
pdf_space_probe: None,
pdf_virtual_fonts: Default::default(),
#[cfg(all(target_os = "linux", target_env = "gnu"))]
pdf_last_match: None,
pdf_catalog_tokens: Vec::new(),
pdf_outlines: Vec::new(),
@@ -1367,13 +1364,7 @@ impl Executor {
};
self.print_tokens(result, token)?;
}
Pdfmatch | Pdflastmatch => {
#[cfg(all(target_os = "linux", target_env = "gnu"))]
self.expand_pdf_match(primitive, token, files)?;
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
return self
.fail("pdfTeX regular expressions are unavailable on this host");
}
Pdfmatch | Pdflastmatch => self.expand_pdf_match(primitive, token, files)?,
Pdfuniformdeviate => {
let bound = self.integer(files)?;
self.reads.insert(Dependency::PdfRandomState);
@@ -836,7 +836,6 @@ fn same_kernel_continuation(
$($value,)+
$($planned: _,)+
$($runtime: _,)+
#[cfg(all(target_os = "linux", target_env = "gnu"))]
pdf_last_match: _,
} = current;
true $(&& *$value == prior.$value)+
@@ -927,7 +926,6 @@ fn same_kernel_continuation(
) {
return false;
}
#[cfg(all(target_os = "linux", target_env = "gnu"))]
if current.pdf_last_match.as_deref() != prior.pdf_last_match.as_deref() {
return false;
}
@@ -14,7 +14,6 @@ mod direction;
mod dvi;
pub use direction::DirectionBoundary;
mod engine;
#[cfg(all(target_os = "linux", target_env = "gnu"))]
pub use engine::pdf_match::{RegexOutcome, RegexRequest, match_pdf_regex};
mod font_catalog;
mod fonts;
@@ -235,7 +234,6 @@ pub struct GeneratedInput {
/// File lookup belongs to the host. Execution never shells out to TeX or
/// searches a different engine when a file/primitive is absent.
pub trait SourceProvider {
#[cfg(all(target_os = "linux", target_env = "gnu"))]
fn match_pdf_regex(
&mut self,
request: &RegexRequest,
@@ -1756,9 +1756,7 @@ const PDFTEX_ONLY_PRIMITIVES: &[(&str, Primitive)] = {
("pdfcreationdate", Pdfcreationdate),
("pdfshellescape", Pdfshellescape),
("pdfstrcmp", Pdfstrcmp),
#[cfg(all(target_os = "linux", target_env = "gnu"))]
("pdfmatch", Pdfmatch),
#[cfg(all(target_os = "linux", target_env = "gnu"))]
("pdflastmatch", Pdflastmatch),
("pdfcolorstackinit", Pdfcolorstackinit),
("pdfobj", Pdfobj),
@@ -1,8 +1,8 @@
#![cfg(all(target_os = "linux", target_env = "gnu"))]
#[cfg(all(target_os = "linux", target_env = "gnu"))]
use std::{fs, process::Command};
use texrra_tex_core::execution::*;
#[cfg(all(target_os = "linux", target_env = "gnu"))]
const SOURCE: &str = r#"
\catcode123=1 \catcode125=2 \catcode35=6 \catcode94=7
\def\probe#1{\message{!pdfmatch:#1:end!}}
@@ -42,6 +42,7 @@ fn file(source: &str) -> SourceFile {
}
}
#[cfg(all(target_os = "linux", target_env = "gnu"))]
#[test]
fn pdf_regex_matches_reference_bytes_and_retains_job_local_captures() {
let dir = std::env::temp_dir().join(format!("texrra-pdfmatch-{}", std::process::id()));
-1
View File
@@ -9,7 +9,6 @@ mod native_generated;
mod native_host;
mod native_job;
mod native_preview;
#[cfg(all(target_os = "linux", target_env = "gnu"))]
mod native_regex;
mod native_stream;
pub mod rust_typeset;
+1 -4
View File
@@ -84,10 +84,7 @@ pub struct CompileRequest {
/// internal worker invocation. Call before parsing application arguments, and
/// exit with the returned status when the invocation was handled.
pub fn dispatch_pdf_regex_worker() -> Option<i32> {
#[cfg(all(target_os = "linux", target_env = "gnu"))]
return crate::native_regex::dispatch();
#[cfg(not(all(target_os = "linux", target_env = "gnu")))]
None
crate::native_regex::dispatch()
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
+1 -2
View File
@@ -331,13 +331,12 @@ macro_rules! call {
}
impl SourceProvider for RecordingHost<'_> {
#[cfg(all(target_os = "linux", target_env = "gnu"))]
fn match_pdf_regex(
&mut self,
request: &texrra_tex_core::execution::RegexRequest,
cancellation: Option<&Cancellation>,
) -> Result<texrra_tex_core::execution::RegexOutcome, String> {
// GNU matching consumes only kernel-supplied bytes and is pinned to
// Matching consumes only kernel-supplied bytes and is pinned to
// this executable on registered frontends. Its result is kernel state.
self.files.match_pdf_regex(request, cancellation)
}
-3
View File
@@ -223,7 +223,6 @@ struct ReplayState {
pub struct Files {
world: FileWorld,
#[cfg(all(target_os = "linux", target_env = "gnu"))]
regex_worker: Option<crate::native_regex::Worker>,
cwd: PathBuf,
inputs: BTreeMap<u8, Input>,
@@ -627,7 +626,6 @@ impl Files {
preparation.phase = HostPreparationPhase::Ready;
Ok(Self {
world: stored_world.take().unwrap(),
#[cfg(all(target_os = "linux", target_env = "gnu"))]
regex_worker: None,
cwd,
inputs: BTreeMap::new(),
@@ -1667,7 +1665,6 @@ impl Files {
}
impl SourceProvider for Files {
#[cfg(all(target_os = "linux", target_env = "gnu"))]
fn match_pdf_regex(
&mut self,
request: &texrra_tex_core::execution::RegexRequest,