diff options
author | eliel <eliel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-25 15:33:24 +0000 |
---|---|---|
committer | eliel <eliel@f38db490-d61c-443f-a65b-d21fe96a405b> | 2009-03-25 15:33:24 +0000 |
commit | e4684cc5ab720dec9d8f2a61b45bbb6e34cabbbb (patch) | |
tree | fc7a02c23dc6109ddd742dca8a1ef5191b0116f3 /main/asterisk.c | |
parent | 1db8a977e113b67d1d845f3ca43e1a6921946ebb (diff) |
Merged revisions 184220 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk
................
r184220 | eliel | 2009-03-25 10:38:19 -0400 (Wed, 25 Mar 2009) | 19 lines
Merged revisions 184188 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4
........
r184188 | eliel | 2009-03-25 10:12:54 -0400 (Wed, 25 Mar 2009) | 13 lines
Avoid destroying the CLI line when moving the cursor backward and trying to autocomplete.
When moving the cursor backward and pressing TAB to autocomplete, a NULL is put
in the line and we are loosing what we have already wrote after the actual
cursor position.
(closes issue #14373)
Reported by: eliel
Patches:
asterisk.c.patch uploaded by eliel (license 64)
Tested by: lmadsen
........
................
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@184256 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/asterisk.c')
-rw-r--r-- | main/asterisk.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/main/asterisk.c b/main/asterisk.c index 08c7f055c..58dd81a5d 100644 --- a/main/asterisk.c +++ b/main/asterisk.c @@ -2398,11 +2398,12 @@ static char *cli_complete(EditLine *editline, int ch) int nummatches = 0; char **matches; int retval = CC_ERROR; - char buf[2048]; + char buf[2048], savechr; int res; LineInfo *lf = (LineInfo *)el_line(editline); + savechr = *(char *)lf->cursor; *(char *)lf->cursor = '\0'; ptr = (char *)lf->cursor; if (ptr) { @@ -2428,8 +2429,10 @@ static char *cli_complete(EditLine *editline, int ch) char *mbuf; int mlen = 0, maxmbuf = 2048; /* Start with a 2048 byte buffer */ - if (!(mbuf = ast_malloc(maxmbuf))) + if (!(mbuf = ast_malloc(maxmbuf))) { + lf->cursor[0] = savechr; return (char *)(CC_ERROR); + } snprintf(buf, sizeof(buf), "_COMMAND MATCHESARRAY \"%s\" \"%s\"", lf->buffer, ptr); fdsend(ast_consock, buf); res = 0; @@ -2438,8 +2441,10 @@ static char *cli_complete(EditLine *editline, int ch) if (mlen + 1024 > maxmbuf) { /* Every step increment buffer 1024 bytes */ maxmbuf += 1024; - if (!(mbuf = ast_realloc(mbuf, maxmbuf))) + if (!(mbuf = ast_realloc(mbuf, maxmbuf))) { + lf->cursor[0] = savechr; return (char *)(CC_ERROR); + } } /* Only read 1024 bytes at a time */ res = read(ast_consock, mbuf + mlen, 1024); @@ -2499,6 +2504,8 @@ static char *cli_complete(EditLine *editline, int ch) ast_free(matches); } + lf->cursor[0] = savechr; + return (char *)(long)retval; } |