normalize/simplify a bit of the command completion code.
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@15856 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
parent
8a81f683ed
commit
5004f1cb9d
|
@ -9394,20 +9394,19 @@ static int start_pri(struct zt_pri *pri)
|
||||||
|
|
||||||
static char *complete_span_helper(const char *line, const char *word, int pos, int state, int rpos)
|
static char *complete_span_helper(const char *line, const char *word, int pos, int state, int rpos)
|
||||||
{
|
{
|
||||||
int span=1;
|
int which, span;
|
||||||
char tmp[50];
|
char *ret = NULL;
|
||||||
|
|
||||||
if (pos != rpos)
|
if (pos != rpos)
|
||||||
return 0;
|
return ret;
|
||||||
while(span <= NUM_SPANS) {
|
|
||||||
if (span > state && pris[span-1].pri)
|
for (which = span = 0; span < NUM_SPANS; span++) {
|
||||||
|
if (pris[span].pri && ++which > state) {
|
||||||
|
asprintf(&ret, "%d", span + 1); /* user indexes start from 1 */
|
||||||
break;
|
break;
|
||||||
span++;
|
}
|
||||||
}
|
}
|
||||||
if (span <= NUM_SPANS) {
|
return ret;
|
||||||
snprintf(tmp, sizeof(tmp), "%d", span);
|
|
||||||
return ast_strdup(tmp);
|
|
||||||
} else
|
|
||||||
return NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *complete_span_4(const char *line, const char *word, int pos, int state)
|
static char *complete_span_4(const char *line, const char *word, int pos, int state)
|
||||||
|
|
Reference in New Issue