aboutsummaryrefslogtreecommitdiff
path: root/src/libbio
diff options
context:
space:
mode:
Diffstat (limited to 'src/libbio')
-rw-r--r--src/libbio/fasta.c9
-rw-r--r--src/libbio/newick.c16
-rw-r--r--src/libbio/phylo.c14
3 files changed, 19 insertions, 20 deletions
diff --git a/src/libbio/fasta.c b/src/libbio/fasta.c
index eb0d090..e6f0dd3 100644
--- a/src/libbio/fasta.c
+++ b/src/libbio/fasta.c
@@ -45,7 +45,7 @@ grow(struct SeqBuf **sb, int min)
return 1;
}
- memcpy(new, old, sizeof(*new) + (*sb)->cap);
+ mem·copy(new, sizeof(*new) + (*sb)->cap, old);
new->cap = newcap;
new->it = new->b + (old->it - old->b);
@@ -96,7 +96,7 @@ push(struct SeqBuf **sb, int n, void *buf)
}
seq = *sb;
- memcpy(seq->it, buf, n);
+ mem·copy(seq->it, n, buf);
seq->it += n;
return 0;
@@ -184,8 +184,7 @@ bio·closeseq(bio·SeqReader *rdr)
}
-static
-int
+static int
readfasta(bio·SeqReader *rdr, bio·Seq *seq, byte hdr, byte stop)
{
int err;
@@ -375,7 +374,7 @@ bio·writefasta(io·Writer io, void *wtr, bio·Seq seq)
b = buf;
}
*b++ = '\n';
- memcpy(b, seq.s+i, d);
+ mem·copy(b, d, seq.s+i);
b += d;
}
diff --git a/src/libbio/newick.c b/src/libbio/newick.c
index a855cea..a555379 100644
--- a/src/libbio/newick.c
+++ b/src/libbio/newick.c
@@ -50,8 +50,8 @@ tokstr(struct Token tok)
case tok·comma: return ",";
case tok·semi: return ";";
case tok·colon: return ":";
- case tok·number:
- snprintf(b, arrlen(b), "%f", tok.lit.x);
+ case tok·number:
+ fmt·nsprint(b, arrlen(b), "%f", tok.lit.x);
return b;
default:
return nil;
@@ -80,8 +80,8 @@ lex(io·Peeker s, void* fp)
c = b;
*c = s.get(fp);
- if (isspace(*c)) {
- while (isspace(*c)) {
+ if(utf8·isspace(*c)){
+ while(utf8·isspace(*c)){
*(++c) = s.get(fp);
}
@@ -107,7 +107,7 @@ lex(io·Peeker s, void* fp)
case '.':
case '0': case '1': case '2': case '3': case '4':
case '5': case '6': case '7': case '8': case '9':
- while (isdigit(*c)) {
+ while(utf8·isdigit(*c)){
NUM: *(++c) = s.get(fp);
}
if (*c == '.') goto NUM;
@@ -194,7 +194,7 @@ parse(struct Parser *p)
}
node = p->mem.alloc(p->heap, 1, sizeof(*node));
- memset(node, 0, sizeof(*node));
+ mem·set(node, sizeof(*node), 0);
if (p->root) {
phylo·addchild(p->root, node);
@@ -281,7 +281,7 @@ parse(struct Parser *p)
}
node = p->mem.alloc(p->heap, 1, sizeof(*node));
- memset(node, 0, sizeof(*node));
+ mem·set(node, sizeof(*node), 0);
node->name = string·make(tok.lit.s);
@@ -396,7 +396,7 @@ dump(bio·Node *node, void *impl, io·Putter out)
if (node->parent) {
out.put(impl, ':');
- snprintf(b, arrlen(b), "%f", node->dist);
+ fmt·nsprint(b, arrlen(b), "%f", node->dist);
out.puts(impl, b);
}
diff --git a/src/libbio/phylo.c b/src/libbio/phylo.c
index 41b0f04..1b0ae59 100644
--- a/src/libbio/phylo.c
+++ b/src/libbio/phylo.c
@@ -328,11 +328,11 @@ phylo·diameter(bio·Tree tree, int *len, bio·Node **path)
sort·nodedists(n, fbuf, nbuf);
path[0] = nbuf[n-1];
- printf("first end '%s'\n", path[0]->name);
+ fmt·print("first end '%s'\n", path[0]->name);
n = phylo·getdistsfrom(path[0], n, fbuf, nbuf);
sort·nodedists(n, fbuf, nbuf);
- printf("second end '%s'\n", nbuf[n-1]->name);
+ fmt·print("second end '%s'\n", nbuf[n-1]->name);
*len = 0;
@@ -393,17 +393,17 @@ phylo·reroot(bio·Tree *tree, bio·Node *node, double d)
// TODO: should check that node is part of this tree?
// TODO: should we check if node->parent != nil?
- if (fabs(d) < PREC) {
+ if(fabs(d) < PREC){
new = node;
rotateparent(node->parent, node);
- } else if (fabs(d-node->dist) < PREC) {
+ }else if(fabs(d-node->dist) < PREC){
new = node->parent;
if (new->parent->parent) {
rotateparent(new->parent->parent, new->parent);
}
- } else {
+ }else{
new = tree->mem.alloc(tree->heap, 1, sizeof(*new));
- memset(new, 0, sizeof(*new));
+ mem·set(new, sizeof(*new), 0);
phylo·addchild(new, node);
node->parent = new;
@@ -415,7 +415,7 @@ phylo·reroot(bio·Tree *tree, bio·Node *node, double d)
node->parent->parent = new;
}
- printf("number of children on old root: %d\n", tree->root->nchild);
+ fmt·print("number of children on old root: %d\n", tree->root->nchild);
tree->root = new;
tree->nleaf = 0;