summaryrefslogtreecommitdiff
path: root/src/gui/updaterwindow.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-01-25 00:27:53 +0300
committerAndrei Karas <akaras@inbox.ru>2013-01-25 00:51:43 +0300
commit7b7d62175f01dd444b8d84586905a783d383e235 (patch)
tree5cd094f36a3c8e8f85b332167891368810129652 /src/gui/updaterwindow.cpp
parent35027dbb38ad7c3b64fbf5615a9060785c861c78 (diff)
downloadmv-7b7d62175f01dd444b8d84586905a783d383e235.tar.gz
mv-7b7d62175f01dd444b8d84586905a783d383e235.tar.bz2
mv-7b7d62175f01dd444b8d84586905a783d383e235.tar.xz
mv-7b7d62175f01dd444b8d84586905a783d383e235.zip
Fix news.txt loading.
Before was skipped empty lines.
Diffstat (limited to 'src/gui/updaterwindow.cpp')
-rw-r--r--src/gui/updaterwindow.cpp20
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();