aboutsummaryrefslogtreecommitdiffstats
path: root/lib/System/Unix/Path.inc
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-05-30 01:09:53 +0000
committerBill Wendling <isanbard@gmail.com>2009-05-30 01:09:53 +0000
commitc19467424889a76b42eb17134180e42ff528c55b (patch)
tree1c33a0bd47e7b0fc26b2c57cb67cbb6b62e23ef4 /lib/System/Unix/Path.inc
parent849163188e3a0db94ef385cf63bdc56c534d65c4 (diff)
downloadexternal_llvm-c19467424889a76b42eb17134180e42ff528c55b.zip
external_llvm-c19467424889a76b42eb17134180e42ff528c55b.tar.gz
external_llvm-c19467424889a76b42eb17134180e42ff528c55b.tar.bz2
Untabification.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72604 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/System/Unix/Path.inc')
-rw-r--r--lib/System/Unix/Path.inc83
1 files changed, 41 insertions, 42 deletions
diff --git a/lib/System/Unix/Path.inc b/lib/System/Unix/Path.inc
index 6bcb00f..d5edee1 100644
--- a/lib/System/Unix/Path.inc
+++ b/lib/System/Unix/Path.inc
@@ -271,52 +271,52 @@ static int
test_dir(char buf[PATH_MAX], char ret[PATH_MAX],
const char *dir, const char *bin)
{
- struct stat sb;
+ struct stat sb;
- snprintf(buf, PATH_MAX, "%s//%s", dir, bin);
- if (realpath(buf, ret) == NULL)
- return (1);
- if (stat(buf, &sb) != 0)
- return (1);
-
- return (0);
+ snprintf(buf, PATH_MAX, "%s//%s", dir, bin);
+ if (realpath(buf, ret) == NULL)
+ return (1);
+ if (stat(buf, &sb) != 0)
+ return (1);
+
+ return (0);
}
static char *
getprogpath(char ret[PATH_MAX], const char *bin)
{
- char *pv, *s, *t, buf[PATH_MAX];
-
- /* First approach: absolute path. */
- if (bin[0] == '/') {
- if (test_dir(buf, ret, "/", bin) == 0)
- return (ret);
- return (NULL);
- }
-
- /* Second approach: relative path. */
- if (strchr(bin, '/') != NULL) {
- if (getcwd(buf, PATH_MAX) == NULL)
- return (NULL);
- if (test_dir(buf, ret, buf, bin) == 0)
- return (ret);
- return (NULL);
- }
-
- /* Third approach: $PATH */
- if ((pv = getenv("PATH")) == NULL)
- return (NULL);
- s = pv = strdup(pv);
- if (pv == NULL)
- return (NULL);
- while ((t = strsep(&s, ":")) != NULL) {
- if (test_dir(buf, ret, t, bin) == 0) {
- free(pv);
- return (ret);
- }
- }
- free(pv);
- return (NULL);
+ char *pv, *s, *t, buf[PATH_MAX];
+
+ /* First approach: absolute path. */
+ if (bin[0] == '/') {
+ if (test_dir(buf, ret, "/", bin) == 0)
+ return (ret);
+ return (NULL);
+ }
+
+ /* Second approach: relative path. */
+ if (strchr(bin, '/') != NULL) {
+ if (getcwd(buf, PATH_MAX) == NULL)
+ return (NULL);
+ if (test_dir(buf, ret, buf, bin) == 0)
+ return (ret);
+ return (NULL);
+ }
+
+ /* Third approach: $PATH */
+ if ((pv = getenv("PATH")) == NULL)
+ return (NULL);
+ s = pv = strdup(pv);
+ if (pv == NULL)
+ return (NULL);
+ while ((t = strsep(&s, ":")) != NULL) {
+ if (test_dir(buf, ret, t, bin) == 0) {
+ free(pv);
+ return (ret);
+ }
+ }
+ free(pv);
+ return (NULL);
}
#endif
@@ -341,7 +341,7 @@ Path Path::GetMainExecutable(const char *argv0, void *MainAddr) {
int err = dladdr(MainAddr, &DLInfo);
if (err == 0)
return Path();
-
+
// If the filename is a symlink, we need to resolve and return the location of
// the actual executable.
char link_path[MAXPATHLEN];
@@ -874,4 +874,3 @@ void Path::UnMapFilePages(const char *BasePtr, uint64_t FileSize) {
}
} // end llvm namespace
-