[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 09/17] wctablet: add wctablet_shift_input
From: |
Gerd Hoffmann |
Subject: |
[Qemu-devel] [PATCH 09/17] wctablet: add wctablet_shift_input |
Date: |
Fri, 6 Jan 2017 09:55:37 +0100 |
Helper function to drop leading chars from the input buffer.
Signed-off-by: Gerd Hoffmann <address@hidden>
---
backends/wctablet.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/backends/wctablet.c b/backends/wctablet.c
index d0ee0e4..2b14241 100644
--- a/backends/wctablet.c
+++ b/backends/wctablet.c
@@ -141,6 +141,13 @@ static int wctablet_check_command(uint8_t *arr, int count)
return -1;
}
+static void wctablet_shift_input(TabletState *tablet, int count)
+{
+ tablet->query_index -= count;
+ memmove(tablet->query, tablet->query + count, tablet->query_index);
+ tablet->query[tablet->query_index] = 0;
+}
+
static void wctablet_queue_output(TabletState *tablet, uint8_t *buf, int count)
{
if (tablet->outlen + count > sizeof(tablet->outbuf)) {
@@ -232,8 +239,7 @@ static int wctablet_chr_write(struct CharDriverState *s,
while (tablet->query_index > 0 && (tablet->query[0] == '@' ||
tablet->query[0] == '\r' ||
tablet->query[0] == '\n')) {
- memmove(tablet->query, tablet->query + 1, tablet->query_index);
- tablet->query_index--;
+ wctablet_shift_input(tablet, 1);
}
if (!tablet->query_index) {
return len;
--
1.8.3.1
- [Qemu-devel] [PATCH 08/17] wctablet: drop debug code from wctablet_handler, (continued)
- [Qemu-devel] [PATCH 08/17] wctablet: drop debug code from wctablet_handler, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 03/17] wctablet: save all chars in the query buffer, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 05/17] wctablet: strip leading \r + \n from buffer, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 14/17] wctablet: misc cleanups, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 01/17] Add wctablet device, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 07/17] wctablet: operate on line speed 9600, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 09/17] wctablet: add wctablet_shift_input,
Gerd Hoffmann <=
- [Qemu-devel] [PATCH 15/17] wctablet: switch to new input interface, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 06/17] wctablet: track line speed, reset on speed changes, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 10/17] wctablet: move init/detect sequence, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 16/17] wctablet: update file comment, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 13/17] wctablet: drop DPRINTF, add trace events instead, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 17/17] wctablet: implement ST and SP commands, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 04/17] wctablet: drop wctablet_commands_names, Gerd Hoffmann, 2017/01/06
- [Qemu-devel] [PATCH 12/17] wctablet: drop timer, hook into chr->accept_input instead, Gerd Hoffmann, 2017/01/06