未验证 提交 11b8ce60 编写于 作者: O openharmony_ci 提交者: Gitee

!1381 fix bug for trigger

Merge pull request !1381 from cheng_jinsong/bugfortrigger
...@@ -328,8 +328,20 @@ int CheckMatchSubCondition(const char *condition, const char *input, int length) ...@@ -328,8 +328,20 @@ int CheckMatchSubCondition(const char *condition, const char *input, int length)
{ {
PARAM_CHECK(condition != NULL, return 0, "Invalid condition"); PARAM_CHECK(condition != NULL, return 0, "Invalid condition");
PARAM_CHECK(input != NULL, return 0, "Invalid input"); PARAM_CHECK(input != NULL, return 0, "Invalid input");
char *tmp = strstr(condition, input); const char *tmp = strstr(condition, input);
if ((tmp != NULL) && ((int)strlen(tmp) > length) && (tmp[length] == '=')) { if (tmp == NULL) {
return 0;
}
PARAM_LOGV("CheckMatchSubCondition Condition: '%s' content: '%s' length %d", condition, input, length);
if (((int)strlen(tmp) <= length) || (tmp[length] != '=')) {
return 0;
}
// for condition: parameter = 1
if (tmp == condition) {
return 1;
}
// for condition: parameter1 = 1 && parameter2 = 1
if (*(tmp - 1) == ' ') {
return 1; return 1;
} }
return 0; return 0;
......
...@@ -448,8 +448,7 @@ int32_t CheckAndMarkTrigger_(const TriggerWorkSpace *workSpace, int type, const ...@@ -448,8 +448,7 @@ int32_t CheckAndMarkTrigger_(const TriggerWorkSpace *workSpace, int type, const
trigger = head->nextTrigger(head, trigger); trigger = head->nextTrigger(head, trigger);
continue; continue;
} }
const char *tmp = strstr(head->getCondition(trigger), name); if (CheckMatchSubCondition(head->getCondition(trigger), name, strlen(name)) == 1) {
if (tmp != NULL && strncmp(tmp + strlen(name), "=", 1) == 0) {
TRIGGER_SET_FLAG(trigger, TRIGGER_FLAGS_RELATED); TRIGGER_SET_FLAG(trigger, TRIGGER_FLAGS_RELATED);
ret = 1; ret = 1;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册