From 39bc46611bec7d4d267ee4c467d87681604b3408 Mon Sep 17 00:00:00 2001 From: ralismark Date: Sat, 3 Oct 2020 14:27:25 +1000 Subject: [PATCH 01/17] Add -Z unstable option support --- src/bin/tectonic.rs | 11 +++++++++ src/driver.rs | 11 +++++++++ src/lib.rs | 1 + src/unstable_opts.rs | 58 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 src/unstable_opts.rs diff --git a/src/bin/tectonic.rs b/src/bin/tectonic.rs index fc301b143..dee3c038d 100644 --- a/src/bin/tectonic.rs +++ b/src/bin/tectonic.rs @@ -16,6 +16,7 @@ use tectonic::errors::{ErrorKind, Result}; use tectonic::status::plain::PlainStatusBackend; use tectonic::status::termcolor::TermcolorStatusBackend; use tectonic::status::{ChatterLevel, StatusBackend}; +use tectonic::unstable_opts::UnstableOptions; use tectonic::{errmsg, tt_error, tt_note}; #[derive(Debug, StructOpt)] @@ -73,11 +74,21 @@ struct CliOptions { /// The directory in which to place output files [default: the directory containing ] #[structopt(name = "outdir", short, long, parse(from_os_str))] outdir: Option, + /// Unstable options + #[structopt( + name = "options", + short = "Z", + number_of_values = 1, + empty_values = false + )] + unstable: Vec, } fn inner(args: CliOptions, config: PersistentConfig, status: &mut dyn StatusBackend) -> Result<()> { + let unstable = UnstableOptions::from_strings(args.unstable.iter().map(String::as_str))?; let mut sess_builder = ProcessingSessionBuilder::default(); let format_path = args.format; sess_builder + .unstables(unstable) .format_name(&format_path) .keep_logs(args.keep_logs) .keep_intermediates(args.keep_intermediates) diff --git a/src/driver.rs b/src/driver.rs index 0f53bf3ec..8b5471d6d 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -26,6 +26,7 @@ use crate::engines::IoEventBackend; use crate::errors::{ErrorKind, Result, ResultExt}; use crate::io::{Bundle, InputOrigin, IoProvider, IoSetup, IoSetupBuilder, OpenResult}; use crate::status::StatusBackend; +use crate::unstable_opts::UnstableOptions; use crate::{ctry, errmsg, tt_error, tt_note, tt_warning}; use crate::{BibtexEngine, Spx2HtmlEngine, TexEngine, TexResult, XdvipdfmxEngine}; use std::result::Result as StdResult; @@ -326,6 +327,7 @@ pub struct ProcessingSessionBuilder { keep_logs: bool, synctex: bool, build_date: Option, + unstables: UnstableOptions, } impl ProcessingSessionBuilder { @@ -471,6 +473,12 @@ impl ProcessingSessionBuilder { self } + /// Loads unstable options into the processing session + pub fn unstables(&mut self, opts: UnstableOptions) -> &mut Self { + self.unstables = opts; + self + } + /// Creates a `ProcessingSession`. pub fn create(self, status: &mut dyn StatusBackend) -> Result { let mut io = IoSetupBuilder::default(); @@ -558,6 +566,7 @@ impl ProcessingSessionBuilder { keep_logs: self.keep_logs, synctex_enabled: self.synctex, build_date: self.build_date.unwrap_or(SystemTime::UNIX_EPOCH), + unstables: self.unstables, }) } } @@ -622,6 +631,8 @@ pub struct ProcessingSession { /// See `TexEngine::with_date` and `XdvipdfmxEngine::with_date`. build_date: SystemTime, + + unstables: UnstableOptions, } const DEFAULT_MAX_TEX_PASSES: usize = 6; diff --git a/src/lib.rs b/src/lib.rs index 5954d43e2..9aa809c64 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -56,6 +56,7 @@ pub mod engines; pub mod errors; pub mod io; pub mod status; +pub mod unstable_opts; // Note: this module is intentionally *not* gated by #[cfg(test)] -- see its // docstring for details. diff --git a/src/unstable_opts.rs b/src/unstable_opts.rs new file mode 100644 index 000000000..71122daf4 --- /dev/null +++ b/src/unstable_opts.rs @@ -0,0 +1,58 @@ +// src/bin/tectonic.rs -- Command-line driver for the Tectonic engine. +// Copyright 2020 the Tectonic Project +// Licensed under the MIT License. + +//! Unstable options for the Tectonic engine. +//! +//! This is similar to the -Z options on rustc - they're unstable options that are not guaranteed +//! to be reliable or very polished. In particular, many of these prevent the build from being +//! reproducible. + +use crate::errors::Result; +use std::default::Default; + +#[derive(Debug)] +pub struct UnstableOptions { + /// The output paper size to use, instead of "letter" + pub paper_size: Option, + /// Whether to enable shell escape + pub shell_escape: bool, +} + +impl Default for UnstableOptions { + fn default() -> Self { + Self { + paper_size: None, + shell_escape: false, + } + } +} + +impl UnstableOptions { + pub fn parse_single(&mut self, opt: &str) -> Result<()> { + let mut splitted = opt.splitn(2, '='); + let name = splitted.next().unwrap(); + let arg = splitted.next().ok_or("option requres an argument"); + + match name { + "paper-size" => self.paper_size = Some(arg?.to_string()), + "shell-escape" => self.shell_escape = true, + "no-shell-escape" => self.shell_escape = false, + _ => return Err("invalid option".into()), + } + + Ok(()) + } + + pub fn from_strings<'a, I>(options: I) -> Result + where + I: Iterator, + { + let mut config = Self::default(); + for arg in options { + config.parse_single(arg)?; + } + + Ok(config) + } +} From 894951d315cc5faeffad3c0d7df2b2e3d79f8acf Mon Sep 17 00:00:00 2001 From: ralismark Date: Thu, 8 Oct 2020 21:26:39 +1100 Subject: [PATCH 02/17] Pass unstable options to engines --- src/driver.rs | 12 +++++++++++- src/engines/bibtex.rs | 2 ++ src/engines/tex.rs | 2 ++ src/engines/xdvipdfmx.rs | 2 ++ tests/bibtex.rs | 9 ++++++++- tests/formats.rs | 2 ++ tests/tex-outputs.rs | 20 +++++++++++++++++--- tests/trip.rs | 5 +++++ tests/util/mod.rs | 2 ++ 9 files changed, 51 insertions(+), 5 deletions(-) diff --git a/src/driver.rs b/src/driver.rs index 8b5471d6d..4e7c45598 100644 --- a/src/driver.rs +++ b/src/driver.rs @@ -1051,7 +1051,14 @@ impl ProcessingSession { TexEngine::new() .halt_on_error_mode(true) .initex_mode(true) - .process(&mut stack, &mut self.events, status, "UNUSED.fmt", "texput") + .process( + &mut stack, + &mut self.events, + status, + "UNUSED.fmt", + "texput", + &self.unstables, + ) }; match result { @@ -1121,6 +1128,7 @@ impl ProcessingSession { status, &self.format_name, &self.primary_input_tex_path, + &self.unstables, ) }; @@ -1148,6 +1156,7 @@ impl ProcessingSession { &mut self.events, status, &self.tex_aux_path.to_str().unwrap(), + &self.unstables, ) }; @@ -1185,6 +1194,7 @@ impl ProcessingSession { status, &self.tex_xdv_path.to_str().unwrap(), &self.tex_pdf_path.to_str().unwrap(), + &self.unstables, )?; } diff --git a/src/engines/bibtex.rs b/src/engines/bibtex.rs index 32cc64b8f..43821f7a5 100644 --- a/src/engines/bibtex.rs +++ b/src/engines/bibtex.rs @@ -9,6 +9,7 @@ use super::{ExecutionState, IoEventBackend, TectonicBridgeApi}; use crate::errors::{ErrorKind, Result}; use crate::io::IoStack; use crate::status::StatusBackend; +use crate::unstable_opts::UnstableOptions; #[derive(Default)] pub struct BibtexEngine {} @@ -24,6 +25,7 @@ impl BibtexEngine { events: &mut dyn IoEventBackend, status: &mut dyn StatusBackend, aux: &str, + unstables: &UnstableOptions, ) -> Result { let _guard = super::ENGINE_LOCK.lock().unwrap(); // until we're thread-safe ... diff --git a/src/engines/tex.rs b/src/engines/tex.rs index f55d896e9..9efc2b1da 100644 --- a/src/engines/tex.rs +++ b/src/engines/tex.rs @@ -9,6 +9,7 @@ use super::{ExecutionState, IoEventBackend, TectonicBridgeApi}; use crate::errors::{DefinitelySame, ErrorKind, Result}; use crate::io::IoStack; use crate::status::StatusBackend; +use crate::unstable_opts::UnstableOptions; #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum TexResult { @@ -109,6 +110,7 @@ impl TexEngine { status: &mut dyn StatusBackend, format_file_name: &str, input_file_name: &str, + unstables: &UnstableOptions, ) -> Result { let _guard = super::ENGINE_LOCK.lock().unwrap(); // until we're thread-safe ... diff --git a/src/engines/xdvipdfmx.rs b/src/engines/xdvipdfmx.rs index 45ab2a686..6f2ecbdd1 100644 --- a/src/engines/xdvipdfmx.rs +++ b/src/engines/xdvipdfmx.rs @@ -9,6 +9,7 @@ use super::{ExecutionState, IoEventBackend, TectonicBridgeApi}; use crate::errors::{ErrorKind, Result}; use crate::io::IoStack; use crate::status::StatusBackend; +use crate::unstable_opts::UnstableOptions; pub struct XdvipdfmxEngine { enable_compression: bool, @@ -51,6 +52,7 @@ impl XdvipdfmxEngine { status: &mut dyn StatusBackend, dvi: &str, pdf: &str, + unstables: &UnstableOptions, ) -> Result { let _guard = super::ENGINE_LOCK.lock().unwrap(); // until we're thread-safe ... diff --git a/tests/bibtex.rs b/tests/bibtex.rs index 7901763ee..1d3b8bd10 100644 --- a/tests/bibtex.rs +++ b/tests/bibtex.rs @@ -2,6 +2,7 @@ // Licensed under the MIT License. use std::collections::HashSet; +use std::default::Default; use tectonic::engines::NoopIoEventBackend; use tectonic::io::stdstreams::GenuineStdoutIo; @@ -49,7 +50,13 @@ impl TestCase { let mut status = NoopStatusBackend::new(); BibtexEngine::new() - .process(&mut io, &mut events, &mut status, &auxname) + .process( + &mut io, + &mut events, + &mut status, + &auxname, + &Default::default(), + ) .unwrap(); // Check that outputs match expectations. diff --git a/tests/formats.rs b/tests/formats.rs index 4f90fc9b6..87ed6161e 100644 --- a/tests/formats.rs +++ b/tests/formats.rs @@ -15,6 +15,7 @@ /// to disk, which may be helpful in debugging. There is probably a less gross /// way to implement that option. use std::collections::{HashMap, HashSet}; +use std::default::Default; use std::ffi::{OsStr, OsString}; use std::str::FromStr; @@ -103,6 +104,7 @@ fn test_format_generation(texname: &str, fmtname: &str, sha256: &str) { &mut NoopStatusBackend::new(), "unused.fmt", texname, + &Default::default(), ) .unwrap(); } diff --git a/tests/tex-outputs.rs b/tests/tex-outputs.rs index 3e9aea35b..a585a72db 100644 --- a/tests/tex-outputs.rs +++ b/tests/tex-outputs.rs @@ -2,6 +2,7 @@ // Licensed under the MIT License. use std::collections::HashSet; +use std::default::Default; use std::path::Path; use std::time; @@ -112,8 +113,14 @@ impl TestCase { let mut events = NoopIoEventBackend::new(); let mut status = NoopStatusBackend::new(); - let tex_res = - TexEngine::new().process(&mut io, &mut events, &mut status, "plain.fmt", &texname); + let tex_res = TexEngine::new().process( + &mut io, + &mut events, + &mut status, + "plain.fmt", + &texname, + &Default::default(), + ); if self.check_pdf && tex_res.definitely_same(&Ok(TexResult::Spotless)) { XdvipdfmxEngine::new() @@ -124,7 +131,14 @@ impl TestCase { .checked_add(time::Duration::from_secs(1_456_304_492)) .unwrap(), ) - .process(&mut io, &mut events, &mut status, &xdvname, &pdfname) + .process( + &mut io, + &mut events, + &mut status, + &xdvname, + &pdfname, + &Default::default(), + ) .unwrap(); } diff --git a/tests/trip.rs b/tests/trip.rs index ca06e883d..dff4123d0 100644 --- a/tests/trip.rs +++ b/tests/trip.rs @@ -2,6 +2,7 @@ // Copyright 2016-2018 the Tectonic Project // Licensed under the MIT License. +use std::default::Default; /// Our incarnation of the classic TRIP test. Unfortunately, the test is /// defined in terms of the precise terminal output and error handling behavior /// of the engine, so you can't do anything to improve the (incredibly poor) UX @@ -62,6 +63,7 @@ fn trip_test() { &mut NoopStatusBackend::new(), "INITEX", "trip", + &Default::default(), ) .unwrap(); } @@ -78,6 +80,7 @@ fn trip_test() { &mut NoopStatusBackend::new(), "trip.fmt", "trip", + &Default::default(), ) .unwrap(); } @@ -127,6 +130,7 @@ fn etrip_test() { &mut NoopStatusBackend::new(), "INITEX", "etrip", + &Default::default(), ) .unwrap(); } @@ -143,6 +147,7 @@ fn etrip_test() { &mut NoopStatusBackend::new(), "etrip.fmt", "etrip", + &Default::default(), ) .unwrap(); } diff --git a/tests/util/mod.rs b/tests/util/mod.rs index 6974e5f2c..b737bf07d 100644 --- a/tests/util/mod.rs +++ b/tests/util/mod.rs @@ -13,6 +13,7 @@ use ::flate2::read::GzDecoder; use std::collections::{HashMap, HashSet}; +use std::default::Default; use std::env; use std::ffi::{OsStr, OsString}; use std::fs::File; @@ -85,6 +86,7 @@ pub fn ensure_plain_format() -> Result { &mut NoopStatusBackend::new(), "UNUSED.fmt", "plain.tex", + &Default::default(), )?; } From 34a6721acf01315b0bc517086378953be5ba475b Mon Sep 17 00:00:00 2001 From: ralismark Date: Sat, 10 Oct 2020 21:12:28 +1100 Subject: [PATCH 03/17] Parse -Z better --- src/bin/tectonic.rs | 17 ++++----- src/unstable_opts.rs | 91 ++++++++++++++++++++++++++++---------------- 2 files changed, 66 insertions(+), 42 deletions(-) diff --git a/src/bin/tectonic.rs b/src/bin/tectonic.rs index dee3c038d..927764264 100644 --- a/src/bin/tectonic.rs +++ b/src/bin/tectonic.rs @@ -16,7 +16,7 @@ use tectonic::errors::{ErrorKind, Result}; use tectonic::status::plain::PlainStatusBackend; use tectonic::status::termcolor::TermcolorStatusBackend; use tectonic::status::{ChatterLevel, StatusBackend}; -use tectonic::unstable_opts::UnstableOptions; +use tectonic::unstable_opts::{UnstableArg, UnstableOptions}; use tectonic::{errmsg, tt_error, tt_note}; #[derive(Debug, StructOpt)] @@ -74,17 +74,14 @@ struct CliOptions { /// The directory in which to place output files [default: the directory containing ] #[structopt(name = "outdir", short, long, parse(from_os_str))] outdir: Option, - /// Unstable options - #[structopt( - name = "options", - short = "Z", - number_of_values = 1, - empty_values = false - )] - unstable: Vec, + /// Unstable options. Pass -Zhelp to show a list + // TODO we can't pass -Zhelp without also passing + #[structopt(name = "option", short = "Z", number_of_values = 1)] + unstable: Vec, } fn inner(args: CliOptions, config: PersistentConfig, status: &mut dyn StatusBackend) -> Result<()> { - let unstable = UnstableOptions::from_strings(args.unstable.iter().map(String::as_str))?; + let unstable = UnstableOptions::from_unstable_args(args.unstable.into_iter()); + let mut sess_builder = ProcessingSessionBuilder::default(); let format_path = args.format; sess_builder diff --git a/src/unstable_opts.rs b/src/unstable_opts.rs index 71122daf4..53fa9055b 100644 --- a/src/unstable_opts.rs +++ b/src/unstable_opts.rs @@ -8,51 +8,78 @@ //! to be reliable or very polished. In particular, many of these prevent the build from being //! reproducible. -use crate::errors::Result; +use crate::errors::{Error, Result}; use std::default::Default; +use std::str::FromStr; +const HELPMSG: &str = r#"Available unstable options: + + -Z help Lists all unstable options + -Z paper-size= Change the default paper size [default: letter] + -Z shell-escape Enable \write18 +"#; + +// Each entry of this should correspond to a field of UnstableOptions. #[derive(Debug)] -pub struct UnstableOptions { - /// The output paper size to use, instead of "letter" - pub paper_size: Option, - /// Whether to enable shell escape - pub shell_escape: bool, +pub enum UnstableArg { + Help, + PaperSize(String), + ShellEscapeEnabled, } -impl Default for UnstableOptions { - fn default() -> Self { - Self { - paper_size: None, - shell_escape: false, +impl FromStr for UnstableArg { + type Err = Error; + + /// Parse from the argument to -Z + fn from_str(s: &str) -> Result { + let mut splitter = s.splitn(2, '='); + let arg = splitter.next().unwrap(); // splitn will always have at least 1 item + let value = splitter.next(); + + // For structopt/clap, if you pass a value to a flag which doesn't accept one, it's + // silently ignored. + + match arg { + "help" => Ok(UnstableArg::Help), + + "paper-size" => value + .ok_or_else(|| { + "'-Z paper-size ' requires a value but none was supplied".into() + }) + .map(|s| UnstableArg::PaperSize(s.to_string())), + + "shell-escape" => Ok(UnstableArg::ShellEscapeEnabled), + + _ => Err(format!("Unknown unstable option '{}'", arg).into()), } } } -impl UnstableOptions { - pub fn parse_single(&mut self, opt: &str) -> Result<()> { - let mut splitted = opt.splitn(2, '='); - let name = splitted.next().unwrap(); - let arg = splitted.next().ok_or("option requres an argument"); - - match name { - "paper-size" => self.paper_size = Some(arg?.to_string()), - "shell-escape" => self.shell_escape = true, - "no-shell-escape" => self.shell_escape = false, - _ => return Err("invalid option".into()), - } - - Ok(()) - } +#[derive(Debug, Default)] +pub struct UnstableOptions { + pub paper_size: Option, + pub shell_escape: bool, +} - pub fn from_strings<'a, I>(options: I) -> Result +impl UnstableOptions { + pub fn from_unstable_args(uargs: I) -> Self where - I: Iterator, + I: Iterator, { - let mut config = Self::default(); - for arg in options { - config.parse_single(arg)?; + let mut opts = UnstableOptions::default(); + + for u in uargs { + use UnstableArg::*; + match u { + Help => { + print!("{}", HELPMSG); + std::process::exit(0); + } + PaperSize(size) => opts.paper_size = Some(size), + ShellEscapeEnabled => opts.shell_escape = true, + } } - Ok(config) + opts } } From c674dbd4a72a95702af5aaa5cc429ae4473521fa Mon Sep 17 00:00:00 2001 From: ralismark Date: Wed, 14 Oct 2020 01:48:35 +1100 Subject: [PATCH 04/17] Parse min-crossrefs --- src/unstable_opts.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/unstable_opts.rs b/src/unstable_opts.rs index 53fa9055b..e2749289c 100644 --- a/src/unstable_opts.rs +++ b/src/unstable_opts.rs @@ -15,6 +15,8 @@ use std::str::FromStr; const HELPMSG: &str = r#"Available unstable options: -Z help Lists all unstable options + -Z min-crossrefs= Equivalent to bibtex's -min-crossrefs flag - "include after + crossrefs" [default: 2] -Z paper-size= Change the default paper size [default: letter] -Z shell-escape Enable \write18 "#; @@ -24,6 +26,7 @@ const HELPMSG: &str = r#"Available unstable options: pub enum UnstableArg { Help, PaperSize(String), + MinCrossrefs(i32), ShellEscapeEnabled, } @@ -42,6 +45,15 @@ impl FromStr for UnstableArg { match arg { "help" => Ok(UnstableArg::Help), + "min-crossrefs" => value + .ok_or_else(|| { + "'-Z min-crossrefs ' requires a value but none was supplied".into() + }) + .and_then(|s| { + FromStr::from_str(s).map_err(|e| format!("-Z min-crossrefs: {}", e).into()) + }) + .map(UnstableArg::MinCrossrefs), + "paper-size" => value .ok_or_else(|| { "'-Z paper-size ' requires a value but none was supplied".into() @@ -59,6 +71,7 @@ impl FromStr for UnstableArg { pub struct UnstableOptions { pub paper_size: Option, pub shell_escape: bool, + pub min_crossrefs: Option, } impl UnstableOptions { @@ -75,6 +88,7 @@ impl UnstableOptions { print!("{}", HELPMSG); std::process::exit(0); } + MinCrossrefs(num) => opts.min_crossrefs = Some(num), PaperSize(size) => opts.paper_size = Some(size), ShellEscapeEnabled => opts.shell_escape = true, } From 2d8cb9d2754fcf21c53d57ea7bdb59be99670382 Mon Sep 17 00:00:00 2001 From: ralismark Date: Wed, 14 Oct 2020 14:29:00 +1100 Subject: [PATCH 05/17] Apply unstable option to min_crossrefs --- src/engines/bibtex.rs | 9 +++++++++ tectonic/bibtex.c | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/engines/bibtex.rs b/src/engines/bibtex.rs index 43821f7a5..c0df816b5 100644 --- a/src/engines/bibtex.rs +++ b/src/engines/bibtex.rs @@ -11,6 +11,11 @@ use crate::io::IoStack; use crate::status::StatusBackend; use crate::unstable_opts::UnstableOptions; +#[no_mangle] +extern "C" { + static mut min_crossrefs: i32; +} + #[derive(Default)] pub struct BibtexEngine {} @@ -34,6 +39,10 @@ impl BibtexEngine { let mut state = ExecutionState::new(io, events, status); let bridge = TectonicBridgeApi::new(&mut state); + if let Some(num) = unstables.min_crossrefs { + unsafe { min_crossrefs = num } + } + unsafe { match super::bibtex_simple_main(&bridge, caux.as_ptr()) { 0 => Ok(TexResult::Spotless), diff --git a/tectonic/bibtex.c b/tectonic/bibtex.c index 7c00b7335..5fc37e6d4 100644 --- a/tectonic/bibtex.c +++ b/tectonic/bibtex.c @@ -416,7 +416,7 @@ static buf_pointer num_text_chars; static unsigned char /*bad_conversion */ conversion_type; static bool prev_colon; static int verbose; -static int32_t min_crossrefs; +int32_t min_crossrefs = MIN_CROSSREFS; /*:473*//*12: *//*3: */ @@ -7302,7 +7302,6 @@ bibtex_main(const char *aux_file_name) max_glob_strs = MAX_GLOB_STRS; max_fields = MAX_FIELDS; max_cites = MAX_CITES; - min_crossrefs = MIN_CROSSREFS; wiz_fn_space = WIZ_FN_SPACE; lit_stk_size = LIT_STK_SIZE; From dffaed61343395bc225bff797eb6ea3b3881dc10 Mon Sep 17 00:00:00 2001 From: ralismark Date: Wed, 14 Oct 2020 14:42:55 +1100 Subject: [PATCH 06/17] Apply unstable option to paperspec --- src/engines/xdvipdfmx.rs | 15 +++++++++++++++ tectonic/dpx-dpxconf.h | 11 +---------- tectonic/dpx-dvipdfmx.c | 16 +++------------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/engines/xdvipdfmx.rs b/src/engines/xdvipdfmx.rs index 6f2ecbdd1..e9a989f6f 100644 --- a/src/engines/xdvipdfmx.rs +++ b/src/engines/xdvipdfmx.rs @@ -11,6 +11,11 @@ use crate::io::IoStack; use crate::status::StatusBackend; use crate::unstable_opts::UnstableOptions; +#[no_mangle] +extern "C" { + static mut paperspec: *const libc::c_char; +} + pub struct XdvipdfmxEngine { enable_compression: bool, deterministic_tags: bool, @@ -56,6 +61,16 @@ impl XdvipdfmxEngine { ) -> Result { let _guard = super::ENGINE_LOCK.lock().unwrap(); // until we're thread-safe ... + let paperspec_str = unstables + .paper_size + .as_ref() + .and_then(|s| CString::new(s.clone()).ok()); + if let Some(cstr) = paperspec_str.as_ref() { + unsafe { + paperspec = cstr.as_ptr(); + } + } + let cdvi = CString::new(dvi)?; let cpdf = CString::new(pdf)?; diff --git a/tectonic/dpx-dpxconf.h b/tectonic/dpx-dpxconf.h index 0151c4c85..3edacd8f1 100644 --- a/tectonic/dpx-dpxconf.h +++ b/tectonic/dpx-dpxconf.h @@ -34,10 +34,6 @@ struct paper { double pswidth, psheight; }; -#ifndef DEFAULT_PAPER_NAME -#define DEFAULT_PAPER_NAME "a4" -#endif - extern const struct paper paperspecs[]; const struct paper *paperinfo (const char *ppformat); @@ -46,14 +42,9 @@ const struct paper *paperinfo (const char *ppformat); #define papername(p) (((p) && (p)->name) ? p->name : NULL) #define paperfirst() &(paperspecs[0]) #define papernext(p) ((((p)+1) && ((p)+1)->name) ? (p+1) : NULL) - -#define defaultpapername() DEFAULT_PAPER_NAME -#define systempapername() DEFAULT_PAPER_NAME - -#define defaultpapersizefile() NULL -#define systempapersizefile() NULL #endif /* HAVE_LIBPAPER */ void dumppaperinfo (void); +extern const char* paperspec; #endif /* _DPXCONF_H_ */ diff --git a/tectonic/dpx-dvipdfmx.c b/tectonic/dpx-dvipdfmx.c index 6a1b6bc9a..a4e42bdcf 100644 --- a/tectonic/dpx-dvipdfmx.c +++ b/tectonic/dpx-dvipdfmx.c @@ -55,6 +55,8 @@ #include "dpx-vf.h" #include "dpx-tt_aux.h" +const char* paperspec = "letter"; + typedef struct page_range { int first; @@ -263,16 +265,6 @@ select_pages ( *ret_num_page_ranges = num_page_ranges; } -static void -system_default (void) -{ - if (systempapername() != NULL) { - select_paper(systempapername()); - } else if (defaultpapername() != NULL) { - select_paper(defaultpapername()); - } -} - #define SWAP(v1,v2) do {\ double _tmp = (v1);\ (v1) = (v2);\ @@ -411,8 +403,6 @@ dvipdfmx_main ( pdf_set_compression(compress ? 9 : 0); pdf_font_set_deterministic_unique_tags(deterministic_tags ? 1 : 0); - system_default(); - pdf_init_fontmaps(); /* This must come before parsing options... */ /* We used to read the config file here. It synthesized command-line @@ -420,7 +410,7 @@ dvipdfmx_main ( * code bits. */ pdf_set_version (5); - select_paper("letter"); + select_paper(paperspec); annot_grow = 0; bookmark_open = 0; key_bits = 40; From 4ce455772b09addb8f4a7d08cbcc609fc68d4aaf Mon Sep 17 00:00:00 2001 From: ralismark Date: Wed, 14 Oct 2020 15:21:36 +1100 Subject: [PATCH 07/17] Almost support shell-escape I haven't implemented the actual "run command" bit yet - they were removed a long time ago. --- src/engines/tex.rs | 5 +++++ tectonic/xetex-engine-interface.c | 2 ++ tectonic/xetex-ini.c | 1 + tectonic/xetex-shipout.c | 16 ++++++++++++++-- tectonic/xetex-xetexd.h | 2 +- 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/engines/tex.rs b/src/engines/tex.rs index 9efc2b1da..d9bc06f3f 100644 --- a/src/engines/tex.rs +++ b/src/engines/tex.rs @@ -121,6 +121,11 @@ impl TexEngine { let bridge = TectonicBridgeApi::new(&mut state); // initialize globals + + let v = if unstables.shell_escape { 1 } else { 0 }; + unsafe { + super::tt_xetex_set_int_variable(b"shell_escape_enabled\0".as_ptr() as _, v); + } let v = if self.halt_on_error { 1 } else { 0 }; unsafe { super::tt_xetex_set_int_variable(b"halt_on_error_p\0".as_ptr() as _, v); diff --git a/tectonic/xetex-engine-interface.c b/tectonic/xetex-engine-interface.c index 2aa23264f..1b1bde2d0 100644 --- a/tectonic/xetex-engine-interface.c +++ b/tectonic/xetex-engine-interface.c @@ -23,6 +23,8 @@ tt_xetex_set_int_variable (const char *var_name, int value) synctex_enabled = (value != 0); else if (streq_ptr(var_name, "semantic_pagination_enabled")) semantic_pagination_enabled = (value != 0); + else if (streq_ptr(var_name, "shell_escape_enabled")) + shell_escape_enabled = (value != 0); else return 1; /* Uh oh: unrecognized variable */ diff --git a/tectonic/xetex-ini.c b/tectonic/xetex-ini.c index ca3484396..0bff9bdc7 100644 --- a/tectonic/xetex-ini.c +++ b/tectonic/xetex-ini.c @@ -9,6 +9,7 @@ #include "dpx-pdfobj.h" /* pdf_files_{init,close} */ /* All the following variables are declared in xetex-xetexd.h */ +bool shell_escape_enabled = false; memory_word *eqtb; int32_t bad; char *name_of_file; diff --git a/tectonic/xetex-shipout.c b/tectonic/xetex-shipout.c index 76bad8e59..7f115fe26 100644 --- a/tectonic/xetex-shipout.c +++ b/tectonic/xetex-shipout.c @@ -2174,15 +2174,27 @@ write_out(int32_t p) if (!log_opened) selector = SELECTOR_TERM_ONLY; + // Existing warning for shell-escape + diagnostic_begin_capture_warning_here(); + print_nl_cstr("runsystem("); for (d = 0; d <= (cur_length()) - 1; d++) print(str_pool[str_start[str_ptr - TOO_BIG_CHAR] + d]); print_cstr(")..."); - print_cstr("disabled"); - print_char('.'); + if (!shell_escape_enabled) { + print_cstr("disabled"); + print_char('.'); + } else { + print_cstr("enabled but not implemented yet!"); + } + + capture_to_diagnostic(NULL); + print_nl_cstr(""); print_ln(); + + // Clear shell escape command pool_ptr = str_start[str_ptr - TOO_BIG_CHAR]; } diff --git a/tectonic/xetex-xetexd.h b/tectonic/xetex-xetexd.h index af14c2ec7..c05ef8599 100644 --- a/tectonic/xetex-xetexd.h +++ b/tectonic/xetex-xetexd.h @@ -356,8 +356,8 @@ void remember_source_info(str_number, int); /* variables! */ /* All the following variables are defined in xetexini.c */ +extern bool shell_escape_enabled; extern memory_word *eqtb; - extern int32_t bad; extern char *name_of_file; extern UTF16_code *name_of_file16; From bbfa43b08dc7ecfbd12f86459e94545d27d69fe4 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2020 07:14:07 +0000 Subject: [PATCH 08/17] build(deps): bump serde from 1.0.116 to 1.0.117 Bumps [serde](https://github.com/serde-rs/serde) from 1.0.116 to 1.0.117. - [Release notes](https://github.com/serde-rs/serde/releases) - [Commits](https://github.com/serde-rs/serde/compare/v1.0.116...v1.0.117) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2341f10b..af4002c31 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1509,18 +1509,18 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96fe57af81d28386a513cbc6858332abc6117cfdb5999647c6444b8f43a370a5" +checksum = "b88fa983de7720629c9387e9f517353ed404164b1e482c970a90c1a4aaf7dc1a" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.116" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f630a6370fd8e457873b4bd2ffdae75408bc291ba72be773772a4c2a065d9ae8" +checksum = "cbd1ae72adb44aab48f325a02444a5fc079349a8d804c1fc922aed3f7454c74e" dependencies = [ "proc-macro2", "quote", From 06f9a6019bb4e6802a1f68b57bbfbcb7ac5689c5 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Mon, 19 Oct 2020 09:27:02 -0400 Subject: [PATCH 09/17] src/io/mod.rs: fix new Clippy complaint --- src/io/mod.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/io/mod.rs b/src/io/mod.rs index c2e3a299d..ca4d92699 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -312,11 +312,7 @@ impl OpenResult { /// Returns true if this result is of the NotAvailable variant. pub fn is_not_available(&self) -> bool { - if let OpenResult::NotAvailable = *self { - true - } else { - false - } + matches!(*self, OpenResult::NotAvailable) } /// Convert this object into a plain Result, erroring if the item was not available. From 7f653dec01ca9d861861d3cd12daeab7652e6345 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2020 14:26:56 +0000 Subject: [PATCH 10/17] build(deps): bump pkg-config from 0.3.18 to 0.3.19 Bumps [pkg-config](https://github.com/rust-lang/pkg-config-rs) from 0.3.18 to 0.3.19. - [Release notes](https://github.com/rust-lang/pkg-config-rs/releases) - [Changelog](https://github.com/rust-lang/pkg-config-rs/blob/master/CHANGELOG.md) - [Commits](https://github.com/rust-lang/pkg-config-rs/compare/0.3.18...0.3.19) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af4002c31..9bc36e6ba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1126,9 +1126,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pkg-config" -version = "0.3.18" +version = "0.3.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d36492546b6af1463394d46f0c834346f31548646f6ba10849802c9c9a27ac33" +checksum = "3831453b3449ceb48b6d9c7ad7c96d5ea673e9b470a1dc578c2ce6521230884c" [[package]] name = "ppv-lite86" From 15c980ce6ac107a3d69ec580d5b06fc570044857 Mon Sep 17 00:00:00 2001 From: "dependabot-preview[bot]" <27856297+dependabot-preview[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2020 14:28:40 +0000 Subject: [PATCH 11/17] build(deps): bump structopt from 0.3.19 to 0.3.20 Bumps [structopt](https://github.com/TeXitoi/structopt) from 0.3.19 to 0.3.20. - [Release notes](https://github.com/TeXitoi/structopt/releases) - [Changelog](https://github.com/TeXitoi/structopt/blob/master/CHANGELOG.md) - [Commits](https://github.com/TeXitoi/structopt/compare/v0.3.19...v0.3.20) Signed-off-by: dependabot-preview[bot] --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index af4002c31..7d0a83414 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1607,9 +1607,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.19" +version = "0.3.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a7159e7d0dbcab6f9c980d7971ef50f3ff5753081461eeda120d5974a4ee95" +checksum = "126d630294ec449fae0b16f964e35bf3c74f940da9dca17ee9b905f7b3112eb8" dependencies = [ "clap", "lazy_static", @@ -1618,9 +1618,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.12" +version = "0.4.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fc47de4dfba76248d1e9169ccff240eea2a4dc1e34e309b95b2393109b4b383" +checksum = "65e51c492f9e23a220534971ff5afc14037289de430e3c83f9daf6a1b6ae91e8" dependencies = [ "heck", "proc-macro-error", From 7d59f6d04975791ae6e6802162d0bdcff2f78ef2 Mon Sep 17 00:00:00 2001 From: ralismark Date: Thu, 15 Oct 2020 12:56:00 +1100 Subject: [PATCH 12/17] Hide shell-escape --- src/unstable_opts.rs | 8 +++++--- tectonic/xetex-shipout.c | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/unstable_opts.rs b/src/unstable_opts.rs index e2749289c..c5a5be14e 100644 --- a/src/unstable_opts.rs +++ b/src/unstable_opts.rs @@ -18,9 +18,11 @@ const HELPMSG: &str = r#"Available unstable options: -Z min-crossrefs= Equivalent to bibtex's -min-crossrefs flag - "include after crossrefs" [default: 2] -Z paper-size= Change the default paper size [default: letter] - -Z shell-escape Enable \write18 "#; +// Re-add this when \write18 gets implemented +// -Z shell-escape Enable \write18 + // Each entry of this should correspond to a field of UnstableOptions. #[derive(Debug)] pub enum UnstableArg { @@ -60,8 +62,8 @@ impl FromStr for UnstableArg { }) .map(|s| UnstableArg::PaperSize(s.to_string())), - "shell-escape" => Ok(UnstableArg::ShellEscapeEnabled), - + // Re-add this when \write18 gets implemetned + // "shell-escape" => Ok(UnstableArg::ShellEscapeEnabled), _ => Err(format!("Unknown unstable option '{}'", arg).into()), } } diff --git a/tectonic/xetex-shipout.c b/tectonic/xetex-shipout.c index 7f115fe26..88b9578c1 100644 --- a/tectonic/xetex-shipout.c +++ b/tectonic/xetex-shipout.c @@ -2186,6 +2186,10 @@ write_out(int32_t p) print_cstr("disabled"); print_char('.'); } else { + // Currently, -Z shell-escape is implemented but hidden (see + // src/unstable_opts.rs). When this gets actually implemented, + // uncomment the relevant parts in that file. + print_cstr("enabled but not implemented yet!"); } From 950d7e51b9d59f184c4df789c12443bcde88d9b3 Mon Sep 17 00:00:00 2001 From: ralismark Date: Mon, 19 Oct 2020 18:02:31 +1100 Subject: [PATCH 13/17] Pass engine configs using structs --- src/engines/bibtex.rs | 15 +++++++-------- src/engines/mod.rs | 2 ++ src/engines/xdvipdfmx.rs | 26 ++++++++++++++++++-------- tectonic/bibtex.c | 8 ++++---- tectonic/bibtex.h | 3 +++ tectonic/core-bridge.c | 6 ++++-- tectonic/dpx-dvipdfmx.c | 5 ++--- tectonic/dpx-dvipdfmx.h | 1 + 8 files changed, 41 insertions(+), 25 deletions(-) diff --git a/src/engines/bibtex.rs b/src/engines/bibtex.rs index c0df816b5..b560f1968 100644 --- a/src/engines/bibtex.rs +++ b/src/engines/bibtex.rs @@ -11,9 +11,9 @@ use crate::io::IoStack; use crate::status::StatusBackend; use crate::unstable_opts::UnstableOptions; -#[no_mangle] -extern "C" { - static mut min_crossrefs: i32; +#[repr(C)] +pub struct BibtexConfig { + min_crossrefs: i32, } #[derive(Default)] @@ -38,13 +38,12 @@ impl BibtexEngine { let mut state = ExecutionState::new(io, events, status); let bridge = TectonicBridgeApi::new(&mut state); - - if let Some(num) = unstables.min_crossrefs { - unsafe { min_crossrefs = num } - } + let config = BibtexConfig { + min_crossrefs: unstables.min_crossrefs.unwrap_or(2), + }; unsafe { - match super::bibtex_simple_main(&bridge, caux.as_ptr()) { + match super::bibtex_simple_main(&bridge, &config, caux.as_ptr()) { 0 => Ok(TexResult::Spotless), 1 => Ok(TexResult::Warnings), 2 => Ok(TexResult::Errors), diff --git a/src/engines/mod.rs b/src/engines/mod.rs index 82e766711..842b1c1b2 100644 --- a/src/engines/mod.rs +++ b/src/engines/mod.rs @@ -496,6 +496,7 @@ extern "C" { fn dvipdfmx_simple_main( api: &TectonicBridgeApi, + config: &xdvipdfmx::XdvipdfmxConfig, dviname: *const libc::c_char, pdfname: *const libc::c_char, enable_compression: bool, @@ -505,6 +506,7 @@ extern "C" { fn bibtex_simple_main( api: &TectonicBridgeApi, + config: &bibtex::BibtexConfig, aux_file_name: *const libc::c_char, ) -> libc::c_int; diff --git a/src/engines/xdvipdfmx.rs b/src/engines/xdvipdfmx.rs index e9a989f6f..c7b9d110d 100644 --- a/src/engines/xdvipdfmx.rs +++ b/src/engines/xdvipdfmx.rs @@ -11,9 +11,9 @@ use crate::io::IoStack; use crate::status::StatusBackend; use crate::unstable_opts::UnstableOptions; -#[no_mangle] -extern "C" { - static mut paperspec: *const libc::c_char; +#[repr(C)] +pub struct XdvipdfmxConfig { + paperspec: *const libc::c_char, } pub struct XdvipdfmxEngine { @@ -61,15 +61,24 @@ impl XdvipdfmxEngine { ) -> Result { let _guard = super::ENGINE_LOCK.lock().unwrap(); // until we're thread-safe ... + // This conversion is probably way too complex, because we need to convert String to + // something which holds a CStr (which needs to be a local so it doesn't disappear). And + // all of this happens in an Option. + + // Keep a local reference so the string doesn't get dropped too early let paperspec_str = unstables .paper_size .as_ref() .and_then(|s| CString::new(s.clone()).ok()); - if let Some(cstr) = paperspec_str.as_ref() { - unsafe { - paperspec = cstr.as_ptr(); - } - } + + // We default to "letter" paper size by default + let paperspec_default = CStr::from_bytes_with_nul(b"letter\0").unwrap(); + + let config = XdvipdfmxConfig { + paperspec: paperspec_str + .as_ref() + .map_or(paperspec_default.as_ptr(), |s| s.as_ptr()), + }; let cdvi = CString::new(dvi)?; let cpdf = CString::new(pdf)?; @@ -80,6 +89,7 @@ impl XdvipdfmxEngine { unsafe { match super::dvipdfmx_simple_main( &bridge, + &config, cdvi.as_ptr(), cpdf.as_ptr(), self.enable_compression, diff --git a/tectonic/bibtex.c b/tectonic/bibtex.c index 5fc37e6d4..aca94f58f 100644 --- a/tectonic/bibtex.c +++ b/tectonic/bibtex.c @@ -145,7 +145,6 @@ static jmp_buf error_jmpbuf, recover_jmpbuf; #define aux_stack_size 20 #define MAX_BIB_FILES 20 #define POOL_SIZE 65000L -#define MIN_CROSSREFS 2 #define MAX_STRINGS 35307 #define MAX_CITES 750 #define WIZ_FN_SPACE 3000 @@ -416,7 +415,8 @@ static buf_pointer num_text_chars; static unsigned char /*bad_conversion */ conversion_type; static bool prev_colon; static int verbose; -int32_t min_crossrefs = MIN_CROSSREFS; + +const BibtexConfig* bibtex_config; /*:473*//*12: *//*3: */ @@ -6695,7 +6695,7 @@ static void bst_read_command(void) mark_warning(); } if (((!all_entries) && (cite_parent_ptr >= old_num_cites) - && (cite_info[cite_parent_ptr] < min_crossrefs))) + && (cite_info[cite_parent_ptr] < bibtex_config->min_crossrefs))) field_info[field_ptr] = 0 /*missing */ ; } } @@ -6709,7 +6709,7 @@ static void bst_read_command(void) if (type_list[cite_ptr] == 0 /*empty */ ) print_missing_entry(cite_list[cite_ptr]); - else if ((all_entries) || (cite_ptr < old_num_cites) || (cite_info[cite_ptr] >= min_crossrefs)) { + else if ((all_entries) || (cite_ptr < old_num_cites) || (cite_info[cite_ptr] >= bibtex_config->min_crossrefs)) { if (cite_ptr > cite_xptr) { /*286: */ if ((cite_xptr + 1) * num_fields > max_fields) { puts_log("field_info index is out of range"); diff --git a/tectonic/bibtex.h b/tectonic/bibtex.h index 2a8851b4e..8df358cf3 100644 --- a/tectonic/bibtex.h +++ b/tectonic/bibtex.h @@ -10,4 +10,7 @@ tt_history_t bibtex_main(const char *aux_file_name); +// Passed in from rust side +extern const BibtexConfig* bibtex_config; + #endif diff --git a/tectonic/core-bridge.c b/tectonic/core-bridge.c index 992506754..a170fb9e0 100644 --- a/tectonic/core-bridge.c +++ b/tectonic/core-bridge.c @@ -70,7 +70,7 @@ tex_simple_main(const tt_bridge_api_t *api, const char *dump_name, const char *i int -dvipdfmx_simple_main(const tt_bridge_api_t *api, const char *dviname, const char *pdfname, bool compress, bool deterministic_tags, time_t build_date) +dvipdfmx_simple_main(const tt_bridge_api_t *api, const XdvipdfmxConfig* config, const char *dviname, const char *pdfname, bool compress, bool deterministic_tags, time_t build_date) { int rv; @@ -81,6 +81,7 @@ dvipdfmx_simple_main(const tt_bridge_api_t *api, const char *dviname, const char return 99; } + dpx_config = config; rv = dvipdfmx_main(pdfname, dviname, NULL, 0, false, compress, deterministic_tags, false, 0, build_date); tectonic_global_bridge = NULL; @@ -89,7 +90,7 @@ dvipdfmx_simple_main(const tt_bridge_api_t *api, const char *dviname, const char int -bibtex_simple_main(const tt_bridge_api_t *api, const char *aux_file_name) +bibtex_simple_main(const tt_bridge_api_t *api, const BibtexConfig *config, const char *aux_file_name) { int rv; @@ -100,6 +101,7 @@ bibtex_simple_main(const tt_bridge_api_t *api, const char *aux_file_name) return 99; } + bibtex_config = config; rv = bibtex_main(aux_file_name); tectonic_global_bridge = NULL; return rv; diff --git a/tectonic/dpx-dvipdfmx.c b/tectonic/dpx-dvipdfmx.c index a4e42bdcf..e3398903c 100644 --- a/tectonic/dpx-dvipdfmx.c +++ b/tectonic/dpx-dvipdfmx.c @@ -55,8 +55,6 @@ #include "dpx-vf.h" #include "dpx-tt_aux.h" -const char* paperspec = "letter"; - typedef struct page_range { int first; @@ -65,6 +63,7 @@ typedef struct page_range int is_xdv = 0; int translate_origin = 0; +const XdvipdfmxConfig* dpx_config; #define OPT_TPIC_TRANSPARENT_FILL (1 << 1) #define OPT_CIDFONT_FIXEDPITCH (1 << 2) @@ -410,7 +409,7 @@ dvipdfmx_main ( * code bits. */ pdf_set_version (5); - select_paper(paperspec); + select_paper(dpx_config->paperspec); annot_grow = 0; bookmark_open = 0; key_bits = 40; diff --git a/tectonic/dpx-dvipdfmx.h b/tectonic/dpx-dvipdfmx.h index 25b88351c..784960069 100644 --- a/tectonic/dpx-dvipdfmx.h +++ b/tectonic/dpx-dvipdfmx.h @@ -34,6 +34,7 @@ extern int is_xdv; extern int translate_origin; extern time_t source_date_epoch; +extern const XdvipdfmxConfig* dpx_config; int extractbb(int argc, char *argv[]); int dvipdfmx_main( From f2c7f564080c5f6e3659d5de53e4b238e8793765 Mon Sep 17 00:00:00 2001 From: ralismark Date: Mon, 19 Oct 2020 18:32:05 +1100 Subject: [PATCH 14/17] Add a4 paper test --- tests/tex-outputs.rs | 23 ++++++++++++++++++++--- tests/tex-outputs/a4paper.tex | 1 + 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 tests/tex-outputs/a4paper.tex diff --git a/tests/tex-outputs.rs b/tests/tex-outputs.rs index a585a72db..396f299b8 100644 --- a/tests/tex-outputs.rs +++ b/tests/tex-outputs.rs @@ -2,7 +2,6 @@ // Licensed under the MIT License. use std::collections::HashSet; -use std::default::Default; use std::path::Path; use std::time; @@ -13,6 +12,7 @@ use tectonic::io::testing::SingleInputFileIo; use tectonic::io::{FilesystemIo, FilesystemPrimaryInputIo, IoProvider, IoStack, MemoryIo}; use tectonic::status::NoopStatusBackend; use tectonic::{TexEngine, XdvipdfmxEngine}; +use tectonic::unstable_opts::UnstableOptions; #[path = "util/mod.rs"] mod util; @@ -24,6 +24,7 @@ struct TestCase { check_synctex: bool, check_pdf: bool, extra_io: Vec>, + unstables: UnstableOptions, } impl TestCase { @@ -34,6 +35,7 @@ impl TestCase { check_synctex: false, check_pdf: false, extra_io: Vec::new(), + unstables: UnstableOptions::default(), } } @@ -57,6 +59,11 @@ impl TestCase { self } + fn with_unstables(&mut self, unstables: UnstableOptions) -> &mut Self { + self.unstables = unstables; + self + } + fn expect(&mut self, result: Result) -> &mut Self { self.expected_result = result; self @@ -119,7 +126,7 @@ impl TestCase { &mut status, "plain.fmt", &texname, - &Default::default(), + &self.unstables, ); if self.check_pdf && tex_res.definitely_same(&Ok(TexResult::Spotless)) { @@ -137,7 +144,7 @@ impl TestCase { &mut status, &xdvname, &pdfname, - &Default::default(), + &self.unstables, ) .unwrap(); } @@ -274,3 +281,13 @@ fn tectoniccodatokens_ok() { fn the_letter_a() { TestCase::new("the_letter_a").check_pdf(true).go() } + +#[test] +fn a4paper() { + let mut unstables = UnstableOptions::default(); + unstables.paper_size = Some(String::from("a4")); + TestCase::new("a4paper") + .with_unstables(unstables) + .check_pdf(true) + .go() +} diff --git a/tests/tex-outputs/a4paper.tex b/tests/tex-outputs/a4paper.tex new file mode 100644 index 000000000..7c9c44ad9 --- /dev/null +++ b/tests/tex-outputs/a4paper.tex @@ -0,0 +1 @@ +a\bye From 6d03496b27875813cb357df100cc8026232a6a2e Mon Sep 17 00:00:00 2001 From: ralismark Date: Wed, 21 Oct 2020 08:59:22 +1100 Subject: [PATCH 15/17] Add a4paper outputs --- tests/tex-outputs/a4paper.log | 3 +++ tests/tex-outputs/a4paper.pdf | Bin 0 -> 1824 bytes tests/tex-outputs/a4paper.xdv | Bin 0 -> 212 bytes 3 files changed, 3 insertions(+) create mode 100644 tests/tex-outputs/a4paper.log create mode 100644 tests/tex-outputs/a4paper.pdf create mode 100644 tests/tex-outputs/a4paper.xdv diff --git a/tests/tex-outputs/a4paper.log b/tests/tex-outputs/a4paper.log new file mode 100644 index 000000000..0f6bcbee3 --- /dev/null +++ b/tests/tex-outputs/a4paper.log @@ -0,0 +1,3 @@ +** +(a4paper.tex [1] ) +Output written on a4paper.xdv (1 page, 212 bytes). diff --git a/tests/tex-outputs/a4paper.pdf b/tests/tex-outputs/a4paper.pdf new file mode 100644 index 0000000000000000000000000000000000000000..3c77556326cbce1a72c21f8a9a28c4dd130adfe8 GIT binary patch literal 1824 zcmcIlU5pb|6rR~F+gcY;e&U1Dy$^0^Bki3#za6sK$j;KZ!t&E@1npKcJ9FC|w$rII zQ+C-Gi4k2hijo+Jzw1U9lhtep1Qmjjs4>RGga?g2s1c&_ASAxEhzZ_1TLi*`Pqxju zKj++gzI)DhPJ4F@=F%u5#e0AK^KvUL0S-80d*Xe4a4W7={BeLdxxYW|`7YM&ICv5u zV!;uq@IaB(OjZSk4F*O4%pss=RGF7WFj5AH%z25=g7m+eW-+O!N+S;g9ubFGk&{4L zmc)!ADm*zu)F@PM9sxV!aa=RoPRWcyLey^?TcI)L@2g`tLIl#TLzR$t11ifzA`Hv2 z%Q^Z%4`{=A#L*4OxO(uf16Q72*1DHz-N&}pb+i(lt$QNt7>4=dZYqCYN#!qhQQ1ob z`_n2W!m_c(^z$4iWH^r3occc3s*L*}X{5+oRb>OwpstKvw8Z;nzio)FZzk$ zEkZC6#H!KR;LG6C`PkpDMJqE;p~OVBYw_TP;KYdw!D9FQ3lmW^bNE;fxn}>|^g?rD zZvHoP@zmU^lRp$MHkEVVzPs8!+dTjM+Lw%@`spC{_E)d|*z>tti0*U`?BDa;$1f+E zqtW1GaJ+KNJpSnG#UQ5UMu+U#>G}8GoSp9pjy(H8>4l?JQKE zp4mLJ)qc=&cLh(xHePbSP7p8O1gB2CbvpJ;GrM+ubc1F+{@B>!CyC&*lRr1rL$MW& zxt8`uvv&BFz!^+r2yyk0`U!0lsu3cd}u zfh^2fuIB?$zRo2@yopOPIVS*F09k-|0q_826;cAcA_El&oD4)D5_%#8Bpv}$J2ZuK zKt#iVe1AXO;W|bE`$b6V4UXU`9}d}i1#3&gz|t^OBK#%i2o;=$YhVvh&-sw%a0f9b z!o`Fg*>GDUUdYNT(yGn3&xQ}9wjR`+2C+qOi)DI6A+&+R*tGNkXR1i6Nm8W@DbcKm zNFBG&YoyS9$4&a!@SU1vq$qT=VPH2oW$v}=X4#$sqe(7s6;hv_*-daQ@FP@lc|n4L#HJz*~9<++~^m zxJS}S;~kPg8`oVRs&K3B`Qcnu;DGMo@bJw|CCv69_6*mmlgLpTggL*(-3>j|^!h_M zY#wq}fSWvnW>i*1NNwmmjmTn%1jjNq)hbmCI9Twp{RlCFxvE|vvsC`nB&$Ql#(p0R050G?!~g&Q literal 0 HcmV?d00001 From b539051b02d095c9341859223ac8854e8103e49d Mon Sep 17 00:00:00 2001 From: ralismark Date: Wed, 21 Oct 2020 09:45:32 +1100 Subject: [PATCH 16/17] Fix cargo fmt --- tests/tex-outputs.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tex-outputs.rs b/tests/tex-outputs.rs index 396f299b8..019bc0139 100644 --- a/tests/tex-outputs.rs +++ b/tests/tex-outputs.rs @@ -11,8 +11,8 @@ use tectonic::errors::{DefinitelySame, ErrorKind, Result}; use tectonic::io::testing::SingleInputFileIo; use tectonic::io::{FilesystemIo, FilesystemPrimaryInputIo, IoProvider, IoStack, MemoryIo}; use tectonic::status::NoopStatusBackend; -use tectonic::{TexEngine, XdvipdfmxEngine}; use tectonic::unstable_opts::UnstableOptions; +use tectonic::{TexEngine, XdvipdfmxEngine}; #[path = "util/mod.rs"] mod util; From c48c2434f2e53e80bec02b812da782ce0fdbc608 Mon Sep 17 00:00:00 2001 From: Peter Williams Date: Sat, 10 Oct 2020 17:25:43 -0400 Subject: [PATCH 17/17] src/io/mod.rs: correct misleading error message --- src/io/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/io/mod.rs b/src/io/mod.rs index ca4d92699..c740125d8 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -467,7 +467,7 @@ pub trait Bundle: IoProvider { OpenResult::NotAvailable => { // Broken or un-cacheable backend. return Err(ErrorKind::Msg( - "itar-format bundle does not provide needed SHA256SUM file".to_owned(), + "bundle does not provide needed SHA256SUM file".to_owned(), ) .into()); }