fix printing of CStr's

This commit is contained in:
Mark Thom
2021-12-09 18:15:52 -07:00
parent 520121b2b2
commit 6c66c236fb
2 changed files with 9 additions and 15 deletions

View File

@@ -833,13 +833,6 @@ impl PredicateSkeleton {
} }
} }
#[inline]
pub(crate) fn reset(&mut self) {
self.core.clause_clause_locs.clear();
self.core.clause_assert_margin = 0;
self.clauses.clear();
}
pub(crate) fn target_pos_of_clause_clause_loc( pub(crate) fn target_pos_of_clause_clause_loc(
&self, &self,
clause_clause_loc: usize, clause_clause_loc: usize,

View File

@@ -1125,8 +1125,11 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
return self.push_list(max_depth); return self.push_list(max_depth);
} }
// let end_h = heap_pstr_iter.focus();
// let end_cell = self.iter.heap[end_h];
let end_h = heap_pstr_iter.focus(); let end_h = heap_pstr_iter.focus();
let end_cell = self.iter.heap[end_h]; let end_cell = heap_pstr_iter.focus;
self.remove_list_children(focus); self.remove_list_children(focus);
@@ -1142,8 +1145,8 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
} }
if self.ignore_ops { if self.ignore_ops {
if !self.print_string_as_functor(end_h, max_depth) { if !self.print_string_as_functor(focus, max_depth) {
if end_cell.get_tag() == HeapCellValueTag::CStr { if end_cell == empty_list_as_cell!() { // end_cell.get_tag() == HeapCellValueTag::CStr {
append_str!(self, "[]"); append_str!(self, "[]");
} else { } else {
if self.outputter.ends_with(",") { if self.outputter.ends_with(",") {
@@ -1182,21 +1185,19 @@ impl<'a, Outputter: HCValueOutputter> HCPrinter<'a, Outputter> {
if self.max_depth > 0 && iter.next().is_some() { if self.max_depth > 0 && iter.next().is_some() {
self.state_stack.push(TokenOrRedirect::Atom(atom!("..."))); self.state_stack.push(TokenOrRedirect::Atom(atom!("...")));
self.state_stack.push(TokenOrRedirect::HeadTailSeparator);
} else { } else {
if iter.cycle_detected() { if iter.cycle_detected() {
self.iter.heap[end_h].set_forwarding_bit(true); self.iter.heap[end_h].set_forwarding_bit(true);
} }
if end_cell.get_tag() == HeapCellValueTag::CStr { if end_cell != empty_list_as_cell!() {
self.state_stack.push(TokenOrRedirect::Atom(atom!("[]")));
} else {
self.state_stack.push(TokenOrRedirect::FunctorRedirect(max_depth)); self.state_stack.push(TokenOrRedirect::FunctorRedirect(max_depth));
self.state_stack.push(TokenOrRedirect::HeadTailSeparator);
self.iter.push_stack(end_h); self.iter.push_stack(end_h);
} }
} }
self.state_stack.push(TokenOrRedirect::HeadTailSeparator);
if self.outputter.ends_with(",") { if self.outputter.ends_with(",") {
self.outputter.truncate(self.outputter.len() - ','.len_utf8()); self.outputter.truncate(self.outputter.len() - ','.len_utf8());
} }