diff options
author | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-10-19 19:13:32 +0000 |
---|---|---|
committer | Björn Steinbrink <B.Steinbrink@gmx.de> | 2005-10-19 19:13:32 +0000 |
commit | 52f78e733af35fdd1ac325ea50011f95dbc4f6a6 (patch) | |
tree | 70f2b5a097f0305fe871d7b74ee5fdc931f5221b /src | |
parent | 940716a07cd6c4171095d5d5a75fa34b1bab6892 (diff) | |
download | mana-52f78e733af35fdd1ac325ea50011f95dbc4f6a6.tar.gz mana-52f78e733af35fdd1ac325ea50011f95dbc4f6a6.tar.bz2 mana-52f78e733af35fdd1ac325ea50011f95dbc4f6a6.tar.xz mana-52f78e733af35fdd1ac325ea50011f95dbc4f6a6.zip |
Fix empty lines not being read from text files.
Diffstat (limited to 'src')
-rw-r--r-- | src/resources/resourcemanager.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 4f409431..e2839416 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -24,6 +24,7 @@ #include "resourcemanager.h" #include <cassert> +#include <sstream> #include <physfs.h> #include "image.h" @@ -292,16 +293,11 @@ ResourceManager::loadTextFile(const std::string &fileName) return lines; } - // Reallocate and include terminating 0 character - fileContents = (char*)realloc(fileContents, contentsLength + 1); - fileContents[contentsLength] = '\0'; + std::istringstream iss(std::string(fileContents, contentsLength)); - // Tokenize and add each line separately - char *line = strtok(fileContents, "\n"); - while (line != NULL) - { + std::string line; + while(getline(iss, line, '\n')) { lines.push_back(line); - line = strtok(NULL, "\n"); } free(fileContents); |