redid the fix for non-executable files in an easier to read way plus
some minor aethetic changes
This commit is contained in:
15
find_path.c
15
find_path.c
@@ -100,21 +100,20 @@ char *find_path(file)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while ((n = index(path, ':'))) {
|
while ((n = index(path, ':'))) {
|
||||||
*n='\0';
|
*n = '\0';
|
||||||
strcpy(fn, path);
|
(void)strcpy(fn, path);
|
||||||
strcat(fn, "/");
|
(void)strcat(fn, "/");
|
||||||
strcat(fn, file);
|
(void)strcat(fn, file);
|
||||||
|
|
||||||
/* stat the file to make sure it exists and is executable */
|
/* stat the file to make sure it exists and is executable */
|
||||||
statfailed = stat(fn, &statbuf);
|
statfailed = stat(fn, &statbuf);
|
||||||
if (!statfailed && (statbuf.st_mode & 0000111))
|
if (!statfailed && (statbuf.st_mode & 0000111))
|
||||||
return (qualify(fn));
|
return(qualify(fn));
|
||||||
else if (!statfailed || errno == ENOENT || errno == ENOTDIR)
|
else if (statfailed && errno != ENOENT && errno != ENOTDIR) {
|
||||||
path=n+1;
|
|
||||||
else {
|
|
||||||
perror("find_path: stat");
|
perror("find_path: stat");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
path = n + 1;
|
||||||
}
|
}
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user