From fb41cc4b30792238eed235aa5c6a8a3ba47b87a6 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Thu, 28 Dec 2017 11:26:00 +0100 Subject: Fixed log pattern matching --- common/log.cpp | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) (limited to 'common') diff --git a/common/log.cpp b/common/log.cpp index bfc9d5e..e726cd5 100644 --- a/common/log.cpp +++ b/common/log.cpp @@ -289,18 +289,16 @@ static void collectDebugArea(const QString &debugArea) static bool containsItemStartingWith(const QByteArray &pattern, const QByteArrayList &list) { for (const auto &item : list) { + int start = 0; + int end = item.size(); if (item.startsWith('*')) { - auto stripped = item.mid(1); - if (stripped.endsWith('*')) { - stripped.chop(1); - } - if (pattern.contains(stripped)) { - return true; - } - } else { - if (pattern.contains(item)) { - return true; - } + start++; + } + if (item.endsWith('*')) { + end--; + } + if (pattern.contains(item.mid(start, end - start))) { + return true; } } return false; -- cgit v1.2.3