mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Whitespace skipping in Reader should not eat the newlines, previously it was impossible to load a string containing "\n\n"
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@909 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
+10
-9
@@ -234,13 +234,10 @@ void Reader::readLine(bool in_string) {
|
||||
size_t pos = line.find_first_of(_(':'), indent);
|
||||
if (trim(line).empty() || line.GetChar(indent) == _('#')) {
|
||||
// empty line or comment
|
||||
if (input->Eof())
|
||||
key.clear();
|
||||
else // Recursion allows skipping of blank lines.
|
||||
readLine(in_string);
|
||||
key.clear();
|
||||
return;
|
||||
}
|
||||
key = line.substr(indent, pos - indent);
|
||||
key = line.substr(indent, pos - indent);
|
||||
if (!ignore_invalid && !in_string && starts_with(key, _(" "))) {
|
||||
warning(_("key: '") + key + _("' starts with a space; only use TABs for indentation!"), 0, false);
|
||||
// try to fix up: 8 spaces is a tab
|
||||
@@ -306,15 +303,19 @@ const String& Reader::getValue() {
|
||||
} else if (value.empty()) {
|
||||
// a multiline string
|
||||
previous_value.clear();
|
||||
bool first = true;
|
||||
int pending_newlines = 0;
|
||||
// read all lines that are indented enough
|
||||
readLine(true);
|
||||
previous_line_number = line_number;
|
||||
while (indent >= expected_indent && !input->Eof()) {
|
||||
if (!first) previous_value += _('\n');
|
||||
first = false;
|
||||
previous_value.resize(previous_value.size() + pending_newlines, _('\n'));
|
||||
pending_newlines = 0;
|
||||
previous_value += line.substr(expected_indent); // strip expected indent
|
||||
readLine(true);
|
||||
do {
|
||||
readLine(true);
|
||||
pending_newlines++;
|
||||
// skip empty lines that are not indented enough
|
||||
} while(trim(line).empty() && indent < expected_indent && !input->Eof());
|
||||
}
|
||||
// moveNext(), but without the initial readLine()
|
||||
state = HANDLED;
|
||||
|
||||
Reference in New Issue
Block a user