From 76a04f0807d5550c31dcaf6ea15cf05d923c890b Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Tue, 20 Oct 2015 17:06:29 +0000 Subject: [PATCH] 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 --- include/setup.h | 4 ++-- src/misc/setup.cpp | 28 ++++++++++++++++++---------- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/include/setup.h b/include/setup.h index 7c8ad3dc..006cef67 100644 --- a/include/setup.h +++ b/include/setup.h @@ -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; } diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index 7251d2f8..eea76a20 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -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); }