]> git.donarmstrong.com Git - samtools.git/blobdiff - kstring.h
Incoporated changes from Nils Homer.
[samtools.git] / kstring.h
index 89a7920c646fd6df2dc773250b7a0f5f1195ccec..d490f58d4f1c93fc722a0d8b3d3f5b967624cfe7 100644 (file)
--- a/kstring.h
+++ b/kstring.h
@@ -112,7 +112,8 @@ static inline int kputw(int c, kstring_t *s)
        char buf[16];
        int l, x;
        if (c == 0) return kputc('0', s);
-       for (l = 0, x = c < 0? -c : c; x > 0; x /= 10) buf[l++] = x%10 + '0';
+        if(c < 0) for (l = 0, x = c; x < 0; x /= 10) buf[l++] = '0' - (x%10);
+        else for (l = 0, x = c; x > 0; x /= 10) buf[l++] = x%10 + '0';
        if (c < 0) buf[l++] = '-';
        if (s->l + l + 1 >= s->m) {
                s->m = s->l + l + 2;