[tty]修复多次scanf之后,导致丢数据的问题 (#7640)
This commit is contained in:
parent
f4294c6abc
commit
1d239db59e
|
@ -1436,14 +1436,15 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, char *b, size_t nr)
|
|||
|
||||
size_t buf_size = RT_TTY_BUF - tail;
|
||||
const void *from = read_buf_addr(ldata, tail);
|
||||
size_t temp_n = n;
|
||||
if (n > buf_size)
|
||||
{
|
||||
rt_memcpy(b, from, buf_size);
|
||||
b += buf_size;
|
||||
n -= buf_size;
|
||||
temp_n -= buf_size;
|
||||
from = ldata->read_buf;
|
||||
}
|
||||
rt_memcpy(b, from, n);
|
||||
rt_memcpy(b, from, temp_n);
|
||||
|
||||
if (found)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue