From 81987141907a72297b873daed9ebe0254ab4c9c6 Mon Sep 17 00:00:00 2001 From: Greg Burd Date: Sat, 23 Mar 2024 21:01:39 -0400 Subject: [PATCH] dot, pt done. --- include/sl.h | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/include/sl.h b/include/sl.h index b06058e..789ff0c 100644 --- a/include/sl.h +++ b/include/sl.h @@ -1425,18 +1425,15 @@ /* -- __skip_dot_node_ \ * Writes out a fragment of a DOT file representing a node. \ */ \ - static size_t __skip_dot_width_##decl(decl##_t *slist, decl##_node_t *node, size_t level) \ + static size_t __skip_dot_width_##decl(decl##_t *slist, decl##_node_t *from, decl##_node_t *to) \ { \ size_t w = 1; \ - decl##_node_t *n; \ + decl##_node_t *n = to; \ \ - if (node == slist->slh_tail) \ + if (from == NULL || to == NULL) \ return 0; \ - if (node == NULL) \ - node = slist->slh_tail; \ \ - n = node->field.sle.next[level] == slist->slh_tail ? NULL : node->field.sle.next[level]; \ - while (n && n->field.sle.prev != node) { \ + while (n->field.sle.prev != from) { \ w++; \ n = prefix##skip_prev_node_##decl(slist, n); \ } \ @@ -1467,7 +1464,7 @@ __SKIP_NEXT_ENTRIES_T2B(field, node) \ { \ next = (node->field.sle.next[lvl] == slist->slh_tail) ? NULL : node->field.sle.next[lvl]; \ - width = __skip_dot_width_##decl(slist, (next == NULL ? node : next), lvl); \ + width = __skip_dot_width_##decl(slist, node, next ? next : slist->slh_tail); \ fprintf(os, " { %zu | ", lvl, width, lvl); \ if (next) \ fprintf(os, "%p } |", (void *)next); \ @@ -1477,7 +1474,7 @@ } \ if (fn) { \ fn(node, buf); \ - fprintf(os, " \u219F %zu \u226B %s \"\n", node->field.sle.height, buf); \ + fprintf(os, " \u219F %zu \u226B %s \"\n", node->field.sle.height, buf); \ } else { \ fprintf(os, " \u219F %zu \"\n", node->field.sle.height); \ } \ @@ -1542,7 +1539,7 @@ int prefix##skip_dot_##decl(FILE *os, decl##_t *slist, size_t nsg, skip_sprintf_node_##decl##_t fn) \ { \ int letitgo = 0; \ - size_t width = 0, i; \ + size_t width, i; \ decl##_node_t *node, *next; \ \ if (slist == NULL || fn == NULL) \ @@ -1573,10 +1570,7 @@ __SKIP_NEXT_ENTRIES_T2B(field, node) \ { \ next = (node->field.sle.next[lvl] == slist->slh_tail) ? NULL : node->field.sle.next[lvl]; \ - if (next) \ - width = __skip_dot_width_##decl(slist, (next == NULL ? node : next), lvl); \ - else \ - width = __skip_dot_width_##decl(slist, node, lvl); \ + width = __skip_dot_width_##decl(slist, node, next ? next : slist->slh_tail); \ fprintf(os, "{ %zu | ", width, lvl); \ if (next) \ fprintf(os, "%p }", (void *)next); \ @@ -1626,8 +1620,8 @@ __skip_dot_write_node_##decl(os, nsg, NULL); \ fprintf(os, " [label = \""); \ node = slist->slh_tail; \ - size_t th = slist->slh_head->field.sle.height == slist->max ? slist->max : slist->slh_head->field.sle.height + 1; \ - for (size_t lvl = th; lvl != (size_t)-1; lvl--) { \ + size_t th = slist->slh_head->field.sle.height == slist->max ? slist->max : slist->slh_head->field.sle.height + 1; \ + for (size_t lvl = th; lvl != (size_t)-1; lvl--) { \ next = (node->field.sle.next[lvl] == slist->slh_tail) ? NULL : node->field.sle.next[lvl]; \ fprintf(os, " NULL", lvl); \ __SKIP_IS_LAST_ENTRY_T2B() continue; \