aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-01-30 22:04:44 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-01-30 22:04:44 +0000
commit6c75cc18099b6c7db33c10df54276a2baeb97ae3 (patch)
treeb4d1367dfc138708b28bf0bae0825f3164794c63
parent9fef7fa26fe9bba13379da3ae726ddf95631de22 (diff)
downloadmandoc-6c75cc18099b6c7db33c10df54276a2baeb97ae3.tar.gz
mandoc-6c75cc18099b6c7db33c10df54276a2baeb97ae3.tar.zst
mandoc-6c75cc18099b6c7db33c10df54276a2baeb97ae3.zip
Have pity on the poor stack.
Replace tail recursion by iteration when walking the syntax trees. No functional change.
-rw-r--r--man_html.c11
-rw-r--r--man_term.c12
-rw-r--r--mdoc_html.c9
-rw-r--r--mdoc_term.c9
4 files changed, 22 insertions, 19 deletions
diff --git a/man_html.c b/man_html.c
index 5b772ed3..a6a661fa 100644
--- a/man_html.c
+++ b/man_html.c
@@ -1,7 +1,7 @@
-/* $Id: man_html.c,v 1.109 2015/01/24 02:41:49 schwarze Exp $ */
+/* $Id: man_html.c,v 1.110 2015/01/30 22:04:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2013, 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
*
* 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 830f82cb..ab75851f 100644
--- a/man_term.c
+++ b/man_term.c
@@ -1,7 +1,7 @@
-/* $Id: man_term.c,v 1.167 2015/01/30 17:32:16 schwarze Exp $ */
+/* $Id: man_term.c,v 1.168 2015/01/30 22:04:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2012 Kristaps Dzonsons <kristaps@bsd.lv>
- * Copyright (c) 2010-2014 Ingo Schwarze <schwarze@openbsd.org>
+ * Copyright (c) 2010-2015 Ingo Schwarze <schwarze@openbsd.org>
*
* 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 f7ce59e8..337e5dba 100644
--- a/mdoc_html.c
+++ b/mdoc_html.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_html.c,v 1.219 2015/01/23 14:21:01 schwarze Exp $ */
+/* $Id: mdoc_html.c,v 1.220 2015/01/30 22:04:44 schwarze Exp $ */
/*
* Copyright (c) 2008-2011, 2014 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2014, 2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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 a7058f8e..3d9b9fea 100644
--- a/mdoc_term.c
+++ b/mdoc_term.c
@@ -1,4 +1,4 @@
-/* $Id: mdoc_term.c,v 1.303 2015/01/23 14:21:01 schwarze Exp $ */
+/* $Id: mdoc_term.c,v 1.304 2015/01/30 22:04:44 schwarze Exp $ */
/*
* Copyright (c) 2008, 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2010, 2012-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -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