From: Olivier Matz Date: Thu, 27 Oct 2011 20:44:38 +0000 (+0200) Subject: rdline: don't display prompt if stopped by user X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=568d6d51fc9e6e2d8842fc1abe63c23de503f8bc;p=libcmdline.git rdline: don't display prompt if stopped by user Signed-off-by: Olivier Matz --- diff --git a/src/lib/cmdline.c b/src/lib/cmdline.c index 7423cc0..70267de 100644 --- a/src/lib/cmdline.c +++ b/src/lib/cmdline.c @@ -194,6 +194,10 @@ cmdline_in(struct cmdline *cl, const char *buf, int size) for (i = 0; i < size; i++) { ret = rdline_char_in(&cl->rdl, buf[i]); + if (ret == RDLINE_RES_VALIDATED && + cl->rdl.status == RDLINE_STOPPED) + break; + if (ret == RDLINE_RES_VALIDATED) rdline_newline(&cl->rdl, cl->prompt); else if (ret == RDLINE_RES_EOF) diff --git a/src/lib/cmdline_rdline.c b/src/lib/cmdline_rdline.c index 5632a87..785a23c 100644 --- a/src/lib/cmdline_rdline.c +++ b/src/lib/cmdline_rdline.c @@ -107,7 +107,7 @@ rdline_init(struct rdline *rdl, rdl->validate = validate; rdl->complete = complete; rdl->help = help; - rdl->status = RDLINE_INIT; + rdl->status = RDLINE_STOPPED; #ifndef NO_RDLINE_HISTORY cirbuf_init(&rdl->history, rdl->history_buf, 0, RDLINE_HISTORY_BUF_SIZE); #endif /* !NO_RDLINE_HISTORY */ @@ -135,7 +135,7 @@ rdline_newline(struct rdline *rdl, const char *prompt) void rdline_stop(struct rdline *rdl) { - rdl->status = RDLINE_INIT; + rdl->status = RDLINE_STOPPED; } void @@ -499,7 +499,6 @@ rdline_parse_char(struct rdline *rdl, char c) } rdline_asyncpager_reset(rdl); - rdl->status = RDLINE_INIT; #else if (rdl->status == RDLINE_EXITED) return RDLINE_RES_EXITED; diff --git a/src/lib/cmdline_rdline.h b/src/lib/cmdline_rdline.h index bda4465..47ab6c9 100644 --- a/src/lib/cmdline_rdline.h +++ b/src/lib/cmdline_rdline.h @@ -90,7 +90,7 @@ #define RDLINE_MAX_LINES 23 enum rdline_status { - RDLINE_INIT, + RDLINE_STOPPED, RDLINE_RUNNING, RDLINE_EXITED };