Skip to content

Commit

Permalink
Work on write option max_depth (re GNU Prolog issue #56), re issue #250
Browse files Browse the repository at this point in the history
  • Loading branch information
infradig committed Jul 10, 2023
1 parent 08c01be commit 849ea8f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/print.c
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,15 @@ ssize_t print_term_to_buf(query *q, char *dst, size_t dstlen, cell *c, pl_idx c_
{
char *save_dst = dst;

if (q->max_depth && (depth >= q->max_depth)) {
if (cons) dst += snprintf(dst, dstlen, "[");
dst += snprintf(dst, dstlen, "...");
if (cons) dst += snprintf(dst, dstlen, "]");
q->last_thing_was_symbol = false;
q->was_space = false;
return dst - save_dst;
}

if (depth > MAX_DEPTH) {
q->cycle_error = true;
q->last_thing_was_symbol = false;
Expand Down

0 comments on commit 849ea8f

Please sign in to comment.