fix build failure

This commit is contained in:
RickyRister 2025-03-12 02:49:54 -07:00
parent 2f1d97b5e0
commit b1d96a6cf8
2 changed files with 10 additions and 18 deletions

View file

@ -1,5 +1,6 @@
#include "parsehelpers.h" #include "parsehelpers.h"
#include <QChar>
#include <QRegularExpression> #include <QRegularExpression>
/** /**
@ -24,9 +25,8 @@
bool parseCipt(const QString &name, const QString &text) bool parseCipt(const QString &name, const QString &text)
{ {
// Try to split shortname on most non-alphanumeric characters (including _) // Try to split shortname on most non-alphanumeric characters (including _)
static QSet<QChar> exceptions = {'\'', '\"'}; auto isShortnameDivider = [](const QChar &c) {
static auto isShortnameDivider = [](const QChar &c) { return c == '_' || (!c.isLetterOrNumber() && c != '\'' && c != '\"');
return c == '_' || (!c.isLetterOrNumber() && !exceptions.contains(c));
}; };
// Try all possible shortnames. // Try all possible shortnames.
@ -37,7 +37,7 @@ bool parseCipt(const QString &name, const QString &text)
if (isShortnameDivider(name.at(i))) { if (isShortnameDivider(name.at(i))) {
if (inAlphanumericPart) { if (inAlphanumericPart) {
// only add to names on a "falling edge", in order to reduce the amount of redundant splits // only add to names on a "falling edge", in order to reduce the amount of redundant splits
possibleNames.append(QRegularExpression::escape(name.first(i))); possibleNames.append(QRegularExpression::escape(name.left(i)));
inAlphanumericPart = false; inAlphanumericPart = false;
} }
} else { } else {

View file

@ -1,19 +1,11 @@
add_executable( add_executable(parse_cipt_test ../../oracle/src/parsehelpers.cpp parse_cipt_test.cpp)
parse_cipt_test
../../oracle/src/parsehelpers.cpp
parse_cipt_test.cpp
)
if (NOT GTEST_FOUND) if(NOT GTEST_FOUND)
add_dependencies(parse_cipt_test gtest) add_dependencies(parse_cipt_test gtest)
endif () endif()
set(TEST_QT_MODULES set(TEST_QT_MODULES ${COCKATRICE_QT_VERSION_NAME}::Widgets)
${COCKATRICE_QT_VERSION_NAME}::Widgets
)
target_link_libraries( target_link_libraries(parse_cipt_test cockatrice_common Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES})
parse_cipt_test cockatrice_common Threads::Threads ${GTEST_BOTH_LIBRARIES} ${TEST_QT_MODULES}
)
add_test(NAME parse_cipt_test COMMAND parse_cipt_test) add_test(NAME parse_cipt_test COMMAND parse_cipt_test)