Browse Source

cmDepends: all members accept std::string arguments

Most `const char*` arguments converted to `const std::string&`
in `cmDepends` and derived classes.
In addition performed minor code cleanup.
Vitaly Stakhovsky 6 years ago
parent
commit
2c50a72576

+ 8 - 7
Source/cmDepends.cxx

@@ -13,7 +13,7 @@
 #include <string.h>
 #include <string.h>
 #include <utility>
 #include <utility>
 
 
-cmDepends::cmDepends(cmLocalGenerator* lg, const char* targetDir)
+cmDepends::cmDepends(cmLocalGenerator* lg, const std::string& targetDir)
   : LocalGenerator(lg)
   : LocalGenerator(lg)
   , TargetDirectory(targetDir)
   , TargetDirectory(targetDir)
   , Dependee(new char[MaxPath])
   , Dependee(new char[MaxPath])
@@ -65,12 +65,13 @@ bool cmDepends::Finalize(std::ostream& /*unused*/, std::ostream& /*unused*/)
   return true;
   return true;
 }
 }
 
 
-bool cmDepends::Check(const char* makeFile, const char* internalFile,
+bool cmDepends::Check(const std::string& makeFile,
+                      const std::string& internalFile,
                       std::map<std::string, DependencyVector>& validDeps)
                       std::map<std::string, DependencyVector>& validDeps)
 {
 {
   // Check whether dependencies must be regenerated.
   // Check whether dependencies must be regenerated.
   bool okay = true;
   bool okay = true;
-  cmsys::ifstream fin(internalFile);
+  cmsys::ifstream fin(internalFile.c_str());
   if (!(fin && this->CheckDependencies(fin, internalFile, validDeps))) {
   if (!(fin && this->CheckDependencies(fin, internalFile, validDeps))) {
     // Clear all dependencies so they will be regenerated.
     // Clear all dependencies so they will be regenerated.
     this->Clear(makeFile);
     this->Clear(makeFile);
@@ -81,7 +82,7 @@ bool cmDepends::Check(const char* makeFile, const char* internalFile,
   return okay;
   return okay;
 }
 }
 
 
-void cmDepends::Clear(const char* file)
+void cmDepends::Clear(const std::string& file)
 {
 {
   // Print verbose output.
   // Print verbose output.
   if (this->Verbose) {
   if (this->Verbose) {
@@ -107,7 +108,7 @@ bool cmDepends::WriteDependencies(const std::set<std::string>& /*unused*/,
 }
 }
 
 
 bool cmDepends::CheckDependencies(
 bool cmDepends::CheckDependencies(
-  std::istream& internalDepends, const char* internalDependsFileName,
+  std::istream& internalDepends, const std::string& internalDependsFileName,
   std::map<std::string, DependencyVector>& validDeps)
   std::map<std::string, DependencyVector>& validDeps)
 {
 {
   // Parse dependencies from the stream.  If any dependee is missing
   // Parse dependencies from the stream.  If any dependee is missing
@@ -194,8 +195,8 @@ bool cmDepends::CheckDependencies(
         // The dependee exists, but the depender doesn't. Regenerate if the
         // The dependee exists, but the depender doesn't. Regenerate if the
         // internalDepends file is older than the dependee.
         // internalDepends file is older than the dependee.
         int result = 0;
         int result = 0;
-        if ((!this->FileComparison->FileTimeCompare(internalDependsFileName,
-                                                    dependee, &result) ||
+        if ((!this->FileComparison->FileTimeCompare(
+               internalDependsFileName.c_str(), dependee, &result) ||
              result < 0)) {
              result < 0)) {
           // The depends-file is older than the dependee.
           // The depends-file is older than the dependee.
           regenerate = true;
           regenerate = true;

+ 8 - 5
Source/cmDepends.h

@@ -29,7 +29,7 @@ class cmDepends
 public:
 public:
   /** Instances need to know the build directory name and the relative
   /** Instances need to know the build directory name and the relative
       path from the build directory to the target file.  */
       path from the build directory to the target file.  */
-  cmDepends(cmLocalGenerator* lg = nullptr, const char* targetDir = "");
+  cmDepends(cmLocalGenerator* lg = nullptr, const std::string& targetDir = "");
 
 
   /** Set the local generator for the directory in which we are
   /** Set the local generator for the directory in which we are
       scanning dependencies.  This is not a full local generator; it
       scanning dependencies.  This is not a full local generator; it
@@ -41,7 +41,10 @@ public:
   void SetLanguage(const std::string& lang) { this->Language = lang; }
   void SetLanguage(const std::string& lang) { this->Language = lang; }
 
 
   /** Set the target build directory.  */
   /** Set the target build directory.  */
-  void SetTargetDirectory(const char* dir) { this->TargetDirectory = dir; }
+  void SetTargetDirectory(const std::string& dir)
+  {
+    this->TargetDirectory = dir;
+  }
 
 
   /** should this be verbose in its output */
   /** should this be verbose in its output */
   void SetVerbose(bool verb) { this->Verbose = verb; }
   void SetVerbose(bool verb) { this->Verbose = verb; }
@@ -61,11 +64,11 @@ public:
       they must be generated Clear has already been called to wipe out
       they must be generated Clear has already been called to wipe out
       the old dependencies.
       the old dependencies.
       Dependencies which are still valid will be stored in validDeps. */
       Dependencies which are still valid will be stored in validDeps. */
-  bool Check(const char* makeFile, const char* internalFile,
+  bool Check(const std::string& makeFile, const std::string& internalFile,
              std::map<std::string, DependencyVector>& validDeps);
              std::map<std::string, DependencyVector>& validDeps);
 
 
   /** Clear dependencies for the target file so they will be regenerated.  */
   /** Clear dependencies for the target file so they will be regenerated.  */
-  void Clear(const char* file);
+  void Clear(const std::string& file);
 
 
   /** Set the file comparison object */
   /** Set the file comparison object */
   void SetFileComparison(cmFileTimeComparison* fc)
   void SetFileComparison(cmFileTimeComparison* fc)
@@ -85,7 +88,7 @@ protected:
   // Return false if dependencies must be regenerated and true
   // Return false if dependencies must be regenerated and true
   // otherwise.
   // otherwise.
   virtual bool CheckDependencies(
   virtual bool CheckDependencies(
-    std::istream& internalDepends, const char* internalDependsFileName,
+    std::istream& internalDepends, const std::string& internalDependsFileName,
     std::map<std::string, DependencyVector>& validDeps);
     std::map<std::string, DependencyVector>& validDeps);
 
 
   // Finalize the dependency information for the target.
   // Finalize the dependency information for the target.

+ 9 - 9
Source/cmDependsC.cxx

@@ -24,7 +24,7 @@ cmDependsC::cmDependsC()
 }
 }
 
 
 cmDependsC::cmDependsC(
 cmDependsC::cmDependsC(
-  cmLocalGenerator* lg, const char* targetDir, const std::string& lang,
+  cmLocalGenerator* lg, const std::string& targetDir, const std::string& lang,
   const std::map<std::string, DependencyVector>* validDeps)
   const std::map<std::string, DependencyVector>* validDeps)
   : cmDepends(lg, targetDir)
   : cmDepends(lg, targetDir)
   , ValidDeps(validDeps)
   , ValidDeps(validDeps)
@@ -53,8 +53,8 @@ cmDependsC::cmDependsC(
   }
   }
 
 
   this->IncludeRegexLine.compile(INCLUDE_REGEX_LINE);
   this->IncludeRegexLine.compile(INCLUDE_REGEX_LINE);
-  this->IncludeRegexScan.compile(scanRegex.c_str());
-  this->IncludeRegexComplain.compile(complainRegex.c_str());
+  this->IncludeRegexScan.compile(scanRegex);
+  this->IncludeRegexComplain.compile(complainRegex);
   this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE;
   this->IncludeRegexLineString = INCLUDE_REGEX_LINE_MARKER INCLUDE_REGEX_LINE;
   this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER;
   this->IncludeRegexScanString = INCLUDE_REGEX_SCAN_MARKER;
   this->IncludeRegexScanString += scanRegex;
   this->IncludeRegexScanString += scanRegex;
@@ -212,7 +212,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
               // Scan this file for new dependencies.  Pass the directory
               // Scan this file for new dependencies.  Pass the directory
               // containing the file to handle double-quote includes.
               // containing the file to handle double-quote includes.
               std::string dir = cmSystemTools::GetFilenamePath(fullName);
               std::string dir = cmSystemTools::GetFilenamePath(fullName);
-              this->Scan(fin, dir.c_str(), fullName);
+              this->Scan(fin, dir, fullName);
             } else {
             } else {
               // Skip file with encoding we do not implement.
               // Skip file with encoding we do not implement.
             }
             }
@@ -342,7 +342,7 @@ void cmDependsC::WriteCacheFile() const
   }
   }
 }
 }
 
 
-void cmDependsC::Scan(std::istream& is, const char* directory,
+void cmDependsC::Scan(std::istream& is, const std::string& directory,
                       const std::string& fullName)
                       const std::string& fullName)
 {
 {
   cmIncludeLines* newCacheEntry = new cmIncludeLines;
   cmIncludeLines* newCacheEntry = new cmIncludeLines;
@@ -418,7 +418,7 @@ void cmDependsC::SetupTransforms()
       sep = "|";
       sep = "|";
     }
     }
     xform += ")[ \t]*\\(([^),]*)\\)";
     xform += ")[ \t]*\\(([^),]*)\\)";
-    this->IncludeRegexTransform.compile(xform.c_str());
+    this->IncludeRegexTransform.compile(xform);
 
 
     // Build a string that encodes all transformation rules and will
     // Build a string that encodes all transformation rules and will
     // change when rules are changed.
     // change when rules are changed.
@@ -460,11 +460,11 @@ void cmDependsC::TransformLine(std::string& line)
   // Construct the transformed line.
   // Construct the transformed line.
   std::string newline = this->IncludeRegexTransform.match(1);
   std::string newline = this->IncludeRegexTransform.match(1);
   std::string arg = this->IncludeRegexTransform.match(4);
   std::string arg = this->IncludeRegexTransform.match(4);
-  for (const char* c = tri->second.c_str(); *c; ++c) {
-    if (*c == '%') {
+  for (char c : tri->second) {
+    if (c == '%') {
       newline += arg;
       newline += arg;
     } else {
     } else {
-      newline += *c;
+      newline += c;
     }
     }
   }
   }
 
 

+ 2 - 2
Source/cmDependsC.h

@@ -28,7 +28,7 @@ public:
   /** Checking instances need to know the build directory name and the
   /** Checking instances need to know the build directory name and the
       relative path from the build directory to the target file.  */
       relative path from the build directory to the target file.  */
   cmDependsC();
   cmDependsC();
-  cmDependsC(cmLocalGenerator* lg, const char* targetDir,
+  cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
              const std::string& lang,
              const std::string& lang,
              const std::map<std::string, DependencyVector>* validDeps);
              const std::map<std::string, DependencyVector>* validDeps);
 
 
@@ -42,7 +42,7 @@ protected:
                          std::ostream& internalDepends) override;
                          std::ostream& internalDepends) override;
 
 
   // Method to scan a single file.
   // Method to scan a single file.
-  void Scan(std::istream& is, const char* directory,
+  void Scan(std::istream& is, const std::string& directory,
             const std::string& fullName);
             const std::string& fullName);
 
 
   // Regular expression to identify C preprocessor include directives.
   // Regular expression to identify C preprocessor include directives.

+ 28 - 30
Source/cmDependsFortran.cxx

@@ -7,7 +7,6 @@
 #include <iostream>
 #include <iostream>
 #include <map>
 #include <map>
 #include <stdlib.h>
 #include <stdlib.h>
-#include <string.h>
 #include <utility>
 #include <utility>
 
 
 #include "cmAlgorithms.h"
 #include "cmAlgorithms.h"
@@ -54,7 +53,8 @@ public:
   typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
   typedef std::map<std::string, cmFortranSourceInfo> ObjectInfoMap;
   ObjectInfoMap ObjectInfo;
   ObjectInfoMap ObjectInfo;
 
 
-  cmFortranSourceInfo& CreateObjectInfo(const char* obj, const char* src)
+  cmFortranSourceInfo& CreateObjectInfo(const std::string& obj,
+                                        const std::string& src)
   {
   {
     std::map<std::string, cmFortranSourceInfo>::iterator i =
     std::map<std::string, cmFortranSourceInfo>::iterator i =
       this->ObjectInfo.find(obj);
       this->ObjectInfo.find(obj);
@@ -121,8 +121,7 @@ bool cmDependsFortran::WriteDependencies(const std::set<std::string>& sources,
   bool okay = true;
   bool okay = true;
   for (std::string const& src : sources) {
   for (std::string const& src : sources) {
     // Get the information object for this source.
     // Get the information object for this source.
-    cmFortranSourceInfo& info =
-      this->Internal->CreateObjectInfo(obj.c_str(), src.c_str());
+    cmFortranSourceInfo& info = this->Internal->CreateObjectInfo(obj, src);
 
 
     // Create the parser object. The constructor takes info by reference,
     // Create the parser object. The constructor takes info by reference,
     // so we may look into the resulting objects later.
     // so we may look into the resulting objects later.
@@ -153,7 +152,7 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
   this->LocateModules();
   this->LocateModules();
 
 
   // Get the directory in which stamp files will be stored.
   // Get the directory in which stamp files will be stored.
-  const char* stamp_dir = this->TargetDirectory.c_str();
+  const std::string& stamp_dir = this->TargetDirectory;
 
 
   // Get the directory in which module files will be created.
   // Get the directory in which module files will be created.
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
   cmMakefile* mf = this->LocalGenerator->GetMakefile();
@@ -167,9 +166,8 @@ bool cmDependsFortran::Finalize(std::ostream& makeDepends,
   typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
   typedef cmDependsFortranInternals::ObjectInfoMap ObjectInfoMap;
   ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
   ObjectInfoMap const& objInfo = this->Internal->ObjectInfo;
   for (auto const& i : objInfo) {
   for (auto const& i : objInfo) {
-    if (!this->WriteDependenciesReal(i.first.c_str(), i.second, mod_dir,
-                                     stamp_dir, makeDepends,
-                                     internalDepends)) {
+    if (!this->WriteDependenciesReal(i.first, i.second, mod_dir, stamp_dir,
+                                     makeDepends, internalDepends)) {
       return false;
       return false;
     }
     }
   }
   }
@@ -256,22 +254,22 @@ void cmDependsFortran::LocateModules()
     std::string fname = targetDir + "/fortran.internal";
     std::string fname = targetDir + "/fortran.internal";
     cmsys::ifstream fin(fname.c_str());
     cmsys::ifstream fin(fname.c_str());
     if (fin) {
     if (fin) {
-      this->MatchRemoteModules(fin, targetDir.c_str());
+      this->MatchRemoteModules(fin, targetDir);
     }
     }
   }
   }
 }
 }
 
 
 void cmDependsFortran::MatchLocalModules()
 void cmDependsFortran::MatchLocalModules()
 {
 {
-  const char* stampDir = this->TargetDirectory.c_str();
+  std::string const& stampDir = this->TargetDirectory;
   std::set<std::string> const& provides = this->Internal->TargetProvides;
   std::set<std::string> const& provides = this->Internal->TargetProvides;
   for (std::string const& i : provides) {
   for (std::string const& i : provides) {
-    this->ConsiderModule(i.c_str(), stampDir);
+    this->ConsiderModule(i, stampDir);
   }
   }
 }
 }
 
 
 void cmDependsFortran::MatchRemoteModules(std::istream& fin,
 void cmDependsFortran::MatchRemoteModules(std::istream& fin,
-                                          const char* stampDir)
+                                          const std::string& stampDir)
 {
 {
   std::string line;
   std::string line;
   bool doing_provides = false;
   bool doing_provides = false;
@@ -300,7 +298,8 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin,
   }
   }
 }
 }
 
 
-void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
+void cmDependsFortran::ConsiderModule(const std::string& name,
+                                      const std::string& stampDir)
 {
 {
   // Locate each required module.
   // Locate each required module.
   typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
   typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
@@ -317,17 +316,17 @@ void cmDependsFortran::ConsiderModule(const char* name, const char* stampDir)
   }
   }
 }
 }
 
 
-bool cmDependsFortran::WriteDependenciesReal(const char* obj,
+bool cmDependsFortran::WriteDependenciesReal(std::string const& obj,
                                              cmFortranSourceInfo const& info,
                                              cmFortranSourceInfo const& info,
                                              std::string const& mod_dir,
                                              std::string const& mod_dir,
-                                             const char* stamp_dir,
+                                             std::string const& stamp_dir,
                                              std::ostream& makeDepends,
                                              std::ostream& makeDepends,
                                              std::ostream& internalDepends)
                                              std::ostream& internalDepends)
 {
 {
   typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
   typedef cmDependsFortranInternals::TargetRequiresMap TargetRequiresMap;
 
 
   // Get the source file for this object.
   // Get the source file for this object.
-  const char* src = info.Source.c_str();
+  std::string const& src = info.Source;
 
 
   // Write the include dependencies to the output stream.
   // Write the include dependencies to the output stream.
   std::string binDir = this->LocalGenerator->GetBinaryDirectory();
   std::string binDir = this->LocalGenerator->GetBinaryDirectory();
@@ -502,8 +501,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
   cmFortranModuleAppendUpperLower(cmSystemTools::GetFilenameName(mod),
   cmFortranModuleAppendUpperLower(cmSystemTools::GetFilenameName(mod),
                                   mod_upper, mod_lower);
                                   mod_upper, mod_lower);
   if (cmSystemTools::FileExists(mod_upper, true)) {
   if (cmSystemTools::FileExists(mod_upper, true)) {
-    if (cmDependsFortran::ModulesDiffer(mod_upper.c_str(), stamp.c_str(),
-                                        compilerId.c_str())) {
+    if (cmDependsFortran::ModulesDiffer(mod_upper, stamp, compilerId)) {
       if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
       if (!cmSystemTools::CopyFileAlways(mod_upper, stamp)) {
         std::cerr << "Error copying Fortran module from \"" << mod_upper
         std::cerr << "Error copying Fortran module from \"" << mod_upper
                   << "\" to \"" << stamp << "\".\n";
                   << "\" to \"" << stamp << "\".\n";
@@ -513,8 +511,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args)
     return true;
     return true;
   }
   }
   if (cmSystemTools::FileExists(mod_lower, true)) {
   if (cmSystemTools::FileExists(mod_lower, true)) {
-    if (cmDependsFortran::ModulesDiffer(mod_lower.c_str(), stamp.c_str(),
-                                        compilerId.c_str())) {
+    if (cmDependsFortran::ModulesDiffer(mod_lower, stamp, compilerId)) {
       if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
       if (!cmSystemTools::CopyFileAlways(mod_lower, stamp)) {
         std::cerr << "Error copying Fortran module from \"" << mod_lower
         std::cerr << "Error copying Fortran module from \"" << mod_lower
                   << "\" to \"" << stamp << "\".\n";
                   << "\" to \"" << stamp << "\".\n";
@@ -581,9 +578,9 @@ static bool cmFortranStreamsDiffer(std::istream& ifs1, std::istream& ifs2)
   return true;
   return true;
 }
 }
 
 
-bool cmDependsFortran::ModulesDiffer(const char* modFile,
-                                     const char* stampFile,
-                                     const char* compilerId)
+bool cmDependsFortran::ModulesDiffer(const std::string& modFile,
+                                     const std::string& stampFile,
+                                     const std::string& compilerId)
 {
 {
   /*
   /*
   gnu >= 4.9:
   gnu >= 4.9:
@@ -617,16 +614,17 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
    * source is compiled twice
    * source is compiled twice
    *   -SunPro
    *   -SunPro
    */
    */
-  if (strcmp(compilerId, "SunPro") == 0) {
+  if (compilerId == "SunPro") {
     return cmSystemTools::FilesDiffer(modFile, stampFile);
     return cmSystemTools::FilesDiffer(modFile, stampFile);
   }
   }
 
 
 #if defined(_WIN32) || defined(__CYGWIN__)
 #if defined(_WIN32) || defined(__CYGWIN__)
-  cmsys::ifstream finModFile(modFile, std::ios::in | std::ios::binary);
-  cmsys::ifstream finStampFile(stampFile, std::ios::in | std::ios::binary);
+  cmsys::ifstream finModFile(modFile.c_str(), std::ios::in | std::ios::binary);
+  cmsys::ifstream finStampFile(stampFile.c_str(),
+                               std::ios::in | std::ios::binary);
 #else
 #else
-  cmsys::ifstream finModFile(modFile);
-  cmsys::ifstream finStampFile(stampFile);
+  cmsys::ifstream finModFile(modFile.c_str());
+  cmsys::ifstream finStampFile(stampFile.c_str());
 #endif
 #endif
   if (!finModFile || !finStampFile) {
   if (!finModFile || !finStampFile) {
     // At least one of the files does not exist.  The modules differ.
     // At least one of the files does not exist.  The modules differ.
@@ -641,7 +639,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
    * Eat the stream content until all recompile only related changes
    * Eat the stream content until all recompile only related changes
    * are left behind.
    * are left behind.
    */
    */
-  if (strcmp(compilerId, "GNU") == 0) {
+  if (compilerId == "GNU") {
     // GNU Fortran 4.9 and later compress .mod files with gzip
     // GNU Fortran 4.9 and later compress .mod files with gzip
     // but also do not include a date so we can fall through to
     // but also do not include a date so we can fall through to
     // compare them without skipping any prefix.
     // compare them without skipping any prefix.
@@ -664,7 +662,7 @@ bool cmDependsFortran::ModulesDiffer(const char* modFile,
         return true;
         return true;
       }
       }
     }
     }
-  } else if (strcmp(compilerId, "Intel") == 0) {
+  } else if (compilerId == "Intel") {
     const char seq[2] = { '\n', '\0' };
     const char seq[2] = { '\n', '\0' };
     const int seqlen = 2;
     const int seqlen = 2;
 
 

+ 9 - 6
Source/cmDependsFortran.h

@@ -44,8 +44,9 @@ public:
 
 
   /** Determine if a mod file and the corresponding mod.stamp file
   /** Determine if a mod file and the corresponding mod.stamp file
       are representing  different module information. */
       are representing  different module information. */
-  static bool ModulesDiffer(const char* modFile, const char* stampFile,
-                            const char* compilerId);
+  static bool ModulesDiffer(const std::string& modFile,
+                            const std::string& stampFile,
+                            const std::string& compilerId);
 
 
 protected:
 protected:
   // Finalize the dependency information for the target.
   // Finalize the dependency information for the target.
@@ -55,8 +56,8 @@ protected:
   // Find all the modules required by the target.
   // Find all the modules required by the target.
   void LocateModules();
   void LocateModules();
   void MatchLocalModules();
   void MatchLocalModules();
-  void MatchRemoteModules(std::istream& fin, const char* stampDir);
-  void ConsiderModule(const char* name, const char* stampDir);
+  void MatchRemoteModules(std::istream& fin, const std::string& stampDir);
+  void ConsiderModule(const std::string& name, const std::string& stampDir);
   bool FindModule(std::string const& name, std::string& module);
   bool FindModule(std::string const& name, std::string& module);
 
 
   // Implement writing/checking methods required by superclass.
   // Implement writing/checking methods required by superclass.
@@ -65,8 +66,10 @@ protected:
                          std::ostream& internalDepends) override;
                          std::ostream& internalDepends) override;
 
 
   // Actually write the dependencies to the streams.
   // Actually write the dependencies to the streams.
-  bool WriteDependenciesReal(const char* obj, cmFortranSourceInfo const& info,
-                             std::string const& mod_dir, const char* stamp_dir,
+  bool WriteDependenciesReal(std::string const& obj,
+                             cmFortranSourceInfo const& info,
+                             std::string const& mod_dir,
+                             std::string const& stamp_dir,
                              std::ostream& makeDepends,
                              std::ostream& makeDepends,
                              std::ostream& internalDepends);
                              std::ostream& internalDepends);
 
 

+ 2 - 1
Source/cmDependsJava.cxx

@@ -27,7 +27,8 @@ bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources,
 }
 }
 
 
 bool cmDependsJava::CheckDependencies(
 bool cmDependsJava::CheckDependencies(
-  std::istream& /*internalDepends*/, const char* /*internalDependsFileName*/,
+  std::istream& /*internalDepends*/,
+  const std::string& /*internalDependsFileName*/,
   std::map<std::string, DependencyVector>& /*validDeps*/)
   std::map<std::string, DependencyVector>& /*validDeps*/)
 {
 {
   return true;
   return true;

+ 1 - 1
Source/cmDependsJava.h

@@ -33,7 +33,7 @@ protected:
                          const std::string& file, std::ostream& makeDepends,
                          const std::string& file, std::ostream& makeDepends,
                          std::ostream& internalDepends) override;
                          std::ostream& internalDepends) override;
   bool CheckDependencies(
   bool CheckDependencies(
-    std::istream& internalDepends, const char* internalDependsFileName,
+    std::istream& internalDepends, const std::string& internalDependsFileName,
     std::map<std::string, DependencyVector>& validDeps) override;
     std::map<std::string, DependencyVector>& validDeps) override;
 };
 };
 
 

+ 8 - 11
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -1333,8 +1333,8 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
     // dependency vector. This means that in the normal case, when only
     // dependency vector. This means that in the normal case, when only
     // few or one file have been edited, then also only this one file is
     // few or one file have been edited, then also only this one file is
     // actually scanned again, instead of all files for this target.
     // actually scanned again, instead of all files for this target.
-    needRescanDependencies = !checker.Check(
-      dependFile.c_str(), internalDependFile.c_str(), validDependencies);
+    needRescanDependencies =
+      !checker.Check(dependFile, internalDependFile, validDependencies);
   }
   }
 
 
   if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) {
   if (needRescanDependInfo || needRescanDirInfo || needRescanDependencies) {
@@ -1347,7 +1347,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
                                        cmsysTerminal_Color_ForegroundBold,
                                        cmsysTerminal_Color_ForegroundBold,
                                      message.c_str(), true, color);
                                      message.c_str(), true, color);
 
 
-    return this->ScanDependencies(dir.c_str(), validDependencies);
+    return this->ScanDependencies(dir, validDependencies);
   }
   }
 
 
   // The dependencies are already up-to-date.
   // The dependencies are already up-to-date.
@@ -1355,7 +1355,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies(const char* tgtInfo,
 }
 }
 
 
 bool cmLocalUnixMakefileGenerator3::ScanDependencies(
 bool cmLocalUnixMakefileGenerator3::ScanDependencies(
-  const char* targetDir,
+  const std::string& targetDir,
   std::map<std::string, cmDepends::DependencyVector>& validDeps)
   std::map<std::string, cmDepends::DependencyVector>& validDeps)
 {
 {
   // Read the directory information file.
   // Read the directory information file.
@@ -1393,12 +1393,9 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
     cmSystemTools::Error("Directory Information file not found");
     cmSystemTools::Error("Directory Information file not found");
   }
   }
 
 
-  // create the file stream for the depends file
-  std::string dir = targetDir;
-
   // Open the make depends file.  This should be copy-if-different
   // Open the make depends file.  This should be copy-if-different
   // because the make tool may try to reload it needlessly otherwise.
   // because the make tool may try to reload it needlessly otherwise.
-  std::string ruleFileNameFull = dir;
+  std::string ruleFileNameFull = targetDir;
   ruleFileNameFull += "/depend.make";
   ruleFileNameFull += "/depend.make";
   cmGeneratedFileStream ruleFileStream(
   cmGeneratedFileStream ruleFileStream(
     ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
     ruleFileNameFull, false, this->GlobalGenerator->GetMakefileEncoding());
@@ -1410,7 +1407,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
   // Open the cmake dependency tracking file.  This should not be
   // Open the cmake dependency tracking file.  This should not be
   // copy-if-different because dependencies are re-scanned when it is
   // copy-if-different because dependencies are re-scanned when it is
   // older than the DependInfo.cmake.
   // older than the DependInfo.cmake.
-  std::string internalRuleFileNameFull = dir;
+  std::string internalRuleFileNameFull = targetDir;
   internalRuleFileNameFull += "/depend.internal";
   internalRuleFileNameFull += "/depend.internal";
   cmGeneratedFileStream internalRuleFileStream(
   cmGeneratedFileStream internalRuleFileStream(
     internalRuleFileNameFull, false,
     internalRuleFileNameFull, false,
@@ -1451,7 +1448,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies(
       scanner->SetFileComparison(
       scanner->SetFileComparison(
         this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
         this->GlobalGenerator->GetCMakeInstance()->GetFileComparison());
       scanner->SetLanguage(lang);
       scanner->SetLanguage(lang);
-      scanner->SetTargetDirectory(dir.c_str());
+      scanner->SetTargetDirectory(targetDir);
       scanner->Write(ruleFileStream, internalRuleFileStream);
       scanner->Write(ruleFileStream, internalRuleFileStream);
 
 
       // free the scanner for this language
       // free the scanner for this language
@@ -1720,7 +1717,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf,
 
 
     // Clear the implicit dependency makefile.
     // Clear the implicit dependency makefile.
     std::string dependFile = dir + "/depend.make";
     std::string dependFile = dir + "/depend.make";
-    clearer.Clear(dependFile.c_str());
+    clearer.Clear(dependFile);
 
 
     // Remove the internal dependency check file to force
     // Remove the internal dependency check file to force
     // regeneration.
     // regeneration.

+ 1 - 1
Source/cmLocalUnixMakefileGenerator3.h

@@ -245,7 +245,7 @@ protected:
 
 
   // Helper methods for dependency updates.
   // Helper methods for dependency updates.
   bool ScanDependencies(
   bool ScanDependencies(
-    const char* targetDir,
+    const std::string& targetDir,
     std::map<std::string, cmDepends::DependencyVector>& validDeps);
     std::map<std::string, cmDepends::DependencyVector>& validDeps);
   void CheckMultipleOutputs(bool verbose);
   void CheckMultipleOutputs(bool verbose);