Re-enabled entering '\' in various text fields in the UI, now that

they're properly loaded and saved in the config files.  The code to
correctly load strings containing backslashes was already there over
7 years ago, and I deactivated it and never even noticed.  That must
be a new record for a long-standing bug :)


git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1812 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
stephena 2009-06-20 22:49:45 +00:00
parent f3aaf17021
commit a5d200e6ef
2 changed files with 15 additions and 37 deletions

View File

@ -96,37 +96,27 @@ void Properties::load(istream& in)
{
setDefaults();
string line, key, value;
string::size_type one, two, three, four, garbage;
// Loop reading properties
while(getline(in, line))
string key, value;
for(;;)
{
// Strip all tabs from the line
while((garbage = line.find("\t")) != string::npos)
line.erase(garbage, 1);
// Get the key associated with this property
key = readQuotedString(in);
// Ignore commented and empty lines
if((line.length() == 0) || (line[0] == ';'))
continue;
// Make sure the stream is still okay
if(!in)
return;
// End of this record
if(line == "\"\"")
// A null key signifies the end of the property list
if(key == "")
break;
one = line.find("\"", 0);
two = line.find("\"", one + 1);
three = line.find("\"", two + 1);
four = line.find("\"", three + 1);
// Get the value associated with this property
value = readQuotedString(in);
// Invalid line if it doesn't contain 4 quotes
if((one == string::npos) || (two == string::npos) ||
(three == string::npos) || (four == string::npos))
break;
// Otherwise get the key and value
key = line.substr(one + 1, two - one - 1);
value = line.substr(three + 1, four - three - 1);
// Make sure the stream is still okay
if(!in)
return;
// Set the property
PropertyType type = getPropertyType(key);
@ -170,9 +160,7 @@ string Properties::readQuotedString(istream& in)
while(in.get(c))
{
if(c == '"')
{
break;
}
}
// Read characters until we see the close quote
@ -180,21 +168,13 @@ string Properties::readQuotedString(istream& in)
while(in.get(c))
{
if((c == '\\') && (in.peek() == '"'))
{
in.get(c);
}
else if((c == '\\') && (in.peek() == '\\'))
{
in.get(c);
}
else if(c == '"')
{
break;
}
else if(c == '\r')
{
continue;
}
s += c;
}
@ -219,9 +199,7 @@ void Properties::writeQuotedString(ostream& out, const string& s)
out.put('"');
}
else
{
out.put(s[i]);
}
}
out.put('"');
}

View File

@ -77,7 +77,7 @@ void EditableWidget::setEditable(bool editable)
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
bool EditableWidget::tryInsertChar(char c, int pos)
{
if (isprint(c) && c != '\"' && c != '\\')
if(isprint(c) && c != '\"')
{
_editString.insert(pos, 1, c);
return true;