From 13a7326f9008687ff6eeb76f9eb3233dc8c743a4 Mon Sep 17 00:00:00 2001
From: On behalf of John Marshall <lh3@sanger.ac.uk>
Date: Tue, 24 Nov 2009 14:45:35 +0000
Subject: [PATCH] Format 'c'-encoded auxiliary fields correctly, as *signed*
 integers.

---
 bam.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/bam.c b/bam.c
index ee7642b..56c95db 100644
--- a/bam.c
+++ b/bam.c
@@ -268,7 +268,7 @@ char *bam_format1_core(const bam_header_t *header, const bam1_t *b, int of)
 		ksprintf(&str, "\t%c%c:", key[0], key[1]);
 		if (type == 'A') { ksprintf(&str, "A:%c", *s); ++s; }
 		else if (type == 'C') { ksprintf(&str, "i:%u", *s); ++s; }
-		else if (type == 'c') { ksprintf(&str, "i:%d", *s); ++s; }
+		else if (type == 'c') { ksprintf(&str, "i:%d", *(int8_t*)s); ++s; }
 		else if (type == 'S') { ksprintf(&str, "i:%u", *(uint16_t*)s); s += 2; }
 		else if (type == 's') { ksprintf(&str, "i:%d", *(int16_t*)s); s += 2; }
 		else if (type == 'I') { ksprintf(&str, "i:%u", *(uint32_t*)s); s += 4; }
-- 
2.39.5