mirror of
https://github.com/MultiMC/MultiMC5.git
synced 2024-12-28 15:18:21 +00:00
NOISSUE Revert INI parser back to single pass
This commit is contained in:
parent
f87c890912
commit
d21700ee91
@ -28,20 +28,53 @@ INIFile::INIFile()
|
||||
|
||||
QString INIFile::unescape(QString orig)
|
||||
{
|
||||
return orig
|
||||
.replace("\\#", "#")
|
||||
.replace("\\t", "\t")
|
||||
.replace("\\n", "\n")
|
||||
.replace("\\\\", "\\");
|
||||
QString out;
|
||||
QChar prev = 0;
|
||||
for(auto c: orig)
|
||||
{
|
||||
if(prev == '\\')
|
||||
{
|
||||
if(c == 'n')
|
||||
out += '\n';
|
||||
else if(c == 't')
|
||||
out += '\t';
|
||||
else if(c == '#')
|
||||
out += '#';
|
||||
else
|
||||
out += c;
|
||||
prev = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(c == '\\')
|
||||
{
|
||||
prev = c;
|
||||
continue;
|
||||
}
|
||||
out += c;
|
||||
prev = 0;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
QString INIFile::escape(QString orig)
|
||||
{
|
||||
return orig
|
||||
.replace('\\', "\\\\")
|
||||
.replace('\n', "\\n")
|
||||
.replace('\t', "\\t")
|
||||
.replace('#', "\\#");
|
||||
QString out;
|
||||
for(auto c: orig)
|
||||
{
|
||||
if(c == '\n')
|
||||
out += "\\n";
|
||||
else if (c == '\t')
|
||||
out += "\\t";
|
||||
else if(c == '\\')
|
||||
out += "\\\\";
|
||||
else if(c == '#')
|
||||
out += "\\#";
|
||||
else
|
||||
out += c;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
bool INIFile::saveFile(QString fileName)
|
||||
|
Loading…
Reference in New Issue
Block a user