correct get_byte/1 not emitted -1 upon discovery of end_of_stream position (#555)

This commit is contained in:
Mark Thom
2020-05-22 14:50:40 -06:00
parent 9e9c3b6342
commit b2d720b853

View File

@@ -2166,6 +2166,13 @@ impl MachineState {
)?; )?;
if stream.past_end_of_stream() { if stream.past_end_of_stream() {
self.eof_action(
self[temp_v!(2)],
&mut stream,
clause_name!("get_byte"),
2,
)?;
if EOFAction::Reset != stream.options.eof_action { if EOFAction::Reset != stream.options.eof_action {
return return_from_clause!(self.last_call, self); return return_from_clause!(self.last_call, self);
} else if self.fail { } else if self.fail {
@@ -2173,12 +2180,6 @@ impl MachineState {
} }
} }
if stream.at_end_of_stream() {
stream.set_past_end_of_stream();
self.unify(self[temp_v!(2)], Addr::Fixnum(-1));
return return_from_clause!(self.last_call, self);
}
let addr = let addr =
match self.store(self.deref(self[temp_v!(2)])) { match self.store(self.deref(self[temp_v!(2)])) {
addr if addr.is_ref() => { addr if addr.is_ref() => {
@@ -2238,18 +2239,9 @@ impl MachineState {
} }
} }
_ => { _ => {
self.eof_action( stream.set_past_end_of_stream();
self[temp_v!(2)], self.unify(self[temp_v!(2)], Addr::Fixnum(-1));
&mut stream, return return_from_clause!(self.last_call, self);
clause_name!("get_byte"),
2,
)?;
if EOFAction::Reset != stream.options.eof_action {
return return_from_clause!(self.last_call, self);
} else if self.fail {
return Ok(());
}
} }
} }
} }