]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
edit: Fix completion at the last character
authorJouni Malinen <j@w1.fi>
Sat, 20 Nov 2010 09:59:04 +0000 (11:59 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 20 Nov 2010 09:59:04 +0000 (11:59 +0200)
Completion needs to be done even if the full word has been entered.
In addition, fix the space-after-full-word to properly allocate room
for the extra character when completion is used in the middle of the
string.

src/utils/edit.c

index eed2b534e9db03fb6279bf9949e79669b9d9880b..93a3078e32e4e9fa4377125e261e8e6def7db83e 100644 (file)
@@ -377,7 +377,7 @@ static void complete(int list)
        }
 
        len = max_common_length(c);
-       if (len <= plen) {
+       if (len < plen) {
                if (list) {
                        edit_clear_line();
                        printf("\r");
@@ -396,8 +396,8 @@ static void complete(int list)
                len = room;
        add_space = count == 1 && len < room;
 
-       os_memmove(cmdbuf + cmdbuf_pos + len, cmdbuf + cmdbuf_pos,
-                  cmdbuf_len - cmdbuf_pos + add_space);
+       os_memmove(cmdbuf + cmdbuf_pos + len + add_space, cmdbuf + cmdbuf_pos,
+                  cmdbuf_len - cmdbuf_pos);
        os_memcpy(&cmdbuf[cmdbuf_pos - plen], c[0], plen + len);
        if (add_space)
                cmdbuf[cmdbuf_pos + len] = ' ';