diff --git a/SystemTools.cxx b/SystemTools.cxx index b19f6f99f52251eeaa7ae2d778d402085e56f990..392ca8cc9621e916b347e21c070a38a5749aeb1a 100644 --- a/SystemTools.cxx +++ b/SystemTools.cxx @@ -2595,18 +2595,15 @@ kwsys_stl::string SystemTools::FindProgram( kwsys_stl::string tryPath; // first try with extensions if the os supports them - if(extensions.size()) + for(kwsys_stl::vector<kwsys_stl::string>::iterator i = + extensions.begin(); i != extensions.end(); ++i) { - for(kwsys_stl::vector<kwsys_stl::string>::iterator i = - extensions.begin(); i != extensions.end(); ++i) + tryPath = name; + tryPath += *i; + if(SystemTools::FileExists(tryPath.c_str()) && + !SystemTools::FileIsDirectory(tryPath.c_str())) { - tryPath = name; - tryPath += *i; - if(SystemTools::FileExists(tryPath.c_str()) && - !SystemTools::FileIsDirectory(tryPath.c_str())) - { - return SystemTools::CollapseFullPath(tryPath.c_str()); - } + return SystemTools::CollapseFullPath(tryPath.c_str()); } } // now try just the name @@ -2652,19 +2649,16 @@ kwsys_stl::string SystemTools::FindProgram( SystemTools::ReplaceString(*p, "\"", ""); #endif // first try with extensions - if(extensions.size()) + for(kwsys_stl::vector<kwsys_stl::string>::iterator ext + = extensions.begin(); ext != extensions.end(); ++ext) { - for(kwsys_stl::vector<kwsys_stl::string>::iterator ext - = extensions.begin(); ext != extensions.end(); ++ext) + tryPath = *p; + tryPath += name; + tryPath += *ext; + if(SystemTools::FileExists(tryPath.c_str()) && + !SystemTools::FileIsDirectory(tryPath.c_str())) { - tryPath = *p; - tryPath += name; - tryPath += *ext; - if(SystemTools::FileExists(tryPath.c_str()) && - !SystemTools::FileIsDirectory(tryPath.c_str())) - { - return SystemTools::CollapseFullPath(tryPath.c_str()); - } + return SystemTools::CollapseFullPath(tryPath.c_str()); } } // now try it without them