From 2c180c465191b1ad7fc196a455c78a7224f0a692 Mon Sep 17 00:00:00 2001 From: David Hampton Date: Sun, 14 Feb 2021 17:20:32 -0500 Subject: [PATCH] eitfixup: Convert Finnish fixups to QRegularExpression. --- mythtv/libs/libmythtv/eitfixup.cpp | 46 +++++++++---------- mythtv/libs/libmythtv/eitfixup.h | 6 +-- .../test/test_eitfixups/test_eitfixups.cpp | 6 +-- 3 files changed, 24 insertions(+), 34 deletions(-) diff --git a/mythtv/libs/libmythtv/eitfixup.cpp b/mythtv/libs/libmythtv/eitfixup.cpp index eb1332fa936..19d1f697b0f 100644 --- a/mythtv/libs/libmythtv/eitfixup.cpp +++ b/mythtv/libs/libmythtv/eitfixup.cpp @@ -46,11 +46,7 @@ int EITFixUp::parseRoman (QString roman) EITFixUp::EITFixUp() - : m_fiRerun(R"(\ ?Uusinta[a-zA-Z\ ]*\.?)"), - m_fiRerun2("\\([Uu]\\)"), - m_fiAgeLimit("\\(((1?[0-9]?)|[ST])\\)$"), - m_fiFilm("^(Film|Elokuva): "), - m_nlTxt("txt"), + : m_nlTxt("txt"), m_nlWide("breedbeeld"), m_nlRepeat("herh."), m_nlHD("\\sHD$"), @@ -1909,53 +1905,55 @@ void EITFixUp::FixATV(DBEventEIT &event) } -/** \fn EITFixUp::FixFI(DBEventEIT&) const +/** * \brief Use this to clean DVB-T guide in Finland. */ -void EITFixUp::FixFI(DBEventEIT &event) const +void EITFixUp::FixFI(DBEventEIT &event) { - int position = event.m_description.indexOf(m_fiRerun); - if (position != -1) + QRegularExpression fiRerun { R"(\s?Uusinta[a-zA-Z\s]*\.?)" }; + auto match = fiRerun.match(event.m_description); + if (match.hasMatch()) { event.m_previouslyshown = true; - event.m_description = event.m_description.replace(m_fiRerun, ""); + event.m_description.remove(match.capturedStart(), match.capturedLength()); } - position = event.m_description.indexOf(m_fiRerun2); - if (position != -1) + QRegularExpression fiRerun2 { R"(\([Uu]\))" }; + match = fiRerun2.match(event.m_description); + if (match.hasMatch()) { event.m_previouslyshown = true; - event.m_description = event.m_description.replace(m_fiRerun2, ""); + event.m_description.remove(match.capturedStart(), match.capturedLength()); } // Check for (Stereo) in the decription and set the