wpa_cli: Add backspace key process for some terminal
authorSiWon Kang <kkangshawn@gmail.com>
Fri, 13 May 2016 02:18:14 +0000 (11:18 +0900)
committerJouni Malinen <j@w1.fi>
Fri, 13 May 2016 15:48:45 +0000 (18:48 +0300)
In some terminal, verified with gtkterm and teraterm, backspace key is
not properly processed. For instance, type 'abc', 3 times of backspace
key press then '123' shows the result of 'abc123' instead of '123'. To
fix this, add a routine to process '\b' character input when using
edit_simple.c instead of edit.c (i.e., without CONFIG_WPA_CLI_EDIT=y).

Signed-off-by: Siwon Kang <kkangshawn@gmail.com>
src/utils/edit_simple.c

index 13173cb..2ffd1a2 100644 (file)
@@ -47,6 +47,12 @@ static void edit_read_char(int sock, void *eloop_ctx, void *sock_ctx)
                return;
        }
 
+       if (c == '\b') {
+               if (cmdbuf_pos > 0)
+                       cmdbuf_pos--;
+               return;
+       }
+
        if (c >= 32 && c <= 255) {
                if (cmdbuf_pos < (int) sizeof(cmdbuf) - 1) {
                        cmdbuf[cmdbuf_pos++] = c;