[Genabel-commits] r1392 - pkg/ProbABEL/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Mon Nov 18 21:33:23 CET 2013
Author: lckarssen
Date: 2013-11-18 21:33:22 +0100 (Mon, 18 Nov 2013)
New Revision: 1392
Modified:
pkg/ProbABEL/src/data.cpp
Log:
- Fixed some cpplint violations that showed up in Jenkins.
- Also changed the way the arrays line and tmp are created in lines 147/148. Officially C++ doesn't allow variable size arrays (although GCC normally allows this, unless the -pedantic CPPFLAG is used).
Modified: pkg/ProbABEL/src/data.cpp
===================================================================
--- pkg/ProbABEL/src/data.cpp 2013-11-18 15:41:47 UTC (rev 1391)
+++ pkg/ProbABEL/src/data.cpp 2013-11-18 20:33:22 UTC (rev 1392)
@@ -88,8 +88,7 @@
nlin++;
}
nlin--; // Subtract one, the previous loop added 1 too much
- } else
- {
+ } else {
std::cerr << "mlinfo: cannot open info file " << filename << endl;
exit(1);
}
@@ -100,7 +99,7 @@
std::cerr << "mlinfo: number of columns != 7 in " << filename << endl;
exit(1);
}
- nsnps = int(nlin / 7) - 1;
+ nsnps = static_cast<int>((nlin / 7) - 1);
std::cout << "Number of SNPs = " << nsnps << endl;
name = new std::string[nsnps];
A1 = new std::string[nsnps];
@@ -145,20 +144,28 @@
{
std::ifstream instr(mapname);
int BFS = 1048576;
- char line[BFS], tmp[BFS];
+ char *line = new char[BFS];
+ char *tmp = new char[BFS];
+
if (!instr.is_open())
{
std::cerr << "mlinfo: cannot open map file " << mapname << endl;
exit(1);
}
+
instr.getline(line, BFS);
+
for (int i = 0; i < nsnps; i++)
{
instr.getline(line, BFS);
std::stringstream line_stream(line);
line_stream >> tmp >> map[i];
}
+
instr.close();
+
+ delete[] line;
+ delete[] tmp;
}
}
@@ -223,8 +230,7 @@
row++;
}
myfile.close();
- } else
- {
+ } else {
std::cerr << "error: inv file: cannot open file '"
<< filename_ << "'\n";
}
More information about the Genabel-commits
mailing list