Mercurial > hg > toybox
diff lib/lib.c @ 295:5a0faa267866
Fix which (the meaning of -a was reversed, and it was finding the _last_ hit).
author | Rob Landley <rob@landley.net> |
---|---|
date | Sat, 17 May 2008 17:52:51 -0500 |
parents | b4077be6c746 |
children | 52600eee8dd6 |
line wrap: on
line diff
--- a/lib/lib.c Sat May 17 17:13:26 2008 -0500 +++ b/lib/lib.c Sat May 17 17:52:51 2008 -0500 @@ -364,7 +364,7 @@ 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 @@ // 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;