From f545c5149fbc2034ca057cbb8a6e0823797a6c2c Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Wed, 15 Sep 2004 14:08:09 -0400 Subject: [PATCH] ENH: Remove double slash --- Source/cmGlob.cxx | 26 +++++++++++++++++++++----- Source/cmGlob.h | 3 ++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Source/cmGlob.cxx b/Source/cmGlob.cxx index 613bc3c13..bc1c2c127 100644 --- a/Source/cmGlob.cxx +++ b/Source/cmGlob.cxx @@ -154,7 +154,8 @@ std::string cmGlob::ConvertExpression(const std::string& expr) 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; if ( !d.Load(dir.c_str()) ) @@ -174,14 +175,29 @@ void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only) continue; } - realname = dir + "/" + fname; + if ( start == 0 ) + { + realname = dir + fname; + } + else + { + realname = dir + "/" + fname; + } #if defined( CM_GLOB_CASE_INDEPENDENT ) // On Windows and apple, no difference between lower and upper case fname = cmsys::SystemTools::LowerCase(fname); #endif - fullname = dir + "/" + fname; + if ( start == 0 ) + { + fullname = dir + fname; + } + else + { + fullname = dir + "/" + fname; + } + if ( !dir_only || !cmsys::SystemTools::FileIsDirectory(realname.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()) ) { - 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 ); if ( last && m_Recurse ) { - this->RecurseDirectory(dir, dir_only); + this->RecurseDirectory(start, dir, dir_only); return; } cmsys::Directory d; diff --git a/Source/cmGlob.h b/Source/cmGlob.h index 125cd7311..62e9d94b1 100644 --- a/Source/cmGlob.h +++ b/Source/cmGlob.h @@ -51,7 +51,8 @@ protected: //! Process last directory, but only when recurse flags is on. That is // 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. void Escape(int ch, char* buffer);