From 8d22e9f70a1653fc6620cc8b5389d1036ec27596 Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Wed, 23 Jul 2003 10:26:37 -0400 Subject: [PATCH] ENH: On windows and apple handle lowercase/upercase file name problem --- Source/cmGlob.cxx | 40 +++++++++++++++++++++++++++++++--------- 1 file changed, 31 insertions(+), 9 deletions(-) diff --git a/Source/cmGlob.cxx b/Source/cmGlob.cxx index 466f9c602..4e07eff9d 100644 --- a/Source/cmGlob.cxx +++ b/Source/cmGlob.cxx @@ -21,6 +21,7 @@ #include #include +#include class cmGlobInternal { @@ -51,7 +52,12 @@ void cmGlob::Escape(int ch, char* buffer) } else { +#if defined( _WIN32 ) || defined(APPLE) + // On Windows and apple, no difference between lower and upper case + sprintf(buffer, "%c", tolower(ch)); +#else sprintf(buffer, "%c", ch); +#endif } } @@ -147,17 +153,25 @@ void cmGlob::RecurseDirectory(const std::string& dir, bool dir_only) } unsigned long cc; std::string fullname; + std::string fname; for ( cc = 0; cc < d.GetNumberOfFiles(); cc ++ ) { - if ( strcmp(d.GetFile(cc), ".") == 0 || - strcmp(d.GetFile(cc), "..") == 0 ) + fname = d.GetFile(cc); + if ( strcmp(fname.c_str(), ".") == 0 || + strcmp(fname.c_str(), "..") == 0 ) { continue; } - fullname = dir + "/" + d.GetFile(cc); + +#if defined( _WIN32 ) || defined( APPLE ) + // On Windows and apple, no difference between lower and upper case + fname = cmsys::SystemTools::LowerCase(fname); +#endif + + fullname = dir + "/" + fname; if ( !dir_only || !cmsys::SystemTools::FileIsDirectory(fullname.c_str()) ) { - if ( m_Internals->Expressions[m_Internals->Expressions.size()-1].find(d.GetFile(cc)) ) + if ( m_Internals->Expressions[m_Internals->Expressions.size()-1].find(fname.c_str()) ) { m_Internals->Files.push_back(fullname); } @@ -185,20 +199,28 @@ void cmGlob::ProcessDirectory(std::string::size_type start, } unsigned long cc; std::string fullname; + std::string fname; for ( cc = 0; cc < d.GetNumberOfFiles(); cc ++ ) { - if ( strcmp(d.GetFile(cc), ".") == 0 || - strcmp(d.GetFile(cc), "..") == 0 ) + fname = d.GetFile(cc); + if ( strcmp(fname.c_str(), ".") == 0 || + strcmp(fname.c_str(), "..") == 0 ) { continue; } + +#if defined( _WIN32 ) || defined( APPLE ) + // On Windows and apple, no difference between lower and upper case + fname = cmsys::SystemTools::LowerCase(fname); +#endif + if ( start == 0 ) { - fullname = dir + d.GetFile(cc); + fullname = dir + fname; } else { - fullname = dir + "/" + d.GetFile(cc); + fullname = dir + "/" + fname; } if ( (!dir_only || !last) && !cmsys::SystemTools::FileIsDirectory(fullname.c_str()) ) @@ -206,7 +228,7 @@ void cmGlob::ProcessDirectory(std::string::size_type start, continue; } - if ( m_Internals->Expressions[start].find(d.GetFile(cc)) ) + if ( m_Internals->Expressions[start].find(fname.c_str()) ) { if ( last ) {