From bf8143c649292042de87c0cef63e6cb3c523388f Mon Sep 17 00:00:00 2001 From: nancy.liao <huihui.liao@greentest.com.cn> Date: 周四, 08 5月 2025 16:40:10 +0800 Subject: [PATCH] 修改了一些警告信息 --- libscpi/src/externinterface.cpp | 70 ++++++++++++++-------------------- 1 files changed, 29 insertions(+), 41 deletions(-) diff --git a/libscpi/src/externinterface.cpp b/libscpi/src/externinterface.cpp index 222a863..15153ed 100644 --- a/libscpi/src/externinterface.cpp +++ b/libscpi/src/externinterface.cpp @@ -82,52 +82,45 @@ } static bool match_all_segments(const std::vector<std::string>& stringList, - const std::vector<Segment>& vecSegment) - { - int currentIndex = 0; - for (size_t i = 0; i < vecSegment.size(); i++) + const std::vector<Segment>& vecSegment) { + size_t currentIndex = 0; + for (const auto& segment : vecSegment) { - auto currentSegment = vecSegment[i]; - - if (currentSegment.is_required) { - for (const auto& option : currentSegment.options) - { - //褰撶储寮昳ndex瓒呰繃杈撳叆鍙傛暟鐨勮瘝缁勫ぇ灏� 鍒欒〃绀哄懡浠や笉鍖归厤 - if(currentIndex >= stringList.size()) - { - return false; - } - if (stringList[currentIndex] != option) - { - return false; - } else { - currentIndex += 1; - } - break; - } - } - else if (currentSegment.is_variable) + if (currentIndex >= stringList.size()) { - if (stringList.size() == vecSegment.size()) + return false; + } + if (segment.is_required) + { + bool matched = false; + for (const auto& option : segment.options) { - auto vecTempSegments = currentSegment.options; - for (const auto& option : vecTempSegments) + if (stringList[currentIndex] == option) { - if (stringList[currentIndex] != option) - { - return false; - } else { - currentIndex += 1; - } + matched = true; break; } } + if (!matched) + { + return false; + } + currentIndex++; } - else { - currentIndex += 1; + else if (segment.is_variable) + { + // 鍙彉鍙傛暟锛氱洿鎺ヨ烦杩� + currentIndex++; + } else + { + + if (segment.options.empty() || stringList[currentIndex] != segment.options[0]) { + return false; + } + currentIndex++; } } - return true; + return currentIndex == stringList.size(); } static std::vector<Segment> extract_all_segments(const std::string& pattern) @@ -339,9 +332,4 @@ } return PatternParser::match_all_segments(inputList, segments) ? 1 : 0; -} - -CPatternResult *GetInstance() -{ - return g_pattern_results; } -- Gitblit v1.9.1