diff options
author | Pjotr Prins | 2017-10-20 08:10:39 +0000 |
---|---|---|
committer | Pjotr Prins | 2017-10-23 13:54:05 +0000 |
commit | b42a02d02b3d9384b1da55bd091f0f89c808b626 (patch) | |
tree | 4fd66b70ce7eb660dcb98c38a7f5309ac43195e8 /src/bslmmdap.cpp | |
parent | 12558c358150bfed99874b791932bbe06a107263 (diff) | |
download | pangemma-b42a02d02b3d9384b1da55bd091f0f89c808b626.tar.gz |
Travis-ci:
- Disabled gcc-6 since we develop with later tools anyway
- Turned the release test into a simple integration test
- Adding MacOSX on Travis-ci
Tests: Adding tests for Plink w. LOCO
Safety: Introduce strtok_safe to get rid of segfaults
Diffstat (limited to 'src/bslmmdap.cpp')
-rw-r--r-- | src/bslmmdap.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/bslmmdap.cpp b/src/bslmmdap.cpp index 7aac1d4..6f9aba7 100644 --- a/src/bslmmdap.cpp +++ b/src/bslmmdap.cpp @@ -116,16 +116,16 @@ void ReadFile_hyb(const string &file_hyp, vector<double> &vec_sa2, getline(infile, line); while (!safeGetline(infile, line).eof()) { - ch_ptr = strtok((char *)line.c_str(), " , \t"); - ch_ptr = strtok(NULL, " , \t"); + ch_ptr = strtok_safe((char *)line.c_str(), " , \t"); + ch_ptr = strtok_safe(NULL, " , \t"); - ch_ptr = strtok(NULL, " , \t"); + ch_ptr = strtok_safe(NULL, " , \t"); vec_sa2.push_back(atof(ch_ptr)); - ch_ptr = strtok(NULL, " , \t"); + ch_ptr = strtok_safe(NULL, " , \t"); vec_sb2.push_back(atof(ch_ptr)); - ch_ptr = strtok(NULL, " , \t"); + ch_ptr = strtok_safe(NULL, " , \t"); vec_wab.push_back(atof(ch_ptr)); } @@ -160,11 +160,11 @@ void ReadFile_bf(const string &file_bf, vector<string> &vec_rs, while (!safeGetline(infile, line).eof()) { flag_block = 0; - ch_ptr = strtok((char *)line.c_str(), " , \t"); + ch_ptr = strtok_safe((char *)line.c_str(), " , \t"); rs = ch_ptr; vec_rs.push_back(rs); - ch_ptr = strtok(NULL, " , \t"); + ch_ptr = strtok_safe(NULL, " , \t"); if (t == 0) { block = ch_ptr; } else { @@ -223,7 +223,7 @@ void ReadFile_cat(const string &file_cat, const vector<string> &vec_rs, // Read header. HEADER header; - !safeGetline(infile, line).eof(); + safeGetline(infile, line).eof(); ReadHeader_io(line, header); // Use the header to determine the number of categories. @@ -238,7 +238,7 @@ void ReadFile_cat(const string &file_cat, const vector<string> &vec_rs, // Read the following lines to record mapRS2cat. while (!safeGetline(infile, line).eof()) { - ch_ptr = strtok((char *)line.c_str(), " , \t"); + ch_ptr = strtok_safe((char *)line.c_str(), " , \t"); if (header.rs_col == 0) { rs = chr + ":" + pos; @@ -248,6 +248,7 @@ void ReadFile_cat(const string &file_cat, const vector<string> &vec_rs, catd.clear(); for (size_t i = 0; i < header.coln; i++) { + enforce(ch_ptr); if (header.rs_col != 0 && header.rs_col == i + 1) { rs = ch_ptr; } else if (header.chr_col != 0 && header.chr_col == i + 1) { |