diff --git a/pbx.c b/pbx.c index 8de44ee66df76e82bda3add26f88269880c2d7ae..f033de974b1af673587bdc96150d76e938e43ec3 100755 --- a/pbx.c +++ b/pbx.c @@ -751,7 +751,20 @@ static void pbx_substitute_variables_temp(struct ast_channel *c,const char *var, headp=&c->varshead; *ret=NULL; /* Now we have the variable name on cp3 */ - if ((first=strchr(var,':'))) { + if (!strncasecmp(var,"LEN(",4)) { + int len=strlen(var); + int len_len=4; + if (strrchr(var,')')) { + char cp3[80]; + strncpy(cp3, var, sizeof(cp3) - 1); + cp3[len-len_len-1]='\0'; + sprintf(workspace,"%d",strlen(cp3)); + *ret = workspace; + } else { + /* length is zero */ + *ret = "0"; + } + } else if ((first=strchr(var,':'))) { strncpy(tmpvar, var, sizeof(tmpvar) - 1); first = strchr(tmpvar, ':'); if (!first) @@ -929,17 +942,6 @@ static void pbx_substitute_variables_temp(struct ast_channel *c,const char *var, } } } - if (!(*ret) && !strncasecmp(var,"LEN(",4)) { - int len=strlen(var); - int len_len=4; - if (len > (len_len+1) && !strncasecmp(var,"LEN(",len_len) && strchr(var+len_len+2,')')) { - char cp3[80]; - strncpy(cp3, var, sizeof(cp3) - 1); - cp3[len-len_len-1]='\0'; - sprintf(workspace,"%d",strlen(cp3)); - *ret = workspace; - } else ast_log(LOG_NOTICE, "Wrong use of LEN(VARIABLE)\n"); - } } }