diff options
author | Rob Landley <rob@landley.net> | 2008-05-17 17:52:51 -0500 |
---|---|---|
committer | Rob Landley <rob@landley.net> | 2008-05-17 17:52:51 -0500 |
commit | 59f490cb4e18960e7ddd003f9a66005eccc5ebd7 (patch) | |
tree | 5e9af2b4cdd2387f8eea377c3d9c8c2662e9e1b5 /lib/lib.c | |
parent | 1a221d9b4f058d05aa250691c381f0cfeaaeab9e (diff) | |
download | toybox-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.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -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; |