Commit 55578408 authored by Waqar Ahmed's avatar Waqar Ahmed Committed by Tomaz Canabrava
Browse files

Use memchr to look for zmodem indicator

parent bf34fcb1
Pipeline #108610 passed with stage
in 1 minute and 59 seconds
...@@ -242,12 +242,16 @@ void Emulation::receiveData(const char *text, int length) ...@@ -242,12 +242,16 @@ void Emulation::receiveData(const char *text, int length)
// look for z-modem indicator // look for z-modem indicator
//-- someone who understands more about z-modems that I do may be able to move //-- someone who understands more about z-modems that I do may be able to move
// this check into the above for loop? // this check into the above for loop?
for (int i = 0; i < length - 4; i++) { auto *found = static_cast<const char *>(memchr(text, '\030', length));
if (text[i] == '\030') { if (found) {
if (qstrncmp(text + i + 1, "B00", 3) == 0) { int startPos = text - found;
Q_EMIT zmodemDownloadDetected(); for (int i = startPos; i < length - 4; i++) {
} else if (qstrncmp(text + i + 1, "B01", 3) == 0) { if (text[i] == '\030') {
Q_EMIT zmodemUploadDetected(); if (qstrncmp(text + i + 1, "B00", 3) == 0) {
Q_EMIT zmodemDownloadDetected();
} else if (qstrncmp(text + i + 1, "B01", 3) == 0) {
Q_EMIT zmodemUploadDetected();
}
} }
} }
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment