Merge pull request #2706 from Janrupf/feature/fix_hashtag_in_notes
Feature/fix hashtag in notes
This commit is contained in:
commit
2f1d31cf43
@ -36,8 +36,10 @@ QString INIFile::unescape(QString orig)
|
|||||||
{
|
{
|
||||||
if(c == 'n')
|
if(c == 'n')
|
||||||
out += '\n';
|
out += '\n';
|
||||||
else if (c == 't')
|
else if(c == 't')
|
||||||
out += '\t';
|
out += '\t';
|
||||||
|
else if(c == '#')
|
||||||
|
out += '#';
|
||||||
else
|
else
|
||||||
out += c;
|
out += c;
|
||||||
prev = 0;
|
prev = 0;
|
||||||
@ -67,6 +69,8 @@ QString INIFile::escape(QString orig)
|
|||||||
out += "\\t";
|
out += "\\t";
|
||||||
else if(c == '\\')
|
else if(c == '\\')
|
||||||
out += "\\\\";
|
out += "\\\\";
|
||||||
|
else if(c == '#')
|
||||||
|
out += "\\#";
|
||||||
else
|
else
|
||||||
out += c;
|
out += c;
|
||||||
}
|
}
|
||||||
@ -120,7 +124,15 @@ bool INIFile::loadFile(QByteArray file)
|
|||||||
{
|
{
|
||||||
QString &lineRaw = lines[i];
|
QString &lineRaw = lines[i];
|
||||||
// Ignore comments.
|
// Ignore comments.
|
||||||
QString line = lineRaw.left(lineRaw.indexOf('#')).trimmed();
|
int commentIndex = 0;
|
||||||
|
QString line = lineRaw;
|
||||||
|
// Search for comments until no more escaped # are available
|
||||||
|
while((commentIndex = line.indexOf('#', commentIndex + 1)) != -1) {
|
||||||
|
if(commentIndex > 0 && line.at(commentIndex - 1) == '\\') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
line = line.left(lineRaw.indexOf('#')).trimmed();
|
||||||
|
}
|
||||||
|
|
||||||
int eqPos = line.indexOf('=');
|
int eqPos = line.indexOf('=');
|
||||||
if (eqPos == -1)
|
if (eqPos == -1)
|
||||||
|
@ -26,6 +26,7 @@ slots:
|
|||||||
QTest::newRow("Plain text") << "Lorem ipsum dolor sit amet.";
|
QTest::newRow("Plain text") << "Lorem ipsum dolor sit amet.";
|
||||||
QTest::newRow("Escape sequences") << "Lorem\n\t\n\\n\\tAAZ\nipsum dolor\n\nsit amet.";
|
QTest::newRow("Escape sequences") << "Lorem\n\t\n\\n\\tAAZ\nipsum dolor\n\nsit amet.";
|
||||||
QTest::newRow("Escape sequences 2") << "\"\n\n\"";
|
QTest::newRow("Escape sequences 2") << "\"\n\n\"";
|
||||||
|
QTest::newRow("Hashtags") << "some data#something";
|
||||||
}
|
}
|
||||||
void test_Escape()
|
void test_Escape()
|
||||||
{
|
{
|
||||||
@ -40,7 +41,7 @@ slots:
|
|||||||
void test_SaveLoad()
|
void test_SaveLoad()
|
||||||
{
|
{
|
||||||
QString a = "a";
|
QString a = "a";
|
||||||
QString b = "a\nb\t\n\\\\\\C:\\Program files\\terrible\\name\\of something\\";
|
QString b = "a\nb\t\n\\\\\\C:\\Program files\\terrible\\name\\of something\\#thisIsNotAComment";
|
||||||
QString filename = "test_SaveLoad.ini";
|
QString filename = "test_SaveLoad.ini";
|
||||||
|
|
||||||
// save
|
// save
|
||||||
|
Loading…
Reference in New Issue
Block a user