Skip to content
Snippets Groups Projects
Commit 64d65fb6 authored by ck's avatar ck
Browse files

Maemo: Fix corner case in end-of-remote-process detection.

parent a8e464ab
No related branches found
No related tags found
No related merge requests found
...@@ -117,7 +117,8 @@ bool MaemoSshRunner::runInternal() ...@@ -117,7 +117,8 @@ bool MaemoSshRunner::runInternal()
void MaemoSshRunner::handleRemoteOutput() void MaemoSshRunner::handleRemoteOutput()
{ {
const QByteArray output = m_connection->waitForRemoteOutput(0); const QByteArray output
= m_potentialEndMarkerPrefix + m_connection->waitForRemoteOutput(0);
// Wait for a prompt before sending the command. // Wait for a prompt before sending the command.
if (!m_promptEncountered) { if (!m_promptEncountered) {
...@@ -143,8 +144,6 @@ void MaemoSshRunner::handleRemoteOutput() ...@@ -143,8 +144,6 @@ void MaemoSshRunner::handleRemoteOutput()
/* /*
* The output the user should see is everything after the first * The output the user should see is everything after the first
* and before the last occurrence of our marker string. * and before the last occurrence of our marker string.
* Note: We don't currently handle the case of an incomplete unicode
* character being sent.
*/ */
int firstCharToEmit; int firstCharToEmit;
int charsToEmitCount; int charsToEmitCount;
...@@ -168,16 +167,19 @@ void MaemoSshRunner::handleRemoteOutput() ...@@ -168,16 +167,19 @@ void MaemoSshRunner::handleRemoteOutput()
if (m_endMarkerCount == 0) { if (m_endMarkerCount == 0) {
charsToEmitCount = 0; charsToEmitCount = 0;
} else { } else {
firstCharToEmit = 0; firstCharToEmit = m_potentialEndMarkerPrefix.count();
charsToEmitCount = -1; charsToEmitCount = -1;
} }
} }
if (charsToEmitCount != 0) if (charsToEmitCount != 0) {
emit remoteOutput(QString::fromUtf8(output.data() + firstCharToEmit, emit remoteOutput(QString::fromUtf8(output.data() + firstCharToEmit,
charsToEmitCount)); charsToEmitCount));
}
if (m_endMarkerCount == 2) if (m_endMarkerCount == 2)
stop(); stop();
m_potentialEndMarkerPrefix = output.right(EndMarker.count() - 1);
} }
const QByteArray MaemoSshRunner::EndMarker(QString(QChar(0x13a0)).toUtf8()); const QByteArray MaemoSshRunner::EndMarker(QString(QChar(0x13a0)).toUtf8());
......
...@@ -104,6 +104,7 @@ private: ...@@ -104,6 +104,7 @@ private:
const char *m_prompt; const char *m_prompt;
int m_endMarkerCount; int m_endMarkerCount;
bool m_promptEncountered; bool m_promptEncountered;
QByteArray m_potentialEndMarkerPrefix;
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment