X-Git-Url: http://git.droids-corp.org/?p=libcmdline.git;a=blobdiff_plain;f=src%2Flib%2Fcmdline_parse.c;h=c0568338b5288447fdc69b000687c087aea16a96;hp=8e73e65e53f667cf761c9d755a1b92539fb88b35;hb=df9816e5e10b0552c7e29650ee21a79654af67ef;hpb=6b78e677092ace71c841c23d4f21909d3fc0ae01 diff --git a/src/lib/cmdline_parse.c b/src/lib/cmdline_parse.c index 8e73e65..c056833 100644 --- a/src/lib/cmdline_parse.c +++ b/src/lib/cmdline_parse.c @@ -502,8 +502,15 @@ int cmdline_help(cmdline_parse_ctx_t *ctx, const char *buf, else iterate = 1; + /* store the incomplete token in tmpbuf */ + n = preparse.comp_tok_len + 1; + if (n > sizeof(tmpbuf)) + n = sizeof(tmpbuf); + snprintf(tmpbuf, n, "%s", preparse.comp_tok_buf); + if (iterate == 1 && - token->ops->complete_start(token, &preparse.opaque) < 0) { + token->ops->complete_start(token, tmpbuf, + &preparse.opaque) < 0) { /* cancel iteration, complete_start() returned * a negative value, meaning no completion */ iterate = 0; @@ -605,8 +612,15 @@ cmdline_complete(cmdline_parse_ctx_t *ctx, const char *buf, token->ops->complete_iterate == NULL) continue; + /* store the incomplete token in tmpbuf */ + n = preparse.comp_tok_len + 1; + if (n > sizeof(tmpbuf)) + n = sizeof(tmpbuf); + snprintf(tmpbuf, n, "%s", preparse.comp_tok_buf); + /* non completable */ - if (token->ops->complete_start(token, &preparse.opaque) < 0) { + if (token->ops->complete_start(token, tmpbuf, + &preparse.opaque) < 0) { if (token->ops->complete_end != NULL) token->ops->complete_end(token, &preparse.opaque);