FS-5945 --resolve

This commit is contained in:
Anthony Minessale 2013-11-08 22:36:35 +05:00
parent a5328fe9c3
commit 92f6986b40

View File

@ -1929,40 +1929,91 @@ SWITCH_STANDARD_API(cond_function)
} }
a = argv[0]; a = argv[0];
while(*a == ' ' || *a == '\t') a++;
if ((expr = strchr(a, '!'))) { if (*a == '\'') {
if ((expr = switch_find_end_paren(a, '\'', '\''))) {
a++;
*expr++ = '\0';
} else {
goto error;
}
} else {
if ((expr = strchr(a, ' '))) {
*expr++ = '\0';
} else {
expr = a;
}
}
while(expr && *expr) {
switch(*expr) {
case '!':
case '<':
case '>':
case '=':
goto done;
default:
expr++;
break;
}
}
done:
switch(*expr) {
case '!':
*expr++ = '\0'; *expr++ = '\0';
if (*expr == '=') { if (*expr == '=') {
o = O_NE; o = O_NE;
}
} else if ((expr = strchr(a, '>'))) {
if (*(expr + 1) == '=') {
*expr++ = '\0'; *expr++ = '\0';
}
break;
case '>':
*expr++ = '\0';
if (*expr == '=') {
o = O_GE; o = O_GE;
*expr++ = '\0';
} else { } else {
o = O_GT; o = O_GT;
} }
} else if ((expr = strchr(a, '<'))) { break;
if (*(expr + 1) == '=') {
case '<':
*expr++ = '\0'; *expr++ = '\0';
if (*expr == '=') {
o = O_LE; o = O_LE;
*expr++ = '\0';
} else { } else {
o = O_LT; o = O_LT;
} }
} else if ((expr = strchr(a, '='))) { break;
case '=':
*expr++ = '\0'; *expr++ = '\0';
if (*expr == '=') { if (*expr == '=') {
o = O_EQ; o = O_EQ;
*expr++ = '\0';
} }
break;
default:
goto error;
} }
if (o) { if (o) {
char *s_a = NULL, *s_b = NULL; char *s_a = NULL, *s_b = NULL;
int a_is_num, b_is_num; int a_is_num, b_is_num;
*expr++ = '\0';
expr++;
b = expr; b = expr;
s_a = switch_strip_spaces(a, SWITCH_TRUE); s_a = switch_strip_spaces(a, SWITCH_TRUE);
s_b = switch_strip_spaces(b, SWITCH_TRUE); s_b = switch_strip_spaces(b, SWITCH_TRUE);
a_is_num = switch_is_number(s_a); a_is_num = switch_is_number(s_a);
b_is_num = switch_is_number(s_b); b_is_num = switch_is_number(s_b);