From: Derek Date: Tue, 8 Jun 2010 16:32:02 +0000 (-0400) Subject: Fixed output of tag types c & C. Removed atoi() call. Simply casting the single byte... X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=0c1c99f07953970d1a160c4be407522f7775bd7f;p=bamtools.git Fixed output of tag types c & C. Removed atoi() call. Simply casting the single byte to int works correctly. --- 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; }