os/input: Don't advance past incomplete sequences in input_enqueue

This allows callers to incrementally process buffers that are filled by
incomplete chunks more easily.
This commit is contained in:
Thiago de Arruda 2015-09-27 11:56:38 -03:00
parent 1143b416ab
commit 0e4e69e52e

View File

@ -171,10 +171,17 @@ size_t input_enqueue(String keys)
} }
if (*ptr == '<') { if (*ptr == '<') {
// Invalid key sequence, skip until the next '>' or until *end char *old_ptr = ptr;
// Invalid or incomplete key sequence, skip until the next '>' or until
// *end
do { do {
ptr++; ptr++;
} while (ptr < end && *ptr != '>'); } while (ptr < end && *ptr != '>');
if (*ptr != '>') {
// Incomplete key sequence, return without consuming.
ptr = old_ptr;
break;
}
ptr++; ptr++;
continue; continue;
} }