aboutsummaryrefslogtreecommitdiffstats
path: root/pbx.c
diff options
context:
space:
mode:
Diffstat (limited to 'pbx.c')
-rwxr-xr-xpbx.c26
1 files changed, 14 insertions, 12 deletions
diff --git a/pbx.c b/pbx.c
index 8de44ee66..f033de974 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");
- }
}
}