diff --git a/extern/filereaderlp/def.hpp b/extern/filereaderlp/def.hpp index 296872592c..723927af22 100644 --- a/extern/filereaderlp/def.hpp +++ b/extern/filereaderlp/def.hpp @@ -10,9 +10,6 @@ void inline lpassert(bool condition) { } } -const unsigned int LP_MAX_NAME_LENGTH = 255; -const unsigned int LP_MAX_LINE_LENGTH = 560; - const std::string LP_KEYWORD_MIN[] = {"minimize", "min", "minimum"}; const std::string LP_KEYWORD_MAX[] = {"maximize", "max", "maximum"}; const std::string LP_KEYWORD_ST[] = {"subject to", "such that", "st", "s.t."}; diff --git a/extern/filereaderlp/reader.cpp b/extern/filereaderlp/reader.cpp index 9ee77f50c6..af1ca2eb4e 100644 --- a/extern/filereaderlp/reader.cpp +++ b/extern/filereaderlp/reader.cpp @@ -1002,24 +1002,24 @@ void Reader::readnexttoken(bool& done) { assert(this->linebufferpos == this->linebuffer.size()); return; } - + // check for double value - double constant; - int ncharconsumed; - int nread = sscanf(this->linebuffer.data()+this->linebufferpos, "%lf%n", &constant, &ncharconsumed); - if (nread == 1) { + const char* startptr = this->linebuffer.data()+this->linebufferpos; + char* endptr; + double constant = strtod(startptr, &endptr); + if (endptr != startptr) { this->rawtokens.push_back(std::unique_ptr(new RawConstantToken(constant))); - this->linebufferpos += ncharconsumed; + this->linebufferpos += endptr - startptr; return; } // assume it's an (section/variable/constraint) identifier - char stringbuffer[LP_MAX_NAME_LENGTH+1]; - nread = sscanf(this->linebuffer.data()+this->linebufferpos, "%[^][\t\n\\:+<>^= /-]%n", - stringbuffer, &ncharconsumed); - if (nread == 1) { - this->rawtokens.push_back(std::unique_ptr(new RawStringToken(stringbuffer))); - this->linebufferpos += ncharconsumed; + auto endpos = this->linebuffer.find_first_of("\t\n\\:+<>^= /-", this->linebufferpos); + if( endpos == std::string::npos ) + endpos = this->linebuffer.size(); // take complete rest of string + if( endpos > this->linebufferpos ) { + this->rawtokens.push_back(std::unique_ptr(new RawStringToken(std::string(this->linebuffer, this->linebufferpos, endpos - this->linebufferpos)))); + this->linebufferpos = endpos; return; }