mirror of
https://github.com/genodelabs/genode.git
synced 2025-02-21 02:01:38 +00:00
test/terminal_expect_send: warn on excess chars
This patch adds a warning on the occurrence of overly long lines and drops characters in this case. Fixes #5108
This commit is contained in:
parent
996b2fe79f
commit
00844efd2f
@ -34,14 +34,21 @@ struct Main
|
||||
|
||||
void handle_read_avail()
|
||||
{
|
||||
size_t num_bytes = terminal.read(read_buffer, sizeof(read_buffer));
|
||||
size_t const num_bytes = terminal.read(read_buffer, sizeof(read_buffer));
|
||||
|
||||
for (size_t i = 0; i < num_bytes; i++) {
|
||||
|
||||
char const c = read_buffer[i];
|
||||
|
||||
/* copy over all characters other than line-end */
|
||||
if (read_buffer[i] != '\n' &&
|
||||
read_buffer[i] != '\r') {
|
||||
line[line_idx++] = read_buffer[i];
|
||||
if (c != '\n' && c != '\r') {
|
||||
line[line_idx++] = c;
|
||||
|
||||
if (line_idx >= MAX_LINE_LENGTH) {
|
||||
warning("dropping characters (maximum line length exceeded)");
|
||||
line_idx = 0;
|
||||
}
|
||||
|
||||
line[line_idx] = 0;
|
||||
}
|
||||
|
||||
@ -52,7 +59,7 @@ struct Main
|
||||
}
|
||||
|
||||
/* check for line end */
|
||||
if (read_buffer[i] == '\n') {
|
||||
if (c == '\n') {
|
||||
if (verbose) log(Cstring(line));
|
||||
line_idx = 0;
|
||||
line[line_idx] = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user