Accept single path with no separator. Fixes issue 1.

This commit is contained in:
konrad_w 2011-04-24 20:00:03 +00:00
parent 0d586e75f0
commit 574afdeeac
2 changed files with 9 additions and 9 deletions

View File

@ -5,6 +5,7 @@
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <pwd.h> #include <pwd.h>
#include <stdlib.h> #include <stdlib.h>
#include <sstream>
/* /*
This class emulates the search path mechanism of dyld This class emulates the search path mechanism of dyld
@ -13,7 +14,7 @@
http://www.opensource.apple.com/source/dyld/dyld-97.1/src/dyld.cpp http://www.opensource.apple.com/source/dyld/dyld-97.1/src/dyld.cpp
*/ */
const char DynamicLoader::EnvironmentPathVariable::PATHS_SEPARATOR[] = ":"; const char DynamicLoader::EnvironmentPathVariable::PATHS_SEPARATOR = ':';
DynamicLoader::EnvironmentPathVariable::EnvironmentPathVariable() { DynamicLoader::EnvironmentPathVariable::EnvironmentPathVariable() {
// never call that explicitly // never call that explicitly
@ -29,13 +30,12 @@ DynamicLoader::EnvironmentPathVariable::EnvironmentPathVariable(const char* home
} }
if (!values.empty()) { if (!values.empty()) {
size_t start = 0; std::stringstream v(values);
size_t end; std::string item;
while ((end = values.find(PATHS_SEPARATOR)) != string::npos) { while (std::getline(v, item, PATHS_SEPARATOR)) {
addPath(values.substr(start, end-start)); addPath(item);
start = end+1; }
} } else {
} else {
setPaths(defaultValues); setPaths(defaultValues);
} }
} }

View File

@ -33,7 +33,7 @@ private:
void addPath(const string& path); void addPath(const string& path);
bool replaceHomeDirectory(string& path); bool replaceHomeDirectory(string& path);
StringList paths; StringList paths;
static const char PATHS_SEPARATOR[]; static const char PATHS_SEPARATOR;
const char* homePath; const char* homePath;
}; };