summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorBjörn Steinbrink <B.Steinbrink@gmx.de>2005-10-19 19:13:32 +0000
committerBjörn Steinbrink <B.Steinbrink@gmx.de>2005-10-19 19:13:32 +0000
commit52f78e733af35fdd1ac325ea50011f95dbc4f6a6 (patch)
tree70f2b5a097f0305fe871d7b74ee5fdc931f5221b /src/resources
parent940716a07cd6c4171095d5d5a75fa34b1bab6892 (diff)
downloadmana-client-52f78e733af35fdd1ac325ea50011f95dbc4f6a6.tar.gz
mana-client-52f78e733af35fdd1ac325ea50011f95dbc4f6a6.tar.bz2
mana-client-52f78e733af35fdd1ac325ea50011f95dbc4f6a6.tar.xz
mana-client-52f78e733af35fdd1ac325ea50011f95dbc4f6a6.zip
Fix empty lines not being read from text files.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/resourcemanager.cpp12
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);