mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-08 09:37:53 +00:00
Allow space characters in front of comments.
This commit is contained in:
parent
15fe5d88e2
commit
4902c66792
@ -180,7 +180,7 @@ bool Config::GameSettings::writeFile(QTextStream &stream)
|
|||||||
//
|
//
|
||||||
// - If a line in file exists with matching key and first part of value (before ',',
|
// - If a line in file exists with matching key and first part of value (before ',',
|
||||||
// '\n', etc) also matches, then replace the line with that of mUserSettings.
|
// '\n', etc) also matches, then replace the line with that of mUserSettings.
|
||||||
// - else remove line (maybe replace the line with '#' in front instead?)
|
// - else remove line (TODO: maybe replace the line with '#' in front instead?)
|
||||||
//
|
//
|
||||||
// - If there is no corresponding line in file, add at the end
|
// - If there is no corresponding line in file, add at the end
|
||||||
//
|
//
|
||||||
@ -227,7 +227,7 @@ bool Config::GameSettings::writeFileWithComments(QFile &file)
|
|||||||
for (std::vector<QString>::iterator iter = fileCopy.begin(); iter != fileCopy.end(); ++iter)
|
for (std::vector<QString>::iterator iter = fileCopy.begin(); iter != fileCopy.end(); ++iter)
|
||||||
{
|
{
|
||||||
// skip empty or comment lines
|
// skip empty or comment lines
|
||||||
if ((*iter).isEmpty() || (*iter).startsWith("#"))
|
if ((*iter).isEmpty() || (*iter).contains(QRegExp("^\\s*#")))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// look for a key in the line
|
// look for a key in the line
|
||||||
@ -262,7 +262,9 @@ bool Config::GameSettings::writeFileWithComments(QFile &file)
|
|||||||
if ((*iter).isNull())
|
if ((*iter).isNull())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if ((*iter).isEmpty() || (*iter).startsWith("#"))
|
// Below is based on readFile() code, if that changes corresponding change may be
|
||||||
|
// required (for example duplicates may be inserted if the rules don't match)
|
||||||
|
if ((*iter).isEmpty() || (*iter).contains(QRegExp("^\\s*#")))
|
||||||
stream << *iter << "\n";
|
stream << *iter << "\n";
|
||||||
|
|
||||||
if (settingRegex.indexIn(*iter) == -1 || settingRegex.captureCount() < 2)
|
if (settingRegex.indexIn(*iter) == -1 || settingRegex.captureCount() < 2)
|
||||||
|
Loading…
Reference in New Issue
Block a user