diff options
author | Bruno Haible <bruno@clisp.org> | 2020-03-07 20:44:47 +0100 |
---|---|---|
committer | Bruno Haible <bruno@clisp.org> | 2020-03-07 20:46:14 +0100 |
commit | 36ebd778f6c9c35c8a8d25d81a893b6e5a4fdf9d (patch) | |
tree | e77f3f76898701fd46449cb0edd5b28a9c5cd0de /lib/findprog.c | |
parent | 1d86584739a712597a6fe3a62ec412238f0f13f8 (diff) | |
download | gnulib-36ebd778f6c9c35c8a8d25d81a893b6e5a4fdf9d.tar.gz |
Revert my last commit, due to compilation errors.
Diffstat (limited to 'lib/findprog.c')
-rw-r--r-- | lib/findprog.c | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/lib/findprog.c b/lib/findprog.c index d834301bd7..d0d41791e2 100644 --- a/lib/findprog.c +++ b/lib/findprog.c @@ -105,29 +105,22 @@ find_in_path (const char *progname) design flaw. */ if (eaccess (progpathname, X_OK) == 0) { - /* Check that the progpathname does not point to a directory. */ - struct stat statbuf; - - if (stat (progpathname, &statbuf) >= 0 - && ! S_ISDIR (statbuf.st_mode)) + /* Found! */ + if (strcmp (progpathname, progname) == 0) { - /* Found! */ - if (strcmp (progpathname, progname) == 0) - { - free (progpathname); - - /* Add the "./" prefix for real, that xconcatenated_filename() - optimized away. This avoids a second PATH search when the - caller uses execlp/execvp. */ - progpathname = XNMALLOC (2 + strlen (progname) + 1, char); - progpathname[0] = '.'; - progpathname[1] = '/'; - memcpy (progpathname + 2, progname, strlen (progname) + 1); - } - - free (path); - return progpathname; + free (progpathname); + + /* Add the "./" prefix for real, that xconcatenated_filename() + optimized away. This avoids a second PATH search when the + caller uses execlp/execvp. */ + progpathname = XNMALLOC (2 + strlen (progname) + 1, char); + progpathname[0] = '.'; + progpathname[1] = '/'; + memcpy (progpathname + 2, progname, strlen (progname) + 1); } + + free (path); + return progpathname; } free (progpathname); |