tttm

git clone https://orangeshoelaces.net/git/tttm.git

9ef281f5f9576e062e5606d94bcfb136f9fe9634

Author: Vasily Kolobkov on 05/03/2016

Committer: Vasily Kolobkov on 05/03/2016

Fix child iteration when printing interior nodes

Stats

pshades.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

Patch

diff --git a/pshades.c b/pshades.c
index cf47366..8c667b1 100644
--- a/pshades.c
+++ b/pshades.c
@@ -94,14 +94,14 @@ void
 ptprint(union parse_node *n, size_t depth)
 {
 	static char *prefix = "               >";
-	size_t l;
+	size_t nend;
 
 	printf("%.*s", (int)depth, prefix);
 
 	switch (n->type) {
 	case PN_INTER:
 		printf("%s\n", prod[n->inter.prod]);
-		for (l = n->inter.len, n++; l > 0; l--, n = ptnext(n))
+		for (nend = n + n->inter.len + 1, n++; n < nend; n = ptnext(n))
 			ptprint(n, depth + 1);
 		break;
 	case PN_LIT: