aboutsummaryrefslogtreecommitdiff
path: root/tools/llee/SysUtils.c
diff options
context:
space:
mode:
authorMisha Brukman <brukman+llvm@gmail.com>2003-08-15 23:31:16 +0000
committerMisha Brukman <brukman+llvm@gmail.com>2003-08-15 23:31:16 +0000
commit593ece00509fe5ced9f6a44732cab0e45d03cf63 (patch)
tree7a942643230618914c92436e107902f7c2319984 /tools/llee/SysUtils.c
parenta1ee42ac8e4e31f06476233f89b2993868c2183b (diff)
A lot of changes were suggested by Chris.
ExecveHandler.c: * Use "" instead of <> for LLVM include files * Use raw I/O, we don't need buffering * Set errno = 0 before using open() * strlen() doesn't count NULL terminator in its size * Use memcmp() instead of strcmp() * Return result of the real execve(), not 0 * Search for path to bytecode file if not absolute/relative path SysUtils.c: * Convert all comments to C-style * Stop using `bool', use `unsigned' instead SysUtils.h: * Stop using `bool', use `unsigned' instead * Updated comment to FindExecutable() README.txt: * Describe the goal of LLEE and an application git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7911 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/llee/SysUtils.c')
-rw-r--r--tools/llee/SysUtils.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/tools/llee/SysUtils.c b/tools/llee/SysUtils.c
index 1c3aa85e5c..90d6bb1290 100644
--- a/tools/llee/SysUtils.c
+++ b/tools/llee/SysUtils.c
@@ -15,16 +15,17 @@
#include <stdlib.h>
#include <string.h>
-/// isExecutableFile - This function returns true if the filename specified
-/// exists and is executable.
-///
-bool isExecutableFile(const char *ExeFileName) {
+/*
+ * isExecutableFile - This function returns true if the filename specified
+ * exists and is executable.
+ */
+unsigned isExecutableFile(const char *ExeFileName) {
struct stat Buf;
if (stat(ExeFileName, &Buf))
- return false; // Must not be executable!
+ return 0; // Must not be executable!
if (!(Buf.st_mode & S_IFREG))
- return false; // Not a regular file?
+ return 0; // Not a regular file?
if (Buf.st_uid == getuid()) // Owner of file?
return Buf.st_mode & S_IXUSR;
@@ -34,15 +35,16 @@ bool isExecutableFile(const char *ExeFileName) {
return Buf.st_mode & S_IXOTH;
}
-/// FindExecutable - Find a named executable in the directories listed in $PATH.
-/// If the executable cannot be found, returns NULL.
-///
+/*
+ * FindExecutable - Find a named executable in the directories listed in $PATH.
+ * If the executable cannot be found, returns NULL.
+ */
char *FindExecutable(const char *ExeName) {
/* Try to find the executable in the path */
const char *PathStr = getenv("PATH");
if (PathStr == 0) return "";
- // Now we have a colon separated list of directories to search... try them...
+ /* Now we have a colon separated list of directories to search, try them. */
unsigned PathLen = strlen(PathStr);
while (PathLen) {
/* Find the next colon */
@@ -76,6 +78,6 @@ char *FindExecutable(const char *ExeName) {
++Colon;
}
- // If we fell out, we ran out of directories in PATH to search, return failure
+ /* If we fell out, we ran out of directories to search, return failure. */
return NULL;
}