mirror of https://github.com/stella-emu/stella.git
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:
parent
f3aaf17021
commit
a5d200e6ef
|
@ -96,37 +96,27 @@ void Properties::load(istream& in)
|
||||||
{
|
{
|
||||||
setDefaults();
|
setDefaults();
|
||||||
|
|
||||||
string line, key, value;
|
|
||||||
string::size_type one, two, three, four, garbage;
|
|
||||||
|
|
||||||
// Loop reading properties
|
// Loop reading properties
|
||||||
while(getline(in, line))
|
string key, value;
|
||||||
|
for(;;)
|
||||||
{
|
{
|
||||||
// Strip all tabs from the line
|
// Get the key associated with this property
|
||||||
while((garbage = line.find("\t")) != string::npos)
|
key = readQuotedString(in);
|
||||||
line.erase(garbage, 1);
|
|
||||||
|
|
||||||
// Ignore commented and empty lines
|
// Make sure the stream is still okay
|
||||||
if((line.length() == 0) || (line[0] == ';'))
|
if(!in)
|
||||||
continue;
|
return;
|
||||||
|
|
||||||
// End of this record
|
// A null key signifies the end of the property list
|
||||||
if(line == "\"\"")
|
if(key == "")
|
||||||
break;
|
break;
|
||||||
|
|
||||||
one = line.find("\"", 0);
|
// Get the value associated with this property
|
||||||
two = line.find("\"", one + 1);
|
value = readQuotedString(in);
|
||||||
three = line.find("\"", two + 1);
|
|
||||||
four = line.find("\"", three + 1);
|
|
||||||
|
|
||||||
// Invalid line if it doesn't contain 4 quotes
|
// Make sure the stream is still okay
|
||||||
if((one == string::npos) || (two == string::npos) ||
|
if(!in)
|
||||||
(three == string::npos) || (four == string::npos))
|
return;
|
||||||
break;
|
|
||||||
|
|
||||||
// Otherwise get the key and value
|
|
||||||
key = line.substr(one + 1, two - one - 1);
|
|
||||||
value = line.substr(three + 1, four - three - 1);
|
|
||||||
|
|
||||||
// Set the property
|
// Set the property
|
||||||
PropertyType type = getPropertyType(key);
|
PropertyType type = getPropertyType(key);
|
||||||
|
@ -170,31 +160,21 @@ string Properties::readQuotedString(istream& in)
|
||||||
while(in.get(c))
|
while(in.get(c))
|
||||||
{
|
{
|
||||||
if(c == '"')
|
if(c == '"')
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Read characters until we see the close quote
|
// Read characters until we see the close quote
|
||||||
string s;
|
string s;
|
||||||
while(in.get(c))
|
while(in.get(c))
|
||||||
{
|
{
|
||||||
if((c == '\\') && (in.peek() == '"'))
|
if((c == '\\') && (in.peek() == '"'))
|
||||||
{
|
|
||||||
in.get(c);
|
in.get(c);
|
||||||
}
|
|
||||||
else if((c == '\\') && (in.peek() == '\\'))
|
else if((c == '\\') && (in.peek() == '\\'))
|
||||||
{
|
|
||||||
in.get(c);
|
in.get(c);
|
||||||
}
|
|
||||||
else if(c == '"')
|
else if(c == '"')
|
||||||
{
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
else if(c == '\r')
|
else if(c == '\r')
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
s += c;
|
s += c;
|
||||||
}
|
}
|
||||||
|
@ -219,10 +199,8 @@ void Properties::writeQuotedString(ostream& out, const string& s)
|
||||||
out.put('"');
|
out.put('"');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
out.put(s[i]);
|
out.put(s[i]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
out.put('"');
|
out.put('"');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,7 +77,7 @@ void EditableWidget::setEditable(bool editable)
|
||||||
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
bool EditableWidget::tryInsertChar(char c, int pos)
|
bool EditableWidget::tryInsertChar(char c, int pos)
|
||||||
{
|
{
|
||||||
if (isprint(c) && c != '\"' && c != '\\')
|
if(isprint(c) && c != '\"')
|
||||||
{
|
{
|
||||||
_editString.insert(pos, 1, c);
|
_editString.insert(pos, 1, c);
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue