From 1e139e410744eb791486dcee0ed4b1eebdf9a515 Mon Sep 17 00:00:00 2001 From: nancy.liao <huihui.liao@greentest.com.cn> Date: 周四, 24 4月 2025 09:32:54 +0800 Subject: [PATCH] 提交修改 --- libscpi/src/utils.c | 22 ++++++++-------------- 1 files changed, 8 insertions(+), 14 deletions(-) diff --git a/libscpi/src/utils.c b/libscpi/src/utils.c index cd76fec..8758917 100644 --- a/libscpi/src/utils.c +++ b/libscpi/src/utils.c @@ -1147,8 +1147,7 @@ // 鐢ㄤ簬鎻愬彇骞跺鐞嗛�夐」鐨勫嚱鏁� -int extract_required_options(const char* pattern, char options[MAX_TAGS][MAX_OPTION_LEN][MAX_OPTION_LEN], int max_tags) -{ +int extract_required_options(const char* pattern, char options[MAX_TAGS][MAX_OPTION_LEN][MAX_OPTION_LEN], int max_tags) { const char* start = strchr(pattern, '<'); // 鏌ユ壘绗竴涓� '<' const char* end = NULL; int tag_count = 0; @@ -1164,8 +1163,7 @@ // 鎻愬彇 <...> 涓殑鍐呭 int len = end - start - 1; - if (len > 0 && len < MAX_OPTION_LEN) - { + if (len > 0 && len < MAX_OPTION_LEN) { char buffer[MAX_OPTION_LEN]; strncpy(buffer, start + 1, len); // 澶嶅埗 '<' 鍜� '>' 涔嬮棿鐨勫唴瀹� buffer[len] = '\0'; // 缁撴潫绗� @@ -1173,8 +1171,7 @@ // 澶勭悊 | 鍒嗛殧绗︼紝鎻愬彇澶氫釜閫夐」 char* token = strtok(buffer, "|"); int option_count = 0; - while (token && option_count < MAX_OPTION_LEN) - { + while (token && option_count < MAX_OPTION_LEN) { // 鍘婚櫎 token 涓殑 "[:", "]" 鍜岀┖鏍� char* p = token; while (*p == ' ' || *p == '[' || *p == ':') p++; // 鍘婚櫎鍓嶅绌烘牸鍜� [: @@ -1183,8 +1180,7 @@ *(q + 1) = '\0'; // 纭繚缁撳熬鏄�'\0' // 鎷疯礉閫夐」鍒� options 鏁扮粍 - if (option_count < MAX_OPTION_LEN) - { // 纭繚涓嶄細瓒婄晫 + if (option_count < MAX_OPTION_LEN) { // 纭繚涓嶄細瓒婄晫 strncpy(options[tag_count][option_count], p, MAX_OPTION_LEN - 1); options[tag_count][option_count][MAX_OPTION_LEN - 1] = '\0'; // 纭繚缁撴潫绗� option_count++; @@ -1202,8 +1198,7 @@ } // 鐢ㄤ簬妫�鏌ヨ緭鍏ユ槸鍚﹁兘鍖归厤姣忎竴缁勯�夐」 -int match_input_to_options(const char* input, char options[MAX_TAGS][MAX_OPTION_LEN][MAX_OPTION_LEN], int num_tags) -{ +int match_input_to_options(const char* input, char options[MAX_TAGS][MAX_OPTION_LEN][MAX_OPTION_LEN], int num_tags) { char input_copy[MAX_INPUT_LEN]; strncpy(input_copy, input, MAX_INPUT_LEN - 1); input_copy[MAX_INPUT_LEN - 1] = '\0'; // 纭繚缁撳熬鏄�'\0' @@ -1213,13 +1208,11 @@ int group_idx = 0; // 瀵规瘡涓�缁勮繘琛屽尮閰� - while (token != NULL && group_idx < num_tags) - { + while (token != NULL && group_idx < num_tags) { int match_found = 0; // 妫�鏌ュ綋鍓嶇粍鐨勬瘡涓�夐」鏄惁涓庤緭鍏ョ殑 token 鍖归厤 printf("Checking input token: '%s' against group %d options\n", token, group_idx + 1); // Debug info - for (int i = 0; i < MAX_OPTION_LEN && options[group_idx][i][0] != '\0'; i++) - { + for (int i = 0; i < MAX_OPTION_LEN && options[group_idx][i][0] != '\0'; i++) { printf(" Comparing with option: '%s'\n", options[group_idx][i]); // Debug info if (strcmp(options[group_idx][i], token) == 0) { match_found = 1; @@ -1240,6 +1233,7 @@ return (group_idx == num_tags); } + // 娴嬭瘯鍖归厤鍑芥暟 bool test_match(const char* pattern, const char* command) { -- Gitblit v1.9.1