1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-23 14:11:34 +00:00

Replace QRegExp by QRegularExpression

This commit is contained in:
elsid 2023-02-05 13:30:26 +01:00
parent aee7716c3a
commit e92ada09af
No known key found for this signature in database
GPG key ID: 4DE04C198CBA7625

View file

@ -303,8 +303,8 @@ bool Config::LauncherSettings::setValue(const QString& sectionPrefix, const QStr
void Config::LauncherSettings::readFile(QTextStream& stream) void Config::LauncherSettings::readFile(QTextStream& stream)
{ {
const QRegExp sectionRe("^\\[([^]]+)\\]"); const QRegularExpression sectionRe("^\\[([^]]+)\\]$");
const QRegExp keyRe("^([^=]+)\\s*=\\s*(.+)$"); const QRegularExpression keyRe("^([^=]+)\\s*=\\s*(.+)$");
QString section; QString section;
@ -315,20 +315,22 @@ void Config::LauncherSettings::readFile(QTextStream& stream)
if (line.isEmpty() || line.startsWith("#")) if (line.isEmpty() || line.startsWith("#"))
continue; continue;
if (sectionRe.exactMatch(line)) const QRegularExpressionMatch sectionMatch = sectionRe.match(line);
if (sectionMatch.hasMatch())
{ {
section = sectionRe.cap(1); section = sectionMatch.captured(1);
continue; continue;
} }
if (section.isEmpty()) if (section.isEmpty())
continue; continue;
if (keyRe.indexIn(line) == -1) const QRegularExpressionMatch keyMatch = keyRe.match(line);
if (!keyMatch.hasMatch())
continue; continue;
const QString key = keyRe.cap(1).trimmed(); const QString key = keyMatch.captured(1).trimmed();
const QString value = keyRe.cap(2).trimmed(); const QString value = keyMatch.captured(2).trimmed();
if (!setValue(section, key, value)) if (!setValue(section, key, value))
Log(Debug::Warning) << "Unsupported setting in the launcher config file: section: " Log(Debug::Warning) << "Unsupported setting in the launcher config file: section: "