[Cmake-commits] [cmake-commits] hoffman committed cmSystemTools.cxx 1.368.2.2 1.368.2.3

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Apr 9 14:57:34 EDT 2008


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv4984/Source

Modified Files:
      Tag: CMake-2-6
	cmSystemTools.cxx 
Log Message:
ENH: merge from head for RC7


Index: cmSystemTools.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmSystemTools.cxx,v
retrieving revision 1.368.2.2
retrieving revision 1.368.2.3
diff -C 2 -d -r1.368.2.2 -r1.368.2.3
*** cmSystemTools.cxx	8 Apr 2008 16:22:50 -0000	1.368.2.2
--- cmSystemTools.cxx	9 Apr 2008 18:57:31 -0000	1.368.2.3
***************
*** 150,155 ****
  }
  #else
! void cmSystemTools::ExpandRegistryValues(std::string&)
  {
  }
  #endif
--- 150,166 ----
  }
  #else
! void cmSystemTools::ExpandRegistryValues(std::string& source)
  {
+   cmsys::RegularExpression regEntry("\\[(HKEY[^]]*)\\]");
+   while (regEntry.find(source))
+     {
+     // the arguments are the second match
+     std::string key = regEntry.match(1);
+     std::string val;
+     std::string reg = "[";
+     reg += key + "]";
+     cmSystemTools::ReplaceString(source, reg.c_str(), "/registry");
+     }
+ 
  }
  #endif
***************
*** 2200,2203 ****
--- 2211,2260 ----
  
  //----------------------------------------------------------------------------
+ #if defined(CMAKE_USE_ELF_PARSER)
+ std::string::size_type cmSystemToolsFindRPath(std::string const& have,
+                                               std::string const& want)
+ {
+   // Search for the desired rpath.
+   std::string::size_type pos = have.find(want);
+ 
+   // If the path is not present we are done.
+   if(pos == std::string::npos)
+     {
+     return pos;
+     }
+ 
+   // Build a regex to match a properly separated path instance.
+   std::string regex_str = "(^|:)(";
+   for(std::string::const_iterator i = want.begin(); i != want.end(); ++i)
+     {
+     int ch = *i;
+     if(!(('a' <= ch && ch <= 'z') ||
+          ('A' <= ch && ch <= 'Z') ||
+          ('0' <= ch && ch <= '9')))
+       {
+       // Escape the non-alphanumeric character.
+       regex_str += "\\";
+       }
+     // Store the character.
+     regex_str.append(1, static_cast<char>(ch));
+     }
+   regex_str += ")(:|$)";
+ 
+   // Look for the separated path.
+   cmsys::RegularExpression regex(regex_str.c_str());
+   if(regex.find(have))
+     {
+     // Return the position of the path portion.
+     return regex.start(2);
+     }
+   else
+     {
+     // The desired rpath was not found.
+     return std::string::npos;
+     }
+ }
+ #endif
+ 
+ //----------------------------------------------------------------------------
  bool cmSystemTools::ChangeRPath(std::string const& file,
                                  std::string const& oldRPath,
***************
*** 2208,2214 ****
--- 2265,2275 ----
    unsigned long rpathPosition = 0;
    unsigned long rpathSize = 0;
+   std::string rpathPrefix;
    std::string rpathSuffix;
    {
+   // Parse the ELF binary.
    cmELF elf(file.c_str());
+ 
+   // Get the RPATH or RUNPATH entry from it.
    cmELF::StringEntry const* se = elf.GetRPath();
    if(!se)
***************
*** 2216,2228 ****
      se = elf.GetRunPath();
      }
    if(se)
      {
!     // Make sure the current rpath begins with the old rpath.
!     if(se->Value.length() < oldRPath.length() ||
!        se->Value.substr(0, oldRPath.length()) != oldRPath)
        {
!       // If it begins with the new rpath instead then it is okay.
!       if(se->Value.length() >= newRPath.length() &&
!          se->Value.substr(0, newRPath.length()) == newRPath)
          {
          return true;
--- 2277,2289 ----
      se = elf.GetRunPath();
      }
+ 
    if(se)
      {
!     // Make sure the current rpath contains the old rpath.
!     std::string::size_type pos = cmSystemToolsFindRPath(se->Value, oldRPath);
!     if(pos == std::string::npos)
        {
!       // If it contains the new rpath instead then it is okay.
!       if(cmSystemToolsFindRPath(se->Value, newRPath) != std::string::npos)
          {
          return true;
***************
*** 2233,2237 ****
          e << "The current RPATH is:\n"
            << "  " << se->Value << "\n"
!           << "which does not begin with:\n"
            << "  " << oldRPath << "\n"
            << "as was expected.";
--- 2294,2298 ----
          e << "The current RPATH is:\n"
            << "  " << se->Value << "\n"
!           << "which does not contain:\n"
            << "  " << oldRPath << "\n"
            << "as was expected.";
***************
*** 2246,2250 ****
  
      // Store the part of the path we must preserve.
!     rpathSuffix = se->Value.substr(oldRPath.length(), oldRPath.npos);
      }
    else if(newRPath.empty())
--- 2307,2312 ----
  
      // Store the part of the path we must preserve.
!     rpathPrefix = se->Value.substr(0, pos);
!     rpathSuffix = se->Value.substr(pos+oldRPath.length(), oldRPath.npos);
      }
    else if(newRPath.empty())
***************
*** 2265,2269 ****
    }
    // Compute the full new rpath.
!   std::string rpath = newRPath;
    rpath += rpathSuffix;
  
--- 2327,2332 ----
    }
    // Compute the full new rpath.
!   std::string rpath = rpathPrefix;
!   rpath += newRPath;
    rpath += rpathSuffix;
  



More information about the Cmake-commits mailing list