未验证 提交 1d239db5 编写于 作者: G goldengrandpa 提交者: GitHub

[tty]修复多次scanf之后,导致丢数据的问题 (#7640)

上级 f4294c6a
...@@ -1436,14 +1436,15 @@ static int canon_copy_from_read_buf(struct tty_struct *tty, char *b, size_t nr) ...@@ -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; size_t buf_size = RT_TTY_BUF - tail;
const void *from = read_buf_addr(ldata, tail); const void *from = read_buf_addr(ldata, tail);
size_t temp_n = n;
if (n > buf_size) if (n > buf_size)
{ {
rt_memcpy(b, from, buf_size); rt_memcpy(b, from, buf_size);
b += buf_size; b += buf_size;
n -= buf_size; temp_n -= buf_size;
from = ldata->read_buf; from = ldata->read_buf;
} }
rt_memcpy(b, from, n); rt_memcpy(b, from, temp_n);
if (found) if (found)
{ {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册