normalize a loop and avoid multiple strlen calls when completing voicemail users

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@7668 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.4
Russell Bryant 21 years ago
parent 1bd94abf57
commit 5c18154617

@ -5741,7 +5741,8 @@ static int handle_show_voicemail_zones(int fd, int argc, char *argv[])
static char *complete_show_voicemail_users(char *line, char *word, int pos, int state)
{
int which = 0;
struct ast_vm_user *vmu = users;
int wordlen;
struct ast_vm_user *vmu;
char *context = "";
/* 0 - show; 1 - voicemail; 2 - users; 3 - for; 4 - <context> */
@ -5753,8 +5754,9 @@ static char *complete_show_voicemail_users(char *line, char *word, int pos, int
else
return NULL;
}
while (vmu) {
if (!strncasecmp(word, vmu->context, strlen(word))) {
wordlen = strlen(word);
for (vmu = users; vmu; vmu = vmu->next) {
if (!strncasecmp(word, vmu->context, wordlen)) {
if (context && strcmp(context, vmu->context)) {
if (++which > state) {
return strdup(vmu->context);
@ -5762,7 +5764,6 @@ static char *complete_show_voicemail_users(char *line, char *word, int pos, int
context = vmu->context;
}
}
vmu = vmu->next;
}
return NULL;
}

Loading…
Cancel
Save