diff options
author | Andrei Karas <akaras@inbox.ru> | 2013-01-25 00:27:53 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2013-01-25 00:51:43 +0300 |
commit | 7b7d62175f01dd444b8d84586905a783d383e235 (patch) | |
tree | 5cd094f36a3c8e8f85b332167891368810129652 | |
parent | 35027dbb38ad7c3b64fbf5615a9060785c861c78 (diff) | |
download | manaplus-7b7d62175f01dd444b8d84586905a783d383e235.tar.gz manaplus-7b7d62175f01dd444b8d84586905a783d383e235.tar.bz2 manaplus-7b7d62175f01dd444b8d84586905a783d383e235.tar.xz manaplus-7b7d62175f01dd444b8d84586905a783d383e235.zip |
Fix news.txt loading.
Before was skipped empty lines.
-rw-r--r-- | src/gui/updaterwindow.cpp | 20 |
1 files changed, 7 insertions, 13 deletions
diff --git a/src/gui/updaterwindow.cpp b/src/gui/updaterwindow.cpp index 7d489c8ec..531a0ac60 100644 --- a/src/gui/updaterwindow.cpp +++ b/src/gui/updaterwindow.cpp @@ -296,31 +296,26 @@ void UpdaterWindow::loadNews() mMemoryBuffer[mDownloadedBytes] = '\0'; mBrowserBox->clearRows(); - // Tokenize and add each line separately - const char *line = strtok(mMemoryBuffer, "\n"); std::string newsName = mUpdatesDir + "/local/help/news.txt"; mkdir_r((mUpdatesDir + "/local/help/").c_str()); + bool firstLine(true); std::ofstream file; + std::stringstream ss(mMemoryBuffer); + std::string line; file.open(newsName.c_str(), std::ios::out); - - bool firstLine(true); - while (line) + while (std::getline(ss, line, '\n')) { if (firstLine) { firstLine = false; - std::string str = line; - const size_t i = str.find("##9 Latest client version: ##6"); + const size_t i = line.find("##9 Latest client version: ##6"); if (!i) - { - line = strtok(nullptr, "\n"); continue; - } if (file.is_open()) - file << str << std::endl; - mBrowserBox->addRow(str); + file << line << std::endl; + mBrowserBox->addRow(line); } else { @@ -328,7 +323,6 @@ void UpdaterWindow::loadNews() file << line << std::endl; mBrowserBox->addRow(line); } - line = strtok(nullptr, "\n"); } file.close(); |