cmdline: fix completion in some conditions (partial token len > 1)
authorOlivier Matz <zer0@droids-corp.org>
Sun, 20 Feb 2011 16:57:29 +0000 (17:57 +0100)
committerOlivier Matz <zer0@droids-corp.org>
Sun, 13 Mar 2011 10:09:25 +0000 (11:09 +0100)
Signed-off-by: Olivier Matz <zer0@droids-corp.org>
src/lib/cmdline_parse.c

index c056833..18ea76e 100644 (file)
@@ -693,8 +693,8 @@ cmdline_complete(cmdline_parse_ctx_t *ctx, const char *buf,
                if (completion_len >= dstsize)
                        completion_len = dstsize - 1;
                strncpy(dst, completion_buf + preparse.comp_tok_len,
-                       completion_len);
-               dst[completion_len] = '\0';
+                       completion_len - preparse.comp_tok_len);
+               dst[completion_len - preparse.comp_tok_len] = '\0';
                return CMDLINE_COMPLETE_APPEND;
        }