From 36097423ac8b35b42f700e0b63e3b6ac44d88235 Mon Sep 17 00:00:00 2001 From: Ingo Schwarze Date: Fri, 30 Jan 2015 22:04:44 +0000 Subject: Have pity on the poor stack. Replace tail recursion by iteration when walking the syntax trees. No functional change. --- man_html.c | 9 +++++---- man_term.c | 10 +++++----- mdoc_html.c | 7 ++++--- mdoc_term.c | 7 ++++--- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/man_html.c b/man_html.c index 4898b652..9363f5ae 100644 --- a/man_html.c +++ b/man_html.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008-2012, 2014 Kristaps Dzonsons - * Copyright (c) 2013, 2014 Ingo Schwarze + * Copyright (c) 2013, 2014, 2015 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -192,9 +192,10 @@ static void print_man_nodelist(MAN_ARGS) { - print_man_node(man, n, mh, h); - if (n->next) - print_man_nodelist(man, n->next, mh, h); + while (n != NULL) { + print_man_node(man, n, mh, h); + n = n->next; + } } static void diff --git a/man_term.c b/man_term.c index 764ad016..8fe39774 100644 --- a/man_term.c +++ b/man_term.c @@ -1,7 +1,7 @@ /* $Id$ */ /* * Copyright (c) 2008-2012 Kristaps Dzonsons - * Copyright (c) 2010-2014 Ingo Schwarze + * Copyright (c) 2010-2015 Ingo Schwarze * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -1007,10 +1007,10 @@ static void print_man_nodelist(DECL_ARGS) { - print_man_node(p, mt, n, meta); - if ( ! n->next) - return; - print_man_nodelist(p, mt, n->next, meta); + while (n != NULL) { + print_man_node(p, mt, n, meta); + n = n->next; + } } static void diff --git a/mdoc_html.c b/mdoc_html.c index 6165050e..04729d15 100644 --- a/mdoc_html.c +++ b/mdoc_html.c @@ -371,9 +371,10 @@ static void print_mdoc_nodelist(MDOC_ARGS) { - print_mdoc_node(meta, n, h); - if (n->next) - print_mdoc_nodelist(meta, n->next, h); + while (n != NULL) { + print_mdoc_node(meta, n, h); + n = n->next; + } } static void diff --git a/mdoc_term.c b/mdoc_term.c index c96a9ead..2b6a8c73 100644 --- a/mdoc_term.c +++ b/mdoc_term.c @@ -291,9 +291,10 @@ static void print_mdoc_nodelist(DECL_ARGS) { - print_mdoc_node(p, pair, meta, n); - if (n->next) - print_mdoc_nodelist(p, pair, meta, n->next); + while (n != NULL) { + print_mdoc_node(p, pair, meta, n); + n = n->next; + } } static void -- cgit