diff --git a/CHANGELOG.md b/CHANGELOG.md index ad4ce1ed7..f235bfab4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,19 @@ +# tectonic 0.2.0 (2020-10-21) + +The 0.2 series finally adds "unstable" `-Z` flags! These allow you to configure +engine options that are relatively low-level. The hope is to eventually set +these kinds of things in a `Tectonic.toml` file, so their use is mildly +discouraged, and long-term availability is not guaranteed. But there are plenty +of times when such flags can be helpful. The currently supported options are: + +- `-Z min-crossrefs=` controls the `-min-crossrefs` option of standalone `bibtex` +- `-Z paper-size=` lets you control the output paper size, rather than + hardcoding it to be US Letter. + +Enormous thanks to @ralismark for finally implementing this! (#657) Now that the +infrastructure is in place, suggestions for additional flags are more than +welcome. + # tectonic 0.1.17 (2020-10-13) - Fix source-based installation by updating to cbindgen 0.15, after later diff --git a/Cargo.lock b/Cargo.lock index f49637a06..99954d0a6 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" @@ -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", @@ -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", @@ -1654,7 +1654,7 @@ dependencies = [ [[package]] name = "tectonic" -version = "0.1.17" +version = "0.2.0" dependencies = [ "app_dirs2", "atty", @@ -1689,14 +1689,14 @@ dependencies = [ [[package]] name = "tectonic_cfg_support" -version = "0.1.0" +version = "0.1.1" dependencies = [ "lazy_static", ] [[package]] name = "tectonic_xdv" -version = "0.1.9" +version = "0.1.10" dependencies = [ "byteorder", "clap", diff --git a/Cargo.toml b/Cargo.toml index fdaf48048..01f18756f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ [package] name = "tectonic" -version = "0.1.17" +version = "0.2.0" authors = ["Peter Williams "] build = "build.rs" description = """ diff --git a/cfg_support/CHANGELOG.md b/cfg_support/CHANGELOG.md index c27274410..a36c43fe6 100644 --- a/cfg_support/CHANGELOG.md +++ b/cfg_support/CHANGELOG.md @@ -1,8 +1,4 @@ -# See elsewhere for changelog +# tectonic_cfg_support 0.1.1 (2020-10-21) -This project’s release notes are curated from the Git history of its main -branch. You can find them by looking at [the version of this file on the -`release` branch][branch] or the [GitHub release history][gh-releases]. - -[branch]: https://github.com/tectonic-typesetting/tectonic/blob/release/cfg_support/CHANGELOG.md -[gh-releases]: https://github.com/tectonic-typesetting/tectonic/releases +- No code changes; just issuing a new release to update deps and silence + Cranko's change detection. diff --git a/cfg_support/Cargo.toml b/cfg_support/Cargo.toml index 27be76b66..8f2af7dac 100644 --- a/cfg_support/Cargo.toml +++ b/cfg_support/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "tectonic_cfg_support" -version = "0.1.0" +version = "0.1.1" authors = [ "Matt Rice ", "Peter Williams " diff --git a/src/bin/tectonic.rs b/src/bin/tectonic.rs index fc301b143..927764264 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::{UnstableArg, UnstableOptions}; use tectonic::{errmsg, tt_error, tt_note}; #[derive(Debug, StructOpt)] @@ -73,11 +74,18 @@ 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. 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_unstable_args(args.unstable.into_iter()); + 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..4e7c45598 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; @@ -1040,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 { @@ -1110,6 +1128,7 @@ impl ProcessingSession { status, &self.format_name, &self.primary_input_tex_path, + &self.unstables, ) }; @@ -1137,6 +1156,7 @@ impl ProcessingSession { &mut self.events, status, &self.tex_aux_path.to_str().unwrap(), + &self.unstables, ) }; @@ -1174,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..b560f1968 100644 --- a/src/engines/bibtex.rs +++ b/src/engines/bibtex.rs @@ -9,6 +9,12 @@ use super::{ExecutionState, IoEventBackend, TectonicBridgeApi}; use crate::errors::{ErrorKind, Result}; use crate::io::IoStack; use crate::status::StatusBackend; +use crate::unstable_opts::UnstableOptions; + +#[repr(C)] +pub struct BibtexConfig { + min_crossrefs: i32, +} #[derive(Default)] pub struct BibtexEngine {} @@ -24,6 +30,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 ... @@ -31,9 +38,12 @@ impl BibtexEngine { let mut state = ExecutionState::new(io, events, status); let bridge = TectonicBridgeApi::new(&mut state); + 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/tex.rs b/src/engines/tex.rs index f55d896e9..d9bc06f3f 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 ... @@ -119,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/src/engines/xdvipdfmx.rs b/src/engines/xdvipdfmx.rs index 45ab2a686..c7b9d110d 100644 --- a/src/engines/xdvipdfmx.rs +++ b/src/engines/xdvipdfmx.rs @@ -9,6 +9,12 @@ use super::{ExecutionState, IoEventBackend, TectonicBridgeApi}; use crate::errors::{ErrorKind, Result}; use crate::io::IoStack; use crate::status::StatusBackend; +use crate::unstable_opts::UnstableOptions; + +#[repr(C)] +pub struct XdvipdfmxConfig { + paperspec: *const libc::c_char, +} pub struct XdvipdfmxEngine { enable_compression: bool, @@ -51,9 +57,29 @@ 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 ... + // 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()); + + // 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)?; @@ -63,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/src/io/mod.rs b/src/io/mod.rs index c2e3a299d..c740125d8 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. @@ -471,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()); } 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..c5a5be14e --- /dev/null +++ b/src/unstable_opts.rs @@ -0,0 +1,101 @@ +// 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::{Error, Result}; +use std::default::Default; +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] +"#; + +// 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 { + Help, + PaperSize(String), + MinCrossrefs(i32), + ShellEscapeEnabled, +} + +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), + + "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() + }) + .map(|s| UnstableArg::PaperSize(s.to_string())), + + // Re-add this when \write18 gets implemetned + // "shell-escape" => Ok(UnstableArg::ShellEscapeEnabled), + _ => Err(format!("Unknown unstable option '{}'", arg).into()), + } + } +} + +#[derive(Debug, Default)] +pub struct UnstableOptions { + pub paper_size: Option, + pub shell_escape: bool, + pub min_crossrefs: Option, +} + +impl UnstableOptions { + pub fn from_unstable_args(uargs: I) -> Self + where + I: Iterator, + { + let mut opts = UnstableOptions::default(); + + for u in uargs { + use UnstableArg::*; + match u { + Help => { + 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, + } + } + + opts + } +} diff --git a/tectonic/bibtex.c b/tectonic/bibtex.c index 7c00b7335..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; -static int32_t 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"); @@ -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; 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-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..e3398903c 100644 --- a/tectonic/dpx-dvipdfmx.c +++ b/tectonic/dpx-dvipdfmx.c @@ -63,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) @@ -263,16 +264,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 +402,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 +409,7 @@ dvipdfmx_main ( * code bits. */ pdf_set_version (5); - select_paper("letter"); + 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( 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..88b9578c1 100644 --- a/tectonic/xetex-shipout.c +++ b/tectonic/xetex-shipout.c @@ -2174,15 +2174,31 @@ 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 { + // 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!"); + } + + 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; 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..019bc0139 100644 --- a/tests/tex-outputs.rs +++ b/tests/tex-outputs.rs @@ -11,6 +11,7 @@ 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::unstable_opts::UnstableOptions; use tectonic::{TexEngine, XdvipdfmxEngine}; #[path = "util/mod.rs"] @@ -23,6 +24,7 @@ struct TestCase { check_synctex: bool, check_pdf: bool, extra_io: Vec>, + unstables: UnstableOptions, } impl TestCase { @@ -33,6 +35,7 @@ impl TestCase { check_synctex: false, check_pdf: false, extra_io: Vec::new(), + unstables: UnstableOptions::default(), } } @@ -56,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 @@ -112,8 +120,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, + &self.unstables, + ); if self.check_pdf && tex_res.definitely_same(&Ok(TexResult::Spotless)) { XdvipdfmxEngine::new() @@ -124,7 +138,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, + &self.unstables, + ) .unwrap(); } @@ -260,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.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 000000000..3c7755632 Binary files /dev/null and b/tests/tex-outputs/a4paper.pdf differ 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 diff --git a/tests/tex-outputs/a4paper.xdv b/tests/tex-outputs/a4paper.xdv new file mode 100644 index 000000000..680f8afb5 Binary files /dev/null and b/tests/tex-outputs/a4paper.xdv differ 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(), )?; } diff --git a/xdv/CHANGELOG.md b/xdv/CHANGELOG.md index 17b66fa53..2c39bf373 100644 --- a/xdv/CHANGELOG.md +++ b/xdv/CHANGELOG.md @@ -1,8 +1,4 @@ -# See elsewhere for changelog +# tectonic_xdv 0.1.10 (2020-10-21) -This project’s release notes are curated from the Git history of its main -branch. You can find them by looking at [the version of this file on the -`release` branch][branch] or the [GitHub release history][gh-releases]. - -[branch]: https://github.com/tectonic-typesetting/tectonic/blob/release/xdv/CHANGELOG.md -[gh-releases]: https://github.com/tectonic-typesetting/tectonic/releases +- No code changes; just issuing a new release to update deps and silence + Cranko's change detection. diff --git a/xdv/Cargo.toml b/xdv/Cargo.toml index 2106da616..657d7cd9f 100644 --- a/xdv/Cargo.toml +++ b/xdv/Cargo.toml @@ -3,7 +3,7 @@ [package] name = "tectonic_xdv" -version = "0.1.9" +version = "0.1.10" authors = ["Peter Williams "] description = """ A decoder for the XDV and SPX file formats used by XeTeX and Tectonic.