diff --git a/source/module_io/input_conv.cpp b/source/module_io/input_conv.cpp index 8e3353db56..88a14837c4 100644 --- a/source/module_io/input_conv.cpp +++ b/source/module_io/input_conv.cpp @@ -35,25 +35,37 @@ template void Input_Conv::parse_expression(const std::string &fn, s int count = 0; std::string pattern("([0-9]+\\*[0-9.]+|[0-9,.]+)"); std::vector str; - std::string::size_type pos1, pos2; - std::string c = " "; - pos2 = fn.find(c); - pos1 = 0; - while (std::string::npos != pos2) - { - str.push_back(fn.substr(pos1, pos2 - pos1)); - pos1 = pos2 + c.size(); - pos2 = fn.find(c, pos1); - } - if (pos1 != fn.length()) - { - str.push_back(fn.substr(pos1)); + std::stringstream ss(fn); + std::string section; + while (ss >> section) { + int index = 0; + if (str.empty()) { + while (index < section.size() && std::isspace(section[index])) { + index++; + } + } + section.erase(0, index); + str.push_back(section); } + // std::string::size_type pos1, pos2; + // std::string c = " "; + // pos2 = fn.find(c); + // pos1 = 0; + // while (std::string::npos != pos2) + // { + // str.push_back(fn.substr(pos1, pos2 - pos1)); + // pos1 = pos2 + c.size(); + // pos2 = fn.find(c, pos1); + // } + // if (pos1 != fn.length()) + // { + // str.push_back(fn.substr(pos1)); + // } regex_t reg; regcomp(®, pattern.c_str(), REG_EXTENDED); regmatch_t pmatch[1]; const size_t nmatch = 1; - for (int i = 0; i < str.size(); ++i) + for (size_t i = 0; i < str.size(); ++i) { if (str[i] == "") { @@ -61,7 +73,7 @@ template void Input_Conv::parse_expression(const std::string &fn, s } int status = regexec(®, str[i].c_str(), nmatch, pmatch, 0); std::string sub_str = ""; - for (int j = pmatch[0].rm_so; j != pmatch[0].rm_eo; ++j) + for (size_t j = pmatch[0].rm_so; j != pmatch[0].rm_eo; ++j) { sub_str += str[i][j]; } @@ -78,8 +90,8 @@ template void Input_Conv::parse_expression(const std::string &fn, s // std::vector ocp_temp(num, occ); // const std::vector::iterator dest = vec.begin() + count; // copy(ocp_temp.begin(), ocp_temp.end(), dest); - //count += num; - for (size_t i = 0; i != num; i++) + // count += num; + for (size_t k = 0; k != num; k++) vec.emplace_back(occ); } else