Skip to content

Commit 3febd59

Browse files
committed
src/io/memory.rs: allow \openin of \openout files to succeed
This is a workaround to get `hyperxmp` working. I think that it should generally be OK and not cause issues. Closes #862.
1 parent cbd96ec commit 3febd59

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/io/memory.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,18 @@ impl IoProvider for MemoryIo {
183183

184184
let name = normalize_tex_path(name);
185185

186-
OpenResult::Ok(OutputHandle::new(
187-
name.to_owned(),
188-
MemoryIoItem::new(&self.files, &name, true),
189-
))
186+
let oh = OutputHandle::new(name.to_owned(), MemoryIoItem::new(&self.files, &name, true));
187+
188+
// `hyperxmp.sty` does a thing where it tries to get today's date by
189+
// calling \filemoddate on `\jobname.log`. That essentially relies on it
190+
// being possible to \openin an \openout file that hasn't yet been
191+
// closed. I think that it's reasonable to allow that, if we just
192+
// provide null data and don't try to support intermixed reads and
193+
// writes. We have to do this after creating the MemoryIoItem since that
194+
// step removes any preexisting entry from the table of files.
195+
self.create_entry(&name, Vec::new());
196+
197+
OpenResult::Ok(oh)
190198
}
191199

192200
fn output_open_stdout(&mut self) -> OpenResult<OutputHandle> {

0 commit comments

Comments
 (0)