aboutsummaryrefslogtreecommitdiff
path: root/lib/lib.c
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2008-05-17 17:52:51 -0500
committerRob Landley <rob@landley.net>2008-05-17 17:52:51 -0500
commit59f490cb4e18960e7ddd003f9a66005eccc5ebd7 (patch)
tree5e9af2b4cdd2387f8eea377c3d9c8c2662e9e1b5 /lib/lib.c
parent1a221d9b4f058d05aa250691c381f0cfeaaeab9e (diff)
downloadtoybox-59f490cb4e18960e7ddd003f9a66005eccc5ebd7.tar.gz
Fix which (the meaning of -a was reversed, and it was finding the _last_ hit).
Diffstat (limited to 'lib/lib.c')
-rw-r--r--lib/lib.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 0e3fe020..1aca9c8c 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -364,7 +364,7 @@ void xmkpath(char *path, int mode)
struct string_list *find_in_path(char *path, char *filename)
{
- struct string_list *rlist = NULL;
+ struct string_list *rlist = NULL, **prlist=&rlist;
char *cwd = xgetcwd();
for (;;) {
@@ -386,8 +386,9 @@ struct string_list *find_in_path(char *path, char *filename)
// Confirm it's not a directory.
if (!stat(rnext->str, &st) && S_ISREG(st.st_mode)) {
- rnext->next = rlist;
- rlist = rnext;
+ *prlist = rnext;
+ rnext->next = NULL;
+ prlist = &(rnext->next);
} else free(rnext);
if (!next) break;