don't allow [] as a stream alias, restore domain error on source sink for open/{3,4}

This commit is contained in:
Mark Thom
2021-11-28 14:53:39 -07:00
parent a87236fea2
commit 529c401eee
2 changed files with 16 additions and 3 deletions

View File

@@ -2977,8 +2977,16 @@ impl MachineState {
let options = self.to_stream_options(alias, eof_action, reposition, stream_type);
let src_sink = self.store(self.deref(self.registers[1]));
if let Some(atom_or_string) = self.value_to_str_like(src_sink) {
let file_spec = self.atom_tbl.build_with(atom_or_string.as_str());
if let Some(str_like) = self.value_to_str_like(src_sink) {
let file_spec = match str_like {
AtomOrString::Atom(atom) => {
atom
}
AtomOrString::String(string) => {
self.atom_tbl.build_with(&string)
}
};
let mut stream = self.stream_from_file_spec(file_spec, indices, &options)?;
*stream.options_mut() = options;