diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-13 19:25:37 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-06-13 19:25:37 +0000 |
| commit | 4c7ad8fc27f3919eec47e4f87f239d1f7757723b (patch) | |
| tree | 40ba81d9ab406b897e744cabb436c28d2e27634b /llvm/lib | |
| parent | c4d547d3ae0237dd9dc4a79d8f0c359ed3efab5c (diff) | |
| download | bcm5719-llvm-4c7ad8fc27f3919eec47e4f87f239d1f7757723b.tar.gz bcm5719-llvm-4c7ad8fc27f3919eec47e4f87f239d1f7757723b.zip | |
Have sys::FindProgramByName return a std::string.
llvm-svn: 183928
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Support/Unix/Program.inc | 14 | ||||
| -rw-r--r-- | llvm/lib/Support/Windows/Program.inc | 16 |
2 files changed, 15 insertions, 15 deletions
diff --git a/llvm/lib/Support/Unix/Program.inc b/llvm/lib/Support/Unix/Program.inc index d8bdd6ce424..5fa421b917f 100644 --- a/llvm/lib/Support/Unix/Program.inc +++ b/llvm/lib/Support/Unix/Program.inc @@ -48,19 +48,19 @@ namespace llvm { using namespace sys; // This function just uses the PATH environment variable to find the program. -Path +std::string sys::FindProgramByName(const std::string& progName) { // Check some degenerate cases if (progName.length() == 0) // no program - return Path(); + return ""; Path temp; if (!temp.set(progName)) // invalid name - return Path(); + return ""; // Use the given path verbatim if it contains any slashes; this matches // the behavior of sh(1) and friends. if (progName.find('/') != std::string::npos) - return temp; + return temp.str(); // At this point, the file name is valid and does not contain slashes. Search // for it through the directories specified in the PATH environment variable. @@ -68,7 +68,7 @@ sys::FindProgramByName(const std::string& progName) { // Get the path. If its empty, we can't do anything to find it. const char *PathStr = getenv("PATH"); if (PathStr == 0) - return Path(); + return ""; // Now we have a colon separated list of directories to search; try them. size_t PathLen = strlen(PathStr); @@ -81,7 +81,7 @@ sys::FindProgramByName(const std::string& progName) { if (FilePath.set(std::string(PathStr,Colon))) { FilePath.appendComponent(progName); if (FilePath.canExecute()) - return FilePath; // Found the executable! + return FilePath.str(); // Found the executable! } // Nope it wasn't in this directory, check the next path in the list! @@ -94,7 +94,7 @@ sys::FindProgramByName(const std::string& progName) { PathLen--; } } - return Path(); + return ""; } static bool RedirectIO(const Path *Path, int FD, std::string* ErrMsg) { diff --git a/llvm/lib/Support/Windows/Program.inc b/llvm/lib/Support/Windows/Program.inc index 90a5cdb78ff..cb3bc699012 100644 --- a/llvm/lib/Support/Windows/Program.inc +++ b/llvm/lib/Support/Windows/Program.inc @@ -33,17 +33,17 @@ namespace llvm { using namespace sys; // This function just uses the PATH environment variable to find the program. -Path sys::FindProgramByName(const std::string& progName) { +std::string sys::FindProgramByName(const std::string &progName) { // Check some degenerate cases if (progName.length() == 0) // no program - return Path(); + return ""; Path temp; if (!temp.set(progName)) // invalid name - return Path(); + return ""; // Return paths with slashes verbatim. if (progName.find('\\') != std::string::npos || progName.find('/') != std::string::npos) - return temp; + return temp.str(); // At this point, the file name is valid and does not contain slashes. // Let Windows search for it. @@ -54,11 +54,11 @@ Path sys::FindProgramByName(const std::string& progName) { // See if it wasn't found. if (len == 0) - return Path(); + return ""; // See if we got the entire path. if (len < MAX_PATH) - return Path(buffer); + return std::string(buffer); // Buffer was too small; grow and retry. while (true) { @@ -68,9 +68,9 @@ Path sys::FindProgramByName(const std::string& progName) { // It is unlikely the search failed, but it's always possible some file // was added or removed since the last search, so be paranoid... if (len2 == 0) - return Path(); + return ""; else if (len2 <= len) - return Path(b); + return std::string(b); len = len2; } |

