|
|
|
@ -150,19 +150,14 @@ ssize_t console_read(struct console *console, char *buf, size_t n) |
|
|
|
|
char *p = buf; |
|
|
|
|
char c; |
|
|
|
|
|
|
|
|
|
*buf = '\0'; |
|
|
|
|
|
|
|
|
|
while (console_peek(&c, console, 1) == 0) { |
|
|
|
|
switch (c) { |
|
|
|
|
case '\004': |
|
|
|
|
if (buf < p) |
|
|
|
|
goto out; |
|
|
|
|
|
|
|
|
|
console_getc(&c, console); |
|
|
|
|
return 0; |
|
|
|
|
return p - buf; |
|
|
|
|
default: |
|
|
|
|
if (((size_t)p - (size_t)buf) >= n) |
|
|
|
|
goto out; |
|
|
|
|
return p - buf; |
|
|
|
|
|
|
|
|
|
*p++ = c; |
|
|
|
|
console_getc(&c, console); |
|
|
|
@ -170,9 +165,6 @@ ssize_t console_read(struct console *console, char *buf, size_t n) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
out: |
|
|
|
|
*p = '\0'; |
|
|
|
|
|
|
|
|
|
return p - buf; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|