summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Eike Beer <kde@opensource.sf-tec.de>2012-03-10 15:32:27 (GMT)
committerRolf Eike Beer <kde@opensource.sf-tec.de>2012-03-10 15:32:27 (GMT)
commit7eb5ed3e439edf06fe4da36a12bb435a7e38905e (patch)
tree7c09ec92e9b17c1b1b36c44d8f7fc11736306551
parente2ac9db16bbab040e51ebdfb3c4e296644dc9a24 (diff)
use correct line endings when reading GnuPG output on Windows
CCMAIL:ps_ml@gmx.de
-rw-r--r--klinebufferedprocess.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/klinebufferedprocess.cpp b/klinebufferedprocess.cpp
index 913e3b7..adca814 100644
--- a/klinebufferedprocess.cpp
+++ b/klinebufferedprocess.cpp
@@ -27,12 +27,18 @@ public:
int m_newlineInStdout;
int m_newlineInStderr;
KLineBufferedProcess * const m_parent;
+ const QByteArray m_lineEnd;
};
KLineBufferedProcessPrivate::KLineBufferedProcessPrivate(KLineBufferedProcess *parent)
: m_newlineInStdout(-1),
m_newlineInStderr(-1),
- m_parent(parent)
+ m_parent(parent),
+#ifdef Q_OS_WIN32 //krazy:exclude=cpp
+ m_lineEnd("\r\n")
+#else
+ m_lineEnd("\n")
+#endif
{
}
@@ -56,7 +62,7 @@ void KLineBufferedProcessPrivate::_k_receivedStdout()
m_stdoutBuffer.append(ndata);
if (m_newlineInStdout < 0) {
- m_newlineInStdout = ndata.indexOf('\n');
+ m_newlineInStdout = ndata.indexOf(m_lineEnd);
if (m_newlineInStdout >= 0) {
m_newlineInStdout += oldBufferSize;
emit m_parent->lineReadyStandardOutput();
@@ -71,7 +77,7 @@ void KLineBufferedProcessPrivate::_k_receivedStderr()
m_stderrBuffer.append(ndata);
if (m_newlineInStderr < 0) {
- m_newlineInStderr = ndata.indexOf('\n');
+ m_newlineInStderr = ndata.indexOf(m_lineEnd);
if (m_newlineInStderr >= 0) {
m_newlineInStderr += oldBufferSize;
emit m_parent->lineReadyStandardError();
@@ -87,9 +93,9 @@ bool KLineBufferedProcess::readLineStandardOutput(QByteArray *line)
// don't copy '\n'
*line = d->m_stdoutBuffer.left(d->m_newlineInStdout);
- d->m_stdoutBuffer.remove(0, d->m_newlineInStdout + 1);
+ d->m_stdoutBuffer.remove(0, d->m_newlineInStdout + d->m_lineEnd.length());
- d->m_newlineInStdout = d->m_stdoutBuffer.indexOf('\n');
+ d->m_newlineInStdout = d->m_stdoutBuffer.indexOf(d->m_lineEnd);
return true;
}
@@ -102,9 +108,9 @@ bool KLineBufferedProcess::readLineStandardError(QByteArray *line)
// don't copy '\n'
*line = d->m_stderrBuffer.left(d->m_newlineInStderr);
- d->m_stderrBuffer.remove(0, d->m_newlineInStderr + 1);
+ d->m_stderrBuffer.remove(0, d->m_newlineInStderr + d->m_lineEnd.length());
- d->m_newlineInStderr = d->m_stderrBuffer.indexOf('\n');
+ d->m_newlineInStderr = d->m_stderrBuffer.indexOf(d->m_lineEnd);
return true;
}