summaryrefslogtreecommitdiffstats
path: root/findexec.c
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:24 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:24 -0800
commit1edcb9b62a1a520eddae8403c19d841c9b18737f (patch)
treebc0a43d9b3905726a76ed6f0528b54275f23d082 /findexec.c
parent5ca6e8e6a4e5c022a6fb5d28f30219c22c99eda8 (diff)
downloadscm-1edcb9b62a1a520eddae8403c19d841c9b18737f.tar.gz
scm-1edcb9b62a1a520eddae8403c19d841c9b18737f.zip
Import Upstream version 5b3upstream/5b3
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);
}