1
0
Fork 0

Fix bug #395 DOSBox can't handle double-quoted values in dosbox.conf files.

Extend the fix to include single quoted values.
Fix a common typo: Separator => Separator


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3950
This commit is contained in:
Peter Veenstra 2015-10-20 17:06:29 +00:00
parent b2bcdaf1ef
commit 76a04f0807
2 changed files with 20 additions and 12 deletions

View file

@ -294,10 +294,10 @@ public:
class Prop_multival:public Property{
protected:
Section_prop* section;
std::string seperator;
std::string separator;
void make_default_value();
public:
Prop_multival(std::string const& _propname, Changeable::Value when,std::string const& sep):Property(_propname,when), section(new Section_prop("")),seperator(sep) {
Prop_multival(std::string const& _propname, Changeable::Value when,std::string const& sep):Property(_propname,when), section(new Section_prop("")),separator(sep) {
default_value = value = "";
}
Section_prop *GetSection() { return section; }

View file

@ -339,7 +339,7 @@ void Prop_multival::make_default_value(){
while( (p = section->Get_prop(i++)) ) {
std::string props = p->Get_Default_Value().ToString();
if(props == "") continue;
result += seperator; result += props;
result += separator; result += props;
}
Value val(result,Value::V_STRING);
SetVal(val,false,true);
@ -363,14 +363,14 @@ bool Prop_multival_remain::SetValue(std::string const& input) {
string::size_type loc = string::npos;
while( (p = section->Get_prop(i++)) ) {
//trim leading seperators
loc = local.find_first_not_of(seperator);
//trim leading separators
loc = local.find_first_not_of(separator);
if(loc != string::npos) local.erase(0,loc);
loc = local.find_first_of(seperator);
loc = local.find_first_of(separator);
string in = "";//default value
/* when i == number_of_properties add the total line. (makes more then
* one string argument possible for parameters of cpu) */
if(loc != string::npos && i < number_of_properties) { //seperator found
if(loc != string::npos && i < number_of_properties) { //separator found
in = local.substr(0,loc);
local.erase(0,loc+1);
} else if(local.size()) { //last argument or last property
@ -400,12 +400,12 @@ bool Prop_multival::SetValue(std::string const& input) {
if(!p) return false;
string::size_type loc = string::npos;
while( (p = section->Get_prop(i++)) ) {
//trim leading seperators
loc = local.find_first_not_of(seperator);
//trim leading separators
loc = local.find_first_not_of(separator);
if(loc != string::npos) local.erase(0,loc);
loc = local.find_first_of(seperator);
loc = local.find_first_of(separator);
string in = "";//default value
if(loc != string::npos) { //seperator found
if(loc != string::npos) { //separator found
in = local.substr(0,loc);
local.erase(0,loc+1);
} else if(local.size()) { //last argument
@ -588,9 +588,17 @@ bool Section_prop::HandleInputline(string const& gegevens){
if(loc == string::npos) return false;
string name = str1.substr(0,loc);
string val = str1.substr(loc + 1);
/* Remove quotes around value */
trim(val);
string::size_type length = val.length();
if (length > 1 &&
((val[0] == '"' && val[length - 1] == '"' ) ||
(val[0] == '\'' && val[length - 1] == '\''))
) val = val.substr(1,length - 2);
/* trim the results incase there were spaces somewhere */
trim(name);trim(val);
for(it tel=properties.begin();tel!=properties.end();tel++){
for(it tel = properties.begin();tel != properties.end();tel++){
if(!strcasecmp((*tel)->propname.c_str(),name.c_str())){
return (*tel)->SetValue(val);
}