]> git.kaiwu.me - klib.git/commitdiff
Fixed output bug where branch length is not printed on branches to leaf nodes
authorIan Holmes <github@yam.biowiki.org>
Fri, 26 Jun 2015 18:21:26 +0000 (14:21 -0400)
committerIan Holmes <github@yam.biowiki.org>
Fri, 26 Jun 2015 18:21:26 +0000 (14:21 -0400)
knhx.c

diff --git a/knhx.c b/knhx.c
index 8dbd3b6e35b4f47703dfc248a3fbf3ae45252818..7448e468035f65aaf9af4036bbcc279bcda7cab1 100644 (file)
--- a/knhx.c
+++ b/knhx.c
@@ -133,7 +133,13 @@ static void format_node_recur(const knhx1_t *node, const knhx1_t *p, kstring_t *
                        sprintf(numbuf, ":%g", p->d);
                        kputsn(numbuf, strlen(numbuf), s);
                }
-       } else kputsn(p->name, strlen(p->name), s);
+       } else {
+         kputsn(p->name, strlen(p->name), s);
+         if (p->d >= 0) {
+           sprintf(numbuf, ":%g", p->d);
+           kputsn(numbuf, strlen(numbuf), s);
+         }
+       }
 }
 
 void kn_format(const knhx1_t *node, int root, kstring_t *s) // TODO: get rid of recursion