aboutsummaryrefslogtreecommitdiffstats
path: root/findexec.c
diff options
context:
space:
mode:
Diffstat (limited to 'findexec.c')
-rw-r--r--findexec.c32
1 files changed, 28 insertions, 4 deletions
diff --git a/findexec.c b/findexec.c
index bbeac76..18285c7 100644
--- a/findexec.c
+++ b/findexec.c
@@ -1,4 +1,4 @@
-/* This file was part of DLD, a dynamic link/unlink editor for C.
+/* "findexec.c" was part of DLD, a dynamic link/unlink editor for C.
Copyright (C) 1990 by W. Wilson Ho.
@@ -59,9 +59,27 @@ Wed Feb 21 23:06:35 1996 Aubrey Jaffer <jaffer@jacal.bertronics>
# include <strings.h>
# endif
#endif
+#ifdef __amigados__
+# include <stdlib.h>
+# include <sys/stat.h>
+#endif
#ifndef __STDC__
# define const /**/
#endif
+#ifdef freebsd
+/* This might be same for 44bsd derived system. */
+# include <sys/types.h>
+# include <sys/stat.h>
+#endif
+#ifdef __alpha
+# include <string.h>
+# include <stdlib.h>
+# include <sys/types.h>
+# include <sys/stat.h>
+#endif
+#ifdef __GO32__
+# include <sys/stat.h>
+#endif
#ifndef DEFAULT_PATH
# define DEFAULT_PATH ".:~/bin::/usr/local/bin:/usr/new:/usr/ucb:/usr/bin:/bin:/usr/hosts"
@@ -93,11 +111,17 @@ char *dld_find_executable(name)
char tbuf[MAXPATHLEN];
if (ABSOLUTE_FILENAME_P(name))
- return copy_of(name);
+ return access(name, X_OK) ? 0 : copy_of(name);
- if ((name[0] == '.') && (name[1] == '/')) {
+ if (strchr(name, '/')) {
+ strcpy (tbuf, "."); /* in case getcwd doesn't work */
getcwd(tbuf, MAXPATHLEN);
- strcat(tbuf, name + 1);
+ if ((name[0] == '.') && (name[1] == '/')) {
+ strcat(tbuf, name + 1);
+ } else {
+ if ('/' != tbuf[strlen(tbuf) - 1]) strcat(tbuf, "/");
+ strcat(tbuf, name);
+ }
return copy_of(tbuf);
}