From b42a02d02b3d9384b1da55bd091f0f89c808b626 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 20 Oct 2017 08:10:39 +0000 Subject: 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 --- src/bslmmdap.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'src/bslmmdap.cpp') 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 &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 &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 &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 &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 &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) { -- cgit v1.2.3