ENH: Remove double slash

This commit is contained in:
Andy Cedilnik 2004-09-15 14:08:09 -04:00
parent df82ea0ad0
commit f545c5149f
2 changed files with 23 additions and 6 deletions

View File

@ -154,7 +154,8 @@ std::string cmGlob::ConvertExpression(const std::string& expr)
return res + "$"; return res + "$";
} }
void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only) void cmGlob::RecurseDirectory(std::string::size_type start,
const std::string& dir, bool dir_only)
{ {
cmsys::Directory d; cmsys::Directory d;
if ( !d.Load(dir.c_str()) ) if ( !d.Load(dir.c_str()) )
@ -174,14 +175,29 @@ void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only)
continue; continue;
} }
realname = dir + "/" + fname; if ( start == 0 )
{
realname = dir + fname;
}
else
{
realname = dir + "/" + fname;
}
#if defined( CM_GLOB_CASE_INDEPENDENT ) #if defined( CM_GLOB_CASE_INDEPENDENT )
// On Windows and apple, no difference between lower and upper case // On Windows and apple, no difference between lower and upper case
fname = cmsys::SystemTools::LowerCase(fname); fname = cmsys::SystemTools::LowerCase(fname);
#endif #endif
fullname = dir + "/" + fname; if ( start == 0 )
{
fullname = dir + fname;
}
else
{
fullname = dir + "/" + fname;
}
if ( !dir_only || !cmsys::SystemTools::FileIsDirectory(realname.c_str()) ) if ( !dir_only || !cmsys::SystemTools::FileIsDirectory(realname.c_str()) )
{ {
if ( m_Internals->Expressions[m_Internals->Expressions.size()-1].find(fname.c_str()) ) if ( m_Internals->Expressions[m_Internals->Expressions.size()-1].find(fname.c_str()) )
@ -191,7 +207,7 @@ void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only)
} }
if ( cmsys::SystemTools::FileIsDirectory(realname.c_str()) ) if ( cmsys::SystemTools::FileIsDirectory(realname.c_str()) )
{ {
this->RecurseDirectory(realname, dir_only); this->RecurseDirectory(start+1, realname, dir_only);
} }
} }
} }
@ -203,7 +219,7 @@ void cmGlob::ProcessDirectory(std::string::size_type start,
bool last = ( start == m_Internals->Expressions.size()-1 ); bool last = ( start == m_Internals->Expressions.size()-1 );
if ( last && m_Recurse ) if ( last && m_Recurse )
{ {
this->RecurseDirectory(dir, dir_only); this->RecurseDirectory(start, dir, dir_only);
return; return;
} }
cmsys::Directory d; cmsys::Directory d;

View File

@ -51,7 +51,8 @@ protected:
//! Process last directory, but only when recurse flags is on. That is //! Process last directory, but only when recurse flags is on. That is
// effectively like saying: /path/to/file/**/file // effectively like saying: /path/to/file/**/file
void RecurseDirectory(const std::string& dir, bool dir_only); void RecurseDirectory(std::string::size_type start,
const std::string& dir, bool dir_only);
//! Escape all non-alphanumeric characters in pattern. //! Escape all non-alphanumeric characters in pattern.
void Escape(int ch, char* buffer); void Escape(int ch, char* buffer);