From 59f490cb4e18960e7ddd003f9a66005eccc5ebd7 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 17 May 2008 17:52:51 -0500 Subject: Fix which (the meaning of -a was reversed, and it was finding the _last_ hit). --- lib/lib.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/lib.c') 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; -- cgit v1.2.3