mirror of https://github.com/stella-emu/stella.git
Changed the parsing of lines in the settings file. Instead of stripping
all the whitespace in line, first split the line into key/value pairs (split by '=' sign), then trim whitespace from beginning and end of both the key and the value. This fixes the bug where settings that must contain spaces (pathnames) are garbled when they have internal spaces removed. git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@298 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
c64b9a6889
commit
14728bf2cc
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Settings.cxx,v 1.24 2004-07-07 22:46:01 stephena Exp $
|
||||
// $Id: Settings.cxx,v 1.25 2004-07-09 00:27:39 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#include <cassert>
|
||||
|
@ -84,8 +84,6 @@ void Settings::loadConfig()
|
|||
{
|
||||
// Strip all whitespace and tabs from the line
|
||||
uInt32 garbage;
|
||||
while((garbage = line.find(" ")) != string::npos)
|
||||
line.erase(garbage, 1);
|
||||
while((garbage = line.find("\t")) != string::npos)
|
||||
line.erase(garbage, 1);
|
||||
|
||||
|
@ -97,8 +95,11 @@ void Settings::loadConfig()
|
|||
if((equalPos = line.find("=")) == string::npos)
|
||||
continue;
|
||||
|
||||
// Split the line into key/value pairs and trim any whitespace
|
||||
key = line.substr(0, equalPos);
|
||||
value = line.substr(equalPos + 1, line.length() - key.length() - 1);
|
||||
key = trim(key);
|
||||
value = trim(value);
|
||||
|
||||
// Check for absent key or value
|
||||
if((key.length() == 0) || (value.length() == 0))
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
// See the file "license" for information on usage and redistribution of
|
||||
// this file, and for a DISCLAIMER OF ALL WARRANTIES.
|
||||
//
|
||||
// $Id: Settings.hxx,v 1.15 2004-07-07 22:46:01 stephena Exp $
|
||||
// $Id: Settings.hxx,v 1.16 2004-07-09 00:27:39 stephena Exp $
|
||||
//============================================================================
|
||||
|
||||
#ifndef SETTINGS_HXX
|
||||
|
@ -26,7 +26,7 @@
|
|||
This class provides an interface for accessing frontend specific settings.
|
||||
|
||||
@author Stephen Anthony
|
||||
@version $Id: Settings.hxx,v 1.15 2004-07-07 22:46:01 stephena Exp $
|
||||
@version $Id: Settings.hxx,v 1.16 2004-07-09 00:27:39 stephena Exp $
|
||||
*/
|
||||
class Settings
|
||||
{
|
||||
|
@ -243,6 +243,14 @@ class Settings
|
|||
// Assignment operator isn't supported by this class so make it private
|
||||
Settings& operator = (const Settings&);
|
||||
|
||||
// Trim leading and following whitespace from a string
|
||||
string trim(string& str)
|
||||
{
|
||||
string::size_type first = str.find_first_not_of(' ');
|
||||
return (first == string::npos) ? string() :
|
||||
str.substr(first, str.find_last_not_of(' ')-first+1);
|
||||
}
|
||||
|
||||
// Current capacity of the settings array
|
||||
unsigned int myCapacity;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue