Commit 28d17e64 authored by Bill Hoffman's avatar Bill Hoffman
Browse files

ENH: search for program without extensions

parent 55bb42d9
...@@ -2018,7 +2018,7 @@ kwsys_stl::string SystemTools::FindProgram( ...@@ -2018,7 +2018,7 @@ kwsys_stl::string SystemTools::FindProgram(
} }
kwsys_stl::string name = nameIn; kwsys_stl::string name = nameIn;
kwsys_stl::vector<kwsys_stl::string> extensions; kwsys_stl::vector<kwsys_stl::string> extensions;
#if defined (_WIN32) || defined(__CYGWIN__) | defined(__MINGW32__) #if defined (_WIN32) || defined(__CYGWIN__) || defined(__MINGW32__)
bool hasExtension = false; bool hasExtension = false;
// check to see if the name already has a .xxx at // check to see if the name already has a .xxx at
// the end of it // the end of it
...@@ -2034,8 +2034,8 @@ kwsys_stl::string SystemTools::FindProgram( ...@@ -2034,8 +2034,8 @@ kwsys_stl::string SystemTools::FindProgram(
} }
#endif #endif
kwsys_stl::string tryPath; kwsys_stl::string tryPath;
// first try the name as it was given (adding extensions
// if needed.) // first try with extensions if the os supports them
if(extensions.size()) if(extensions.size())
{ {
for(kwsys_stl::vector<kwsys_stl::string>::iterator i = for(kwsys_stl::vector<kwsys_stl::string>::iterator i =
...@@ -2050,15 +2050,13 @@ kwsys_stl::string SystemTools::FindProgram( ...@@ -2050,15 +2050,13 @@ kwsys_stl::string SystemTools::FindProgram(
} }
} }
} }
else // now try just the name
{
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()))
{ {
return SystemTools::CollapseFullPath(tryPath.c_str()); return SystemTools::CollapseFullPath(tryPath.c_str());
} }
}
// now construct the path // now construct the path
kwsys_stl::vector<kwsys_stl::string> path; kwsys_stl::vector<kwsys_stl::string> path;
// Add the system search path to our path. // Add the system search path to our path.
...@@ -2080,6 +2078,7 @@ kwsys_stl::string SystemTools::FindProgram( ...@@ -2080,6 +2078,7 @@ kwsys_stl::string SystemTools::FindProgram(
// Remove double quotes from the path on windows // Remove double quotes from the path on windows
SystemTools::ReplaceString(*p, "\"", ""); SystemTools::ReplaceString(*p, "\"", "");
#endif #endif
// first try with extensions
if(extensions.size()) if(extensions.size())
{ {
for(kwsys_stl::vector<kwsys_stl::string>::iterator ext for(kwsys_stl::vector<kwsys_stl::string>::iterator ext
...@@ -2096,8 +2095,7 @@ kwsys_stl::string SystemTools::FindProgram( ...@@ -2096,8 +2095,7 @@ kwsys_stl::string SystemTools::FindProgram(
} }
} }
} }
else // now try it without them
{
tryPath = *p; tryPath = *p;
tryPath += "/"; tryPath += "/";
tryPath += name; tryPath += name;
...@@ -2107,7 +2105,6 @@ kwsys_stl::string SystemTools::FindProgram( ...@@ -2107,7 +2105,6 @@ kwsys_stl::string SystemTools::FindProgram(
return SystemTools::CollapseFullPath(tryPath.c_str()); return SystemTools::CollapseFullPath(tryPath.c_str());
} }
} }
}
// Couldn't find the program. // Couldn't find the program.
return ""; return "";
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment