summaryrefslogtreecommitdiff
path: root/src/libs/utils/synchronousprocess.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/utils/synchronousprocess.cpp')
-rw-r--r--src/libs/utils/synchronousprocess.cpp19
1 files changed, 4 insertions, 15 deletions
diff --git a/src/libs/utils/synchronousprocess.cpp b/src/libs/utils/synchronousprocess.cpp
index bb31af4f06..5ede9bcc6b 100644
--- a/src/libs/utils/synchronousprocess.cpp
+++ b/src/libs/utils/synchronousprocess.cpp
@@ -188,7 +188,8 @@ void ChannelBuffer::clearForRun()
QString ChannelBuffer::linesRead()
{
// Any new lines?
- const int lastLineIndex = data.lastIndexOf(QLatin1Char('\n'));
+ const int lastLineIndex = qMax(data.lastIndexOf(QLatin1Char('\n')),
+ data.lastIndexOf(QLatin1Char('\r')));
if (lastLineIndex == -1 || lastLineIndex <= bufferPos)
return QString();
const int nextBufferPos = lastLineIndex + 1;
@@ -719,20 +720,8 @@ QString SynchronousProcess::locateBinary(const QString &path, const QString &bin
QString SynchronousProcess::normalizeNewlines(const QString &text)
{
- const QChar cr(QLatin1Char('\r'));
- const QChar lf(QLatin1Char('\n'));
- QString res;
- res.reserve(text.size());
- for (int i = 0, count = text.size(); i < count; ++i) {
- const QChar c = text.at(i);
- if (c == cr) {
- res += lf;
- if (i + 1 < count && text.at(i + 1) == lf)
- ++i;
- } else {
- res += c;
- }
- }
+ QString res = text;
+ res.replace(QLatin1String("\r\n"), QLatin1String("\n"));
return res;
}