Skip to content

Commit

Permalink
resolve Cargo.lock differences
Browse files Browse the repository at this point in the history
  • Loading branch information
Eli Flanagan committed Sep 12, 2019
2 parents 2097cff + c7e2589 commit da44f56
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 71 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/tests/plain.fmt
/tests/00*00-latex-*.fmt
/tests/00*00-plain-*.fmt
/tests/xenia/paper.pdf

# ignore mdbook compiled output (HTML)
docs/book/*
124 changes: 62 additions & 62 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ crate-type = ["rlib"]
[build-dependencies]
cc = "^1.0"
pkg-config = "^0.3" # note: sync dist/docker/*/pkg-config-rs.sh with the version in Cargo.lock
regex = "^1.1"
regex = "^1.3"
sha2 = "^0.8"
vcpkg = "0.2.7"

Expand Down
2 changes: 1 addition & 1 deletion src/io/cached_itarbundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -680,7 +680,7 @@ impl IoProvider for CachedITarBundle {
Err(e) => return OpenResult::Err(e.into()),
};

OpenResult::Ok(InputHandle::new(
OpenResult::Ok(InputHandle::new_read_only(
name,
BufReader::new(f),
InputOrigin::Other,
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 @@ -84,7 +84,7 @@ impl IoProvider for FormatCache {
OpenResult::Err(e) => return OpenResult::Err(e),
};

OpenResult::Ok(InputHandle::new(
OpenResult::Ok(InputHandle::new_read_only(
name,
BufReader::new(f),
InputOrigin::Other,
Expand Down
32 changes: 27 additions & 5 deletions src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,12 @@ pub enum InputOrigin {
/// computation. The `ExecutionState` code then has further pieces that track
/// access to nonexistent files, which we treat as being equivalent to an
/// existing empty file for these purposes.
pub struct InputHandle {
name: OsString,
inner: Box<dyn InputFeatures>,
/// Indicates that the file cannot be written to (provided by a read-only IoProvider) and
/// therefore it is useless to compute the digest.
read_only: bool,
digest: digest::DigestComputer,
origin: InputOrigin,
ever_read: bool,
Expand All @@ -91,6 +93,24 @@ impl InputHandle {
InputHandle {
name: name.to_os_string(),
inner: Box::new(inner),
read_only: false,
digest: Default::default(),
origin,
ever_read: false,
did_unhandled_seek: false,
ungetc_char: None,
}
}

pub fn new_read_only<T: 'static + InputFeatures>(
name: &OsStr,
inner: T,
origin: InputOrigin,
) -> InputHandle {
InputHandle {
name: name.to_os_string(),
inner: Box::new(inner),
read_only: true,
digest: Default::default(),
origin,
ever_read: false,
Expand All @@ -114,13 +134,13 @@ impl InputHandle {
}

/// Consumes the object and returns the SHA256 sum of the content that was
/// written. No digest is returned if there was ever a seek on the input
/// read. No digest is returned if there was ever a seek on the input
/// stream, since in that case the results will not be reliable. We also
/// return None if the stream was never read, which is another common
/// TeX access pattern: files are opened, immediately closed, and then
/// opened again.
/// opened again. Finally, no digest is returned if the file is marked read-only.
pub fn into_name_digest(self) -> (OsString, Option<DigestData>) {
if self.did_unhandled_seek || !self.ever_read {
if self.did_unhandled_seek || !self.ever_read || self.read_only {
(self.name, None)
} else {
(self.name, Some(DigestData::from(self.digest)))
Expand Down Expand Up @@ -174,7 +194,9 @@ impl Read for InputHandle {

self.ever_read = true;
let n = self.inner.read(buf)?;
self.digest.input(&buf[..n]);
if !self.read_only {
self.digest.input(&buf[..n]);
}
Ok(n)
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/io/zipbundle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ impl<R: Read + Seek> IoProvider for ZipBundle<R> {
return OpenResult::Err(e.into());
}

OpenResult::Ok(InputHandle::new(name, Cursor::new(buf), InputOrigin::Other))
OpenResult::Ok(InputHandle::new_read_only(
name,
Cursor::new(buf),
InputOrigin::Other,
))
}
}

Expand Down

0 comments on commit da44f56

Please sign in to comment.