Introduce Utils::SynchronousProcess::normalizeNewlines

Replaces \r\n? with \n.

Some console applications (e.g. git-push, git-rebase) use \r alone to
move the cursor to the line's beginning. This should be replaced by \n
rather than just be erased.

Change-Id: I8d614d2b471e59decdbfa7f173ffa7fbdb11759b
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
This commit is contained in:
Orgad Shaneh
2013-08-02 12:15:04 +03:00
committed by Orgad Shaneh
parent 1b13122cd1
commit 208aeb79ed
8 changed files with 43 additions and 27 deletions

View File

@@ -744,9 +744,7 @@ Core::IEditor *locateEditor(const char *property, const QString &entry)
// Return converted command output, remove '\r' read on Windows
static inline QString commandOutputFromLocal8Bit(const QByteArray &a)
{
QString output = QString::fromLocal8Bit(a);
output.remove(QLatin1Char('\r'));
return output;
return Utils::SynchronousProcess::normalizeNewlines(QString::fromLocal8Bit(a));
}
// Return converted command output split into lines
@@ -3398,7 +3396,7 @@ QString GitClient::readConfig(const QString &workingDirectory, const QStringList
VcsBasePlugin::SuppressCommandLogging))
return QString();
if (Utils::HostOsInfo::isWindowsHost())
return QString::fromUtf8(outputText).remove(QLatin1Char('\r'));
return Utils::SynchronousProcess::normalizeNewlines(QString::fromUtf8(outputText));
return commandOutputFromLocal8Bit(outputText);
}