From 0c1c99f07953970d1a160c4be407522f7775bd7f Mon Sep 17 00:00:00 2001 From: Derek Date: Tue, 8 Jun 2010 12:32:02 -0400 Subject: [PATCH] Fixed output of tag types c & C. Removed atoi() call. Simply casting the single byte to int works correctly. --- bamtools_convert.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/bamtools_convert.cpp b/bamtools_convert.cpp index e881d43..607c380 100644 --- a/bamtools_convert.cpp +++ b/bamtools_convert.cpp @@ -238,12 +238,12 @@ void BamTools::PrintJSON(ostream& out, const BamAlignment& a) { break; case('C') : - out << atoi(&tagData[index]); + out << (int)tagData[index]; ++index; break; case('c') : - out << atoi(&tagData[index]); + out << (int)tagData[index]; ++index; break; @@ -347,6 +347,7 @@ void BamTools::PrintSAM(ostream& out, const BamAlignment& a) { // write tag data const char* tagData = a.TagData.c_str(); const size_t tagDataLength = a.TagData.length(); + size_t index = 0; while ( index < tagDataLength ) { @@ -365,12 +366,12 @@ void BamTools::PrintSAM(ostream& out, const BamAlignment& a) { break; case('C') : - out << "i:" << atoi(&tagData[index]); + out << "i:" << (int)tagData[index]; ++index; break; case('c') : - out << "i:" << atoi(&tagData[index]); + out << "i:" << (int)tagData[index]; ++index; break; @@ -384,7 +385,7 @@ void BamTools::PrintSAM(ostream& out, const BamAlignment& a) { index += 2; break; - case('I') : + case('I') : out << "i:" << BgzfData::UnpackUnsignedInt(&tagData[index]); index += 4; break; @@ -414,7 +415,7 @@ void BamTools::PrintSAM(ostream& out, const BamAlignment& a) { ++index; break; } - + if ( tagData[index] == '\0') break; } -- 2.39.5