[PATCH] [Support][Program] Add findProgramByName(Name, OptionalPaths)
Michael Spencer
bigcheesegs at gmail.com
Mon Nov 3 15:28:01 PST 2014
================
Comment at: lib/Support/Unix/Program.inc:107
@@ +106,3 @@
+ // Check some degenerate cases
+ if (Name.empty()) // no program
+ return std::errc::no_such_file_or_directory;
----------------
rafael wrote:
> assert
K.
================
Comment at: lib/Support/Unix/Program.inc:116
@@ +115,3 @@
+ SmallVector<StringRef, 16> SearchPaths;
+ SplitString(std::getenv("PATH"), SearchPaths, ":");
+ return findProgramByName(Name, SearchPaths);
----------------
rafael wrote:
> on windows it is ; instead of :, no.
This is UNIX only code.
================
Comment at: lib/Support/Unix/Program.inc:120
@@ +119,3 @@
+
+ if (Paths.empty())
+ return std::errc::no_such_file_or_directory;
----------------
rafael wrote:
> Redundant if. Just let the for iterate 0 times.
K.
================
Comment at: lib/Support/Unix/Program.inc:130
@@ +129,3 @@
+ sys::path::append(FilePath, Name);
+ if (sys::fs::can_execute(Twine(FilePath)))
+ return std::string(FilePath.str()); // Found the executable!
----------------
rafael wrote:
> .c_str() since we have a SmallString anyway.
K.
http://reviews.llvm.org/D6067
More information about the llvm-commits
mailing list