提交 3e11bf0d authored 作者: Aron Podrigal's avatar Aron Podrigal

cond api return -ERR on all syntax errors

上级 625c95a5
...@@ -1922,21 +1922,18 @@ SWITCH_STANDARD_API(cond_function) ...@@ -1922,21 +1922,18 @@ SWITCH_STANDARD_API(cond_function)
} }
} }
if (!*expr) { if (!*expr) {
stream->write_function(stream, "-ERR while looking for closing quote near < %s > \n", a); goto error;
goto end;
} }
*expr++ = '\0'; *expr++ = '\0';
if (!switch_isspace(*expr)) { if (!switch_isspace(*expr)) {
stream->write_function(stream, "-ERR, Syntax error near < %s > \n", expr); goto error;
goto end;
} }
} else { } else {
if ((expr = strchr(a, ' '))) { if ((expr = strchr(a, ' '))) {
*expr++ = '\0'; *expr++ = '\0';
} else { } else {
stream->write_function(stream, "-ERR, Syntax error near < %s > \n", a); goto error;
goto end;
} }
} }
...@@ -1950,7 +1947,7 @@ SWITCH_STANDARD_API(cond_function) ...@@ -1950,7 +1947,7 @@ SWITCH_STANDARD_API(cond_function)
case '=': case '=':
goto operator; goto operator;
default: default:
expr++; goto error;
break; break;
} }
} }
...@@ -1995,8 +1992,7 @@ operator: ...@@ -1995,8 +1992,7 @@ operator:
break; break;
default: default:
stream->write_function(stream, "-ERR, Syntax error near %s invalid conditional operator.\n", expr); goto error;
goto end;
} }
if (o) { if (o) {
...@@ -2019,37 +2015,32 @@ operator: ...@@ -2019,37 +2015,32 @@ operator:
} }
} }
if (!*expr) { if (!*expr) {
stream->write_function(stream, "-ERR while looking for closing quote near < %s >!\n", b); goto error;
goto end;
} }
*expr++ = '\0'; *expr++ = '\0';
if (!switch_isspace(*expr)) { if (!switch_isspace(*expr)) {
stream->write_function(stream, "-ERR, Syntax error near < %s > \n", expr); goto error;
goto end;
} }
} else { } else {
if ((expr = strchr(b, ' '))) { if ((expr = strchr(b, ' '))) {
*expr++ = '\0'; *expr++ = '\0';
} else { } else {
stream->write_function(stream, "-ERR, Syntax error near < %s > \n", b); goto error;
goto end;
} }
} }
while (switch_isspace(*expr)) expr++; while (switch_isspace(*expr)) expr++;
if (*expr != '?') { if (*expr != '?') {
stream->write_function(stream, "-ERR, Syntax error near < %s > no expression found.\n", expr); goto error;
goto end;
} }
*expr = ':'; *expr = ':';
argc = switch_separate_string(expr, ':', argv, (sizeof(argv) / sizeof(argv[0]))); argc = switch_separate_string(expr, ':', argv, (sizeof(argv) / sizeof(argv[0])));
if (!(argc >= 2 && argc <= 3)) { if (!(argc >= 2 && argc <= 3)) {
stream->write_function(stream, "-ERR, Syntax error near < %s > , Invalid expression.\n", ++expr); goto error;
goto end;
} }
s_a = a; s_a = a;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论