diff options
author | Joost Peters | 2003-10-12 19:17:26 +0000 |
---|---|---|
committer | Joost Peters | 2003-10-12 19:17:26 +0000 |
commit | 905e47dc1abc250ac2d3e9692251e49308d6dc4b (patch) | |
tree | 315c1fc7187756862117a7e6259784cc5865ef0a | |
parent | ba281b251af3f9db2305517a20541fab182440c3 (diff) | |
download | scummvm-rg350-905e47dc1abc250ac2d3e9692251e49308d6dc4b.tar.gz scummvm-rg350-905e47dc1abc250ac2d3e9692251e49308d6dc4b.tar.bz2 scummvm-rg350-905e47dc1abc250ac2d3e9692251e49308d6dc4b.zip |
don't use strstr(), as there is no terminating '\0' at the end of the file
svn-id: r10772
-rw-r--r-- | queen/resource.cpp | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/queen/resource.cpp b/queen/resource.cpp index 93e5ad521c..ae46696d83 100644 --- a/queen/resource.cpp +++ b/queen/resource.cpp @@ -122,16 +122,13 @@ int32 Resource::resourceIndex(const char *filename) { } char *Resource::getJAS2Line() { - char *startOfLine = _JAS2Ptr + _JAS2Pos; - char *pos = strstr(startOfLine, "\r\n"); - if (pos) { - *pos = '\0'; - pos += 2; - } else { - error("Couldn't find newline"); - } - _JAS2Pos = (pos - _JAS2Ptr); - return startOfLine; + char *startOfLine = _JAS2Ptr + _JAS2Pos; + char *curPos = startOfLine; + while (*curPos++ != 0xd) ; + *(curPos-1) = '\0'; // '\r' + *curPos = '\0'; // '\n' + _JAS2Pos = (curPos - _JAS2Ptr) + 1; + return startOfLine; } uint32 Resource::fileSize(const char *filename) { |