Skip to content

Commit

Permalink
main.cpp: Add snprintf code in similar code section
Browse files Browse the repository at this point in the history
Introduce snprintf & LINEBUFFSIZE in similar section for
'single-read alignments'. This should make the code a bit
cleaner.
  • Loading branch information
thomas committed Oct 9, 2017
1 parent 3a1d8ff commit 2f18c2c
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,20 @@ void RunProcess(void) {
}

if(param.out_sam&&param.sam_header) {
char _ch[1000];
char _ch[LINEBUFFSIZE];
int ret_len;
for(bit32_t i=0;i<ref.total_num;i++) {
sprintf(_ch,"@SQ\tSN:%s\tLN:%u\n",ref.title[i<<1].name.c_str(),ref.title[i<<1].size);
ret_len=snprintf(_ch,LINEBUFFSIZE,"@SQ\tSN:%s\tLN:%u\n",ref.title[i<<1].name.c_str(),ref.title[i<<1].size);
if (ret_len>=LINEBUFFSIZE) {
cerr<<"Buffer error, output was truncated (increase LINEBUFFSIZE in main.cpp and recompile)."<<endl;
}
_str.append(_ch);
}
sprintf(_ch,"@PG\tID:BSMAP\tVN:%s\tCL:\"%s\"\n",version,command_line.c_str()); _str.append(_ch);
ret_len=snprintf(_ch,LINEBUFFSIZE,"@PG\tID:BSMAP\tVN:%s\tCL:\"%s\"\n",version,command_line.c_str());
if (ret_len>=LINEBUFFSIZE) {
cerr<<"Buffer error, output was truncated (increase LINEBUFFSIZE in main.cpp and recompile)."<<endl;
}
_str.append(_ch);
if(param.stdout) cout<< _str;
else if(param.pipe_out) fwrite(_str.c_str(),1,_str.size(),pout);
else fout<<_str;
Expand Down

0 comments on commit 2f18c2c

Please sign in to comment.