Skip to content

Commit

Permalink
Merge pull request #1202 from winstxnhdw/master
Browse files Browse the repository at this point in the history
fix: use c++ 17
  • Loading branch information
CraftSpider authored Aug 8, 2024
2 parents 19654bf + 513caa0 commit f392f76
Show file tree
Hide file tree
Showing 16 changed files with 43 additions and 64 deletions.
9 changes: 5 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

37 changes: 9 additions & 28 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,14 @@ documentation = "https://docs.rs/tectonic"
repository = "https://github.com/tectonic-typesetting/tectonic/"
readme = "CARGO_README.md"
keywords = ["tex", "latex", "typesetting", "font"]
categories = [
"command-line-interface",
"parser-implementations",
"rendering",
"science",
"text-processing",
]
categories = ["command-line-interface", "parser-implementations", "rendering", "science", "text-processing"]
license = "MIT"
edition = "2018"
exclude = ["/dist/", "/reference_sources/"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(backtrace)'] }

[badges]
travis-ci = { repository = "tectonic-typesetting/tectonic" }
codecov = { repository = "tectonic-typesetting/tectonic", service = "github" }
Expand Down Expand Up @@ -97,6 +94,7 @@ watchexec-filterer-globset = "3.0"
watchexec-signals = "2.0"
watchexec-supervisor = "1.0"
zip = { version = "^0.6", default-features = false, features = ["deflate"] }
time = "0.3.36"

[features]
default = ["geturl-reqwest", "serialization"]
Expand All @@ -114,10 +112,7 @@ external-harfbuzz = ["tectonic_engine_xetex/external-harfbuzz"]
geturl-curl = ["tectonic_bundles/geturl-curl", "tectonic_geturl/curl"]
geturl-reqwest = ["tectonic_bundles/geturl-reqwest", "tectonic_geturl/reqwest"]

native-tls-vendored = [
"tectonic_bundles/native-tls-vendored",
"tectonic_geturl/native-tls-vendored",
]
native-tls-vendored = ["tectonic_bundles/native-tls-vendored", "tectonic_geturl/native-tls-vendored"]

# developer feature to compile with the necessary flags for profiling tectonic.
profile = []
Expand All @@ -141,23 +136,9 @@ overlay-triplets-path = "dist/vcpkg-triplets"
# guidance if they might need to set $VCPKGRS_TRIPLET.
[package.metadata.vcpkg.target]
x86_64-apple-darwin = { install = ["freetype", "harfbuzz[graphite2]", "icu"] }
aarch64-apple-darwin = { triplet = "arm64-osx", install = [
"freetype",
"harfbuzz[graphite2]",
"icu",
] }
x86_64-unknown-linux-gnu = { install = [
"fontconfig",
"freetype",
"harfbuzz[graphite2]",
"icu",
] }
x86_64-pc-windows-msvc = { triplet = "x64-windows-static-release", install = [
"fontconfig",
"freetype",
"harfbuzz[graphite2]",
"icu",
] }
aarch64-apple-darwin = { triplet = "arm64-osx", install = ["freetype", "harfbuzz[graphite2]", "icu"] }
x86_64-unknown-linux-gnu = { install = ["fontconfig", "freetype", "harfbuzz[graphite2]", "icu"] }
x86_64-pc-windows-msvc = { triplet = "x64-windows-static-release", install = ["fontconfig", "freetype", "harfbuzz[graphite2]", "icu"] }

[package.metadata.internal_dep_versions]
tectonic_bridge_core = "thiscommit:2023-06-11:PvhF7YB"
Expand Down
6 changes: 2 additions & 4 deletions crates/bundles/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ impl<CB: CacheBackend> CachingBundle<CB> {
// If a filename contains newline characters, it will mess up our
// line-based manifest format. Be paranoid and refuse to record such
// filenames.
if !name.contains(|c| c == '\n' || c == '\r') {
if !name.contains(['\n', '\r']) {
writeln!(man, "{name} {length} {digest_text}")?;
}

Expand Down Expand Up @@ -515,9 +515,7 @@ impl<CB: CacheBackend> CachingBundle<CB> {
// giving incorrect results if we pulled files out of the cache
// before this invocation. Rewrite the digest file so that next time
// we'll start afresh, then bail.
file_create_write(&self.digest_path, |f| {
writeln!(f, "{}", pull_data.digest.to_string())
})?;
file_create_write(&self.digest_path, |f| writeln!(f, "{}", pull_data.digest))?;
bail!("backend digest changed; rerun tectonic to use updated information");
}

Expand Down
4 changes: 2 additions & 2 deletions crates/docmodel/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl Document {
tried_src_path = true;

if let Some(s) = t.to_str() {
name = s.to_owned();
s.clone_into(&mut name);
}
}

Expand All @@ -273,7 +273,7 @@ impl Document {

if let Some(Component::Normal(t)) = full_path.components().next_back() {
if let Some(s) = t.to_str() {
name = s.to_owned();
s.clone_into(&mut name);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/engine_spx2html/src/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ pub(crate) fn create_output_path(

for piece in dest_path.split('/') {
if let Some(out_path) = out_path.as_mut() {
match std::fs::create_dir(&out_path) {
match std::fs::create_dir(out_path.as_path()) {
Ok(_) => {}
Err(e) if e.kind() == std::io::ErrorKind::AlreadyExists => {}
Err(e) => {
Expand Down
10 changes: 6 additions & 4 deletions crates/engine_spx2html/src/fontfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,9 +426,10 @@ impl FontFileData {

if let Some(out_path) = out_path.as_mut() {
out_path.push(rel_path);
let display_path = out_path.clone();
atry!(
std::fs::write(&out_path, &self.buffer);
["cannot write output file `{}`", out_path.display()]
std::fs::write(out_path, &self.buffer);
["cannot write output file `{}`", display_path.display()]
);
}

Expand Down Expand Up @@ -490,9 +491,10 @@ impl FontFileData {

out_path.pop();
out_path.push(&varname);
let display_path = out_path.clone();
atry!(
std::fs::write(&out_path, &buffer);
["cannot write output file `{}`", out_path.display()]
std::fs::write(out_path, &buffer);
["cannot write output file `{}`", display_path.display()]
);
}

Expand Down
8 changes: 4 additions & 4 deletions crates/engine_spx2html/src/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,13 +197,13 @@ impl FontEnsemble {
// Update the info records for the relevant fonts to capture the
// established relationship.

self.font_files[regular].family_name = name.clone();
self.font_files[regular].family_name.clone_from(&name);
self.font_files[regular].family_relation = FamilyRelativeFontId::Regular;
self.font_files[bold].family_name = name.clone();
self.font_files[bold].family_name.clone_from(&name);
self.font_files[bold].family_relation = FamilyRelativeFontId::Bold;
self.font_files[italic].family_name = name.clone();
self.font_files[italic].family_name.clone_from(&name);
self.font_files[italic].family_relation = FamilyRelativeFontId::Italic;
self.font_files[bold_italic].family_name = name.clone();
self.font_files[bold_italic].family_name.clone_from(&name);
self.font_files[bold_italic].family_relation = FamilyRelativeFontId::BoldItalic;

self.font_families.insert(
Expand Down
4 changes: 2 additions & 2 deletions crates/engine_spx2html/src/initialization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,12 @@ impl InitializationState {
}

fn handle_set_template(&mut self, texpath: &str, _common: &mut Common) -> Result<()> {
self.next_template_path = texpath.to_owned();
texpath.clone_into(&mut self.next_template_path);
Ok(())
}

fn handle_set_output_path(&mut self, texpath: &str, _common: &mut Common) -> Result<()> {
self.next_output_path = texpath.to_owned();
texpath.clone_into(&mut self.next_output_path);
Ok(())
}

Expand Down
1 change: 1 addition & 0 deletions crates/engine_xetex/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ fn main() {
let profile_target_requires_frame_pointer: bool =
target_cfg!(not(all(target_os = "linux", target_arch = "x86_64")));

#[allow(unexpected_cfgs)]
const PROFILE_BUILD_ENABLED: bool = cfg!(feature = "profile");

let profile_config = |cfg: &mut cc::Build| {
Expand Down
8 changes: 4 additions & 4 deletions crates/io_base/src/digest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! Helpers to tidy up the computation of digests in various places.
use std::{
fs,
fmt, fs,
path::{Path, PathBuf},
str::FromStr,
};
Expand Down Expand Up @@ -103,9 +103,9 @@ impl DigestData {
}
}

impl ToString for DigestData {
fn to_string(&self) -> String {
bytes_to_hex(&self.0)
impl fmt::Display for DigestData {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}", bytes_to_hex(&self.0))
}
}

Expand Down
2 changes: 1 addition & 1 deletion crates/xdv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ impl<'a, T: XdvEvents> Cursor<'a, T> {
return Err(InternalError::NeedMoreData);
}

let rv = unsafe { mem::transmute(self.buf[0]) };
let rv = unsafe { mem::transmute::<u8, i8>(self.buf[0]) };
self.buf = &self.buf[1..];
self.offset += 1;
Ok(rv)
Expand Down
2 changes: 1 addition & 1 deletion crates/xetex_layout/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ fn main() {
let mut cppcfg = cc::Build::new();

let cppflags = [
"-std=c++14",
"-std=c++17",
"-Wall",
"-Wdate-time",
"-Wendif-labels",
Expand Down
2 changes: 1 addition & 1 deletion src/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ impl ProcessingSessionBuilder {
}
};

filesystem_root = parent.clone();
filesystem_root.clone_from(&parent);
let pio: Box<dyn IoProvider> = Box::new(FilesystemPrimaryInputIo::new(&p));
(pio, Some(p), parent)
}
Expand Down
2 changes: 1 addition & 1 deletion src/io/format_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl FormatCache {
let mut p = self.formats_base.clone();
p.push(format!(
"{}-{}-{}.fmt",
self.bundle_digest.to_string(),
self.bundle_digest,
stem,
crate::FORMAT_SERIAL
));
Expand Down
8 changes: 2 additions & 6 deletions tests/formats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,8 @@ fn test_format_generation(texname: &str, fmtname: &str, sha256: &str) {
let observed = info.write_digest.unwrap();

if observed != want_digest {
println!(
"expected {} to have SHA256 = {}",
fmtname,
want_digest.to_string()
);
println!("instead, got {}", observed.to_string());
println!("expected {} to have SHA256 = {}", fmtname, want_digest);
println!("instead, got {}", observed);
panic!();
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/util/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ impl<'a> ExpectedFile<'a> {
.unwrap_or_else(|| panic!("couldn't Unicode-ify file name of {:?}", pbase))
.replace(std::path::is_separator, "_");

let mut dec = GzDecoder::new(File::open(&pbase).unwrap());
let mut dec = GzDecoder::new(File::open(pbase.as_path()).unwrap());
let mut contents = Vec::new();
dec.read_to_end(&mut contents).unwrap();

Expand Down

0 comments on commit f392f76

Please sign in to comment.