Skip to content

Commit

Permalink
s/t/bamtools_filter.cpp: simplify GetScriptContents().
Browse files Browse the repository at this point in the history
Closes: #238
  • Loading branch information
vpa1977 authored and SoapZA committed Jul 12, 2024
1 parent 1ce1d52 commit 636ee0f
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/toolkit/bamtools_filter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,22 +540,18 @@ const std::string FilterTool::FilterToolPrivate::GetScriptContents()
// read in entire script contents
char buffer[1024];
std::ostringstream docStream;
while (true) {

// peek ahead, make sure there is data available
char ch = fgetc(inFile);
ungetc(ch, inFile);
if (feof(inFile)) {
while (!feof(inFile)) {
// read next block of data
const char* data = fgets(buffer, sizeof(buffer), inFile);
if (!data) {
break;
}

// read next block of data
if (fgets(buffer, 1024, inFile) == 0) {
if (ferror(inFile)) {
std::cerr << "bamtools filter ERROR: could not read script contents" << std::endl;
return std::string();
return {};
}

docStream << buffer;
docStream << data;
}

// close script file
Expand Down

0 comments on commit 636ee0f

Please sign in to comment.