aboutsummaryrefslogtreecommitdiffstats
path: root/findexec.c
diff options
context:
space:
mode:
authorRob Browning <rlb@cs.utexas.edu>1997-12-12 17:29:42 -0600
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:24 -0800
commitf64b2806c1d66a1341bb8b1491f384169ab1d65f (patch)
tree8b97dbe3640c60927959b0e63461ef9fcae591e0 /findexec.c
parent6dcb175d7f34d9f5a0b3ba623f94454ec16a73d6 (diff)
parent1edcb9b62a1a520eddae8403c19d841c9b18737f (diff)
downloadscm-f64b2806c1d66a1341bb8b1491f384169ab1d65f.tar.gz
scm-f64b2806c1d66a1341bb8b1491f384169ab1d65f.zip
Import Debian changes 5b3-1debian/5b3-1
scm (5b3-1) unstable; urgency=low * New maintainer * New version * libc6
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);
}