From 7b7d62175f01dd444b8d84586905a783d383e235 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 25 Jan 2013 00:27:53 +0300 Subject: Fix news.txt loading. Before was skipped empty lines. --- src/gui/updaterwindow.cpp | 20 +++++++------------- 1 file 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(); -- cgit v1.2.3-60-g2f50