BUG: Make sure search paths never have double-slashes. Leading with two slashes (//) on cygwin looks like a network path and delays while waiting for a non-existent machine.

This commit is contained in:
Brad King 2008-01-20 17:24:46 -05:00
parent 9de44ef28a
commit c7b844ba3e
2 changed files with 46 additions and 13 deletions

View File

@ -101,6 +101,16 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
supportFrameworks = false; supportFrameworks = false;
} }
std::string framework; std::string framework;
// Add a trailing slash to all paths to aid the search process.
for(std::vector<std::string>::iterator i = this->SearchPaths.begin();
i != this->SearchPaths.end(); ++i)
{
std::string& p = *i;
if(p[p.size()-1] != '/')
{
p += "/";
}
}
// Use the search path to find the file. // Use the search path to find the file.
unsigned int k; unsigned int k;
std::string result; std::string result;
@ -122,7 +132,6 @@ bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
if(result.size() == 0) if(result.size() == 0)
{ {
tryPath = this->SearchPaths[k]; tryPath = this->SearchPaths[k];
tryPath += "/";
tryPath += this->Names[j]; tryPath += this->Names[j];
if(cmSystemTools::FileExists(tryPath.c_str())) if(cmSystemTools::FileExists(tryPath.c_str()))
{ {
@ -181,7 +190,6 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string& file,
if(frameWorkName.size()) if(frameWorkName.size())
{ {
std::string fpath = dir; std::string fpath = dir;
fpath += "/";
fpath += frameWorkName; fpath += frameWorkName;
fpath += ".framework"; fpath += ".framework";
std::string intPath = fpath; std::string intPath = fpath;
@ -200,7 +208,7 @@ std::string cmFindPathCommand::FindHeaderInFramework(std::string& file,
// if it is not found yet or not a framework header, then do a glob search // if it is not found yet or not a framework header, then do a glob search
// for all files in dir/*/Headers/ // for all files in dir/*/Headers/
cmStdString glob = dir; cmStdString glob = dir;
glob += "/*/Headers/"; glob += "*/Headers/";
glob += file; glob += file;
cmsys::Glob globIt; cmsys::Glob globIt;
globIt.FindFiles(glob); globIt.FindFiles(glob);

View File

@ -2112,13 +2112,22 @@ kwsys_stl::string SystemTools
{ {
path.push_back(*i); path.push_back(*i);
} }
// Add a trailing slash to all paths to aid the search process.
for(kwsys_stl::vector<kwsys_stl::string>::iterator i = path.begin();
i != path.end(); ++i)
{
kwsys_stl::string& p = *i;
if(p[p.size()-1] != '/')
{
p += "/";
}
}
// now look for the file // now look for the file
kwsys_stl::string tryPath; kwsys_stl::string tryPath;
for(kwsys_stl::vector<kwsys_stl::string>::const_iterator p = path.begin(); for(kwsys_stl::vector<kwsys_stl::string>::const_iterator p = path.begin();
p != path.end(); ++p) p != path.end(); ++p)
{ {
tryPath = *p; tryPath = *p;
tryPath += "/";
tryPath += name; tryPath += name;
if(SystemTools::FileExists(tryPath.c_str())) if(SystemTools::FileExists(tryPath.c_str()))
{ {
@ -2235,6 +2244,16 @@ kwsys_stl::string SystemTools::FindProgram(
{ {
path.push_back(*i); path.push_back(*i);
} }
// Add a trailing slash to all paths to aid the search process.
for(kwsys_stl::vector<kwsys_stl::string>::iterator i = path.begin();
i != path.end(); ++i)
{
kwsys_stl::string& p = *i;
if(p[p.size()-1] != '/')
{
p += "/";
}
}
// Try each path // Try each path
for(kwsys_stl::vector<kwsys_stl::string>::iterator p = path.begin(); for(kwsys_stl::vector<kwsys_stl::string>::iterator p = path.begin();
p != path.end(); ++p) p != path.end(); ++p)
@ -2250,7 +2269,6 @@ kwsys_stl::string SystemTools::FindProgram(
= extensions.begin(); ext != extensions.end(); ++ext) = extensions.begin(); ext != extensions.end(); ++ext)
{ {
tryPath = *p; tryPath = *p;
tryPath += "/";
tryPath += name; tryPath += name;
tryPath += *ext; tryPath += *ext;
if(SystemTools::FileExists(tryPath.c_str()) && if(SystemTools::FileExists(tryPath.c_str()) &&
@ -2262,7 +2280,6 @@ kwsys_stl::string SystemTools::FindProgram(
} }
// now try it without them // now try it without them
tryPath = *p; tryPath = *p;
tryPath += "/";
tryPath += name; tryPath += name;
if(SystemTools::FileExists(tryPath.c_str()) && if(SystemTools::FileExists(tryPath.c_str()) &&
!SystemTools::FileIsDirectory(tryPath.c_str())) !SystemTools::FileIsDirectory(tryPath.c_str()))
@ -2319,13 +2336,22 @@ kwsys_stl::string SystemTools
{ {
path.push_back(*i); path.push_back(*i);
} }
// Add a trailing slash to all paths to aid the search process.
for(kwsys_stl::vector<kwsys_stl::string>::iterator i = path.begin();
i != path.end(); ++i)
{
kwsys_stl::string& p = *i;
if(p[p.size()-1] != '/')
{
p += "/";
}
}
kwsys_stl::string tryPath; kwsys_stl::string tryPath;
for(kwsys_stl::vector<kwsys_stl::string>::const_iterator p = path.begin(); for(kwsys_stl::vector<kwsys_stl::string>::const_iterator p = path.begin();
p != path.end(); ++p) p != path.end(); ++p)
{ {
#if defined(__APPLE__) #if defined(__APPLE__)
tryPath = *p; tryPath = *p;
tryPath += "/";
tryPath += name; tryPath += name;
tryPath += ".framework"; tryPath += ".framework";
if(SystemTools::FileExists(tryPath.c_str()) if(SystemTools::FileExists(tryPath.c_str())
@ -2336,7 +2362,6 @@ kwsys_stl::string SystemTools
#endif #endif
#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__) #if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__MINGW32__)
tryPath = *p; tryPath = *p;
tryPath += "/";
tryPath += name; tryPath += name;
tryPath += ".lib"; tryPath += ".lib";
if(SystemTools::FileExists(tryPath.c_str()) if(SystemTools::FileExists(tryPath.c_str())
@ -2346,7 +2371,7 @@ kwsys_stl::string SystemTools
} }
#else #else
tryPath = *p; tryPath = *p;
tryPath += "/lib"; tryPath += "lib";
tryPath += name; tryPath += name;
tryPath += ".so"; tryPath += ".so";
if(SystemTools::FileExists(tryPath.c_str()) if(SystemTools::FileExists(tryPath.c_str())
@ -2355,7 +2380,7 @@ kwsys_stl::string SystemTools
return SystemTools::CollapseFullPath(tryPath.c_str()); return SystemTools::CollapseFullPath(tryPath.c_str());
} }
tryPath = *p; tryPath = *p;
tryPath += "/lib"; tryPath += "lib";
tryPath += name; tryPath += name;
tryPath += ".a"; tryPath += ".a";
if(SystemTools::FileExists(tryPath.c_str()) if(SystemTools::FileExists(tryPath.c_str())
@ -2364,7 +2389,7 @@ kwsys_stl::string SystemTools
return SystemTools::CollapseFullPath(tryPath.c_str()); return SystemTools::CollapseFullPath(tryPath.c_str());
} }
tryPath = *p; tryPath = *p;
tryPath += "/lib"; tryPath += "lib";
tryPath += name; tryPath += name;
tryPath += ".sl"; tryPath += ".sl";
if(SystemTools::FileExists(tryPath.c_str()) if(SystemTools::FileExists(tryPath.c_str())
@ -2373,7 +2398,7 @@ kwsys_stl::string SystemTools
return SystemTools::CollapseFullPath(tryPath.c_str()); return SystemTools::CollapseFullPath(tryPath.c_str());
} }
tryPath = *p; tryPath = *p;
tryPath += "/lib"; tryPath += "lib";
tryPath += name; tryPath += name;
tryPath += ".dylib"; tryPath += ".dylib";
if(SystemTools::FileExists(tryPath.c_str()) if(SystemTools::FileExists(tryPath.c_str())
@ -2382,7 +2407,7 @@ kwsys_stl::string SystemTools
return SystemTools::CollapseFullPath(tryPath.c_str()); return SystemTools::CollapseFullPath(tryPath.c_str());
} }
tryPath = *p; tryPath = *p;
tryPath += "/lib"; tryPath += "lib";
tryPath += name; tryPath += name;
tryPath += ".dll"; tryPath += ".dll";
if(SystemTools::FileExists(tryPath.c_str()) if(SystemTools::FileExists(tryPath.c_str())