diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2022-06-27 02:22:29 (GMT) |
---|---|---|
committer | Alex Turbov <i.zaufi@gmail.com> | 2022-07-11 13:14:01 (GMT) |
commit | b5f880d5c69b72dcebd41cd0e5de6a82cdd5bbb2 (patch) | |
tree | 8f61f4aa57eea6baa3c1c8f38ddfdd2809ad4330 /Source/cmFindPackageCommand.cxx | |
parent | 045e36fe368df43d555ab0e7261207a79fef9bcc (diff) | |
download | CMake-b5f880d5c69b72dcebd41cd0e5de6a82cdd5bbb2.zip CMake-b5f880d5c69b72dcebd41cd0e5de6a82cdd5bbb2.tar.gz CMake-b5f880d5c69b72dcebd41cd0e5de6a82cdd5bbb2.tar.bz2 |
cmFindPackageCommand: Deduplicate code to exclude `.` and `..` dir entries
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 18a12c4..8fcfa22 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -2152,6 +2152,7 @@ public: protected: bool Consider(std::string const& fullPath, cmFileList& listing); + static bool IsIgnoredEntry(const char* fname); private: bool Search(cmFileList&); @@ -2236,6 +2237,12 @@ bool cmFileListGeneratorBase::Consider(std::string const& fullPath, return listing.Visit(fullPath + '/'); } +bool cmFileListGeneratorBase::IsIgnoredEntry(const char* const fname) +{ + assert(fname != nullptr); + return strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0; +} + class cmFileListGeneratorFixed : public cmFileListGeneratorBase { public: @@ -2330,7 +2337,7 @@ private: d.Load(parent); for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) { const char* fname = d.GetFile(i); - if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) { + if (this->IsIgnoredEntry(fname)) { continue; } for (std::string const& n : this->Names) { @@ -2386,7 +2393,7 @@ private: d.Load(parent); for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) { const char* fname = d.GetFile(i); - if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) { + if (this->IsIgnoredEntry(fname)) { continue; } for (std::string name : this->Names) { @@ -2433,7 +2440,7 @@ private: d.Load(parent); for (unsigned long i = 0; i < d.GetNumberOfFiles(); ++i) { const char* fname = d.GetFile(i); - if (strcmp(fname, ".") == 0 || strcmp(fname, "..") == 0) { + if (this->IsIgnoredEntry(fname)) { continue; } if (cmsysString_strcasecmp(fname, this->String.c_str()) == 0) { |