Beautifier: Handle CRLF for Artistic Style on Windows correctly

Artistic Style will return CRLF on Windows if you are using a pipe. Thus
we have to convert it.

Change-Id: Id24cac2f35cc3c1978d709fb6c66cee8c8814e34
Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
Lorenz Haas
2014-07-09 08:59:38 +02:00
parent 45195b331b
commit e392014baa
4 changed files with 25 additions and 2 deletions

View File

@@ -198,9 +198,14 @@ QString BeautifierPlugin::format(const QString &text, const Command &command,
return QString();
}
if (command.pipeAddsNewline()) {
const bool addsNewline = command.pipeAddsNewline();
const bool returnsCRLF = command.returnsCRLF();
if (addsNewline || returnsCRLF) {
QString formatted = QString::fromUtf8(process.readAllStandardOutput());
formatted.remove(QRegExp(QLatin1String("(\\r\\n|\\n)$")));
if (addsNewline)
formatted.remove(QRegExp(QLatin1String("(\\r\\n|\\n)$")));
if (returnsCRLF)
formatted.replace(QLatin1String("\r\n"), QLatin1String("\n"));
return formatted;
}
return QString::fromUtf8(process.readAllStandardOutput());