Browse Source

cmSystemTools: Let `GetFileFormat` accept a `std::stding const&`

The `const char*` used formerly was converted to a `std::string`
internally anyway.
Sebastian Holtermann 6 years ago
parent
commit
ed0fa784eb

+ 1 - 1
Source/cmExtraCodeLiteGenerator.cxx

@@ -223,7 +223,7 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
       for (cmSourceFile* s : sources) {
         // check whether it is a source or a include file
         // then put it accordingly into one of the two containers
-        switch (cmSystemTools::GetFileFormat(s->GetExtension().c_str())) {
+        switch (cmSystemTools::GetFileFormat(s->GetExtension())) {
           case cmSystemTools::C_FILE_FORMAT:
           case cmSystemTools::CXX_FILE_FORMAT:
           case cmSystemTools::CUDA_FILE_FORMAT:

+ 2 - 2
Source/cmQtAutoGenInitializer.cxx

@@ -679,7 +679,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
       // Register generated files that will be scanned by moc or uic
       if (this->Moc.Enabled || this->Uic.Enabled) {
         cmSystemTools::FileFormat const fileType =
-          cmSystemTools::GetFileFormat(ext.c_str());
+          cmSystemTools::GetFileFormat(ext);
         if ((fileType == cmSystemTools::CXX_FILE_FORMAT) ||
             (fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
           std::string const absPath = cmSystemTools::GetRealPath(fPath);
@@ -745,7 +745,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
           continue;
         }
         cmSystemTools::FileFormat const fileType =
-          cmSystemTools::GetFileFormat(sf->GetExtension().c_str());
+          cmSystemTools::GetFileFormat(sf->GetExtension());
         if (!(fileType == cmSystemTools::CXX_FILE_FORMAT) &&
             !(fileType == cmSystemTools::HEADER_FILE_FORMAT)) {
           continue;

+ 2 - 4
Source/cmSystemTools.cxx

@@ -1330,13 +1330,11 @@ bool cmSystemTools::SimpleGlob(const std::string& glob,
   return res;
 }
 
-cmSystemTools::FileFormat cmSystemTools::GetFileFormat(const char* cext)
+cmSystemTools::FileFormat cmSystemTools::GetFileFormat(std::string const& ext)
 {
-  if (!cext || *cext == 0) {
+  if (ext.empty()) {
     return cmSystemTools::NO_FILE_FORMAT;
   }
-  // std::string ext = cmSystemTools::LowerCase(cext);
-  std::string ext = cext;
   if (ext == "c" || ext == ".c" || ext == "m" || ext == ".m") {
     return cmSystemTools::C_FILE_FORMAT;
   }

+ 1 - 1
Source/cmSystemTools.h

@@ -334,7 +334,7 @@ public:
   /**
    * Determine the file type based on the extension
    */
-  static FileFormat GetFileFormat(const char* ext);
+  static FileFormat GetFileFormat(std::string const& ext);
 
   /** Windows if this is true, the CreateProcess in RunCommand will
    *  not show new console windows when running programs.