Skip to content

Commit

Permalink
Printing max_depth, re issue #351
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Oct 28, 2024
1 parent 6308b79 commit e9da175
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
10 changes: 5 additions & 5 deletions src/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ static bool print_term_to_buf_(query *q, cell *c, pl_idx c_ctx, int running, int
if (running) tmp = deref(q, tmp, tmp_ctx);
if (running) tmp_ctx = q->latest_ctx;

if (has_visited(visited, tmp, tmp_ctx)) {
if (q->is_dump_vars && has_visited(visited, tmp, tmp_ctx)) {
tmp = c;
tmp_ctx = c_ctx;
SB_sprintf(q->sb, "%s", !is_ref(tmp) ? C_STR(q, tmp) : "_");
Expand Down Expand Up @@ -1189,7 +1189,7 @@ static bool print_term_to_buf_(query *q, cell *c, pl_idx c_ctx, int running, int
if ((c->val_off == g_plus_s) && is_op_lhs) space = true;
if (isalpha(*src)) space = true;

if (has_visited(visited, lhs, lhs_ctx)) {
if (q->is_dump_vars && has_visited(visited, lhs, lhs_ctx)) {
if (q->is_dump_vars) {
SB_sprintf(q->sb, "%s", !is_ref(save_lhs) ? C_STR(q, save_lhs) : "_");
} else
Expand Down Expand Up @@ -1270,7 +1270,7 @@ static bool print_term_to_buf_(query *q, cell *c, pl_idx c_ctx, int running, int
else
q->last_thing = WAS_OTHER;

if (has_visited(visited, rhs, rhs_ctx)) {
if (q->is_dump_vars && has_visited(visited, rhs, rhs_ctx)) {
if (q->is_dump_vars) {
SB_sprintf(q->sb, "%s", !is_ref(save_rhs) ? C_STR(q, save_rhs) : "_");
} else
Expand Down Expand Up @@ -1344,7 +1344,7 @@ static bool print_term_to_buf_(query *q, cell *c, pl_idx c_ctx, int running, int
if (q->last_thing != WAS_SPACE) SB_sprintf(q->sb, "%s", " ");
SB_sprintf(q->sb, "%s", "...");
q->last_thing = WAS_SYMBOL;
} else if (has_visited(visited, lhs, lhs_ctx)) {
} else if (q->is_dump_vars && has_visited(visited, lhs, lhs_ctx)) {
if (q->is_dump_vars) {
SB_sprintf(q->sb, "%s", !is_ref(save_lhs) ? C_STR(q, save_lhs) : "_");
} else
Expand Down Expand Up @@ -1464,7 +1464,7 @@ static bool print_term_to_buf_(query *q, cell *c, pl_idx c_ctx, int running, int
if (q->last_thing != WAS_SPACE) SB_sprintf(q->sb, "%s", " ");
SB_sprintf(q->sb, "%s", "...");
q->last_thing = WAS_SYMBOL;
} else if (has_visited(visited, rhs, rhs_ctx)) {
} else if (q->is_dump_vars && has_visited(visited, rhs, rhs_ctx)) {
if (q->is_dump_vars) {
SB_sprintf(q->sb, "%s", !is_ref(save_rhs) ? C_STR(q, save_rhs) : "_");
} else
Expand Down
2 changes: 1 addition & 1 deletion tests/issues-OLD/test031.expected
Original file line number Diff line number Diff line change
@@ -1 +1 @@
f(X)
f(f(f(f(f(...)))))
2 changes: 1 addition & 1 deletion tests/issues-OLD/test031.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

main :-
X = f(X), X == X,
writeq(X), nl.
write_term(X,[max_depth(5)]), nl.
2 changes: 1 addition & 1 deletion tests/tests/test098.expected
Original file line number Diff line number Diff line change
@@ -1 +1 @@
_4*_3
_4*(_4*(_4*(_4*(_4* ...))))
2 changes: 1 addition & 1 deletion tests/tests/test098.pl
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

main :-
dif([],A), A=_*A,
write(A), nl.
write_term(A,[max_depth(5)]), nl.

0 comments on commit e9da175

Please sign in to comment.