summaryrefslogtreecommitdiffstats
path: root/findexec.c
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:26 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-02-20 00:05:26 -0800
commitdeda2c0fd8689349fea2a900199a76ff7ecb319e (patch)
treec9726d54a0806a9b0c75e6c82db8692aea0053cf /findexec.c
parent3278b75942bdbe706f7a0fba87729bb1e935b68b (diff)
downloadscm-deda2c0fd8689349fea2a900199a76ff7ecb319e.tar.gz
scm-deda2c0fd8689349fea2a900199a76ff7ecb319e.zip
Import Upstream version 5d6upstream/5d6
Diffstat (limited to 'findexec.c')
-rw-r--r--findexec.c125
1 files changed, 74 insertions, 51 deletions
diff --git a/findexec.c b/findexec.c
index b6d648b..4992775 100644
--- a/findexec.c
+++ b/findexec.c
@@ -37,54 +37,72 @@ Wed Feb 21 23:06:35 1996 Aubrey Jaffer <jaffer@jacal.bertronics>
filename. A new copy of the complete path name of that file is
returned. This new string may be disposed by free() later on. */
-#include <sys/file.h>
-#include <sys/param.h>
-#ifdef linux
-# include <stdlib.h>
-# include <sys/stat.h>
-# include <unistd.h> /* for X_OK define */
-#endif
-#ifdef __svr4__
-# include <string.h>
-# include <stdlib.h>
-# include <sys/stat.h>
-# include <unistd.h> /* for X_OK define */
-#else
-# ifdef __sgi__
+#ifndef __MINGW32__
+# ifndef PLAN9
+# include <sys/file.h>
+# include <sys/param.h>
+# endif
+# ifdef linux
+# include <stdlib.h>
+# include <sys/stat.h>
+# include <unistd.h> /* for X_OK define */
+# endif
+# ifdef __SVR4
# include <string.h>
# include <stdlib.h>
# include <sys/stat.h>
# include <unistd.h> /* for X_OK define */
# else
-# include <strings.h>
+# ifdef __sgi__
+# include <string.h>
+# include <stdlib.h>
+# include <sys/stat.h>
+# include <unistd.h> /* for X_OK define */
+# else
+# ifdef PLAN9
+# include <u.h>
+# include <libc.h>
+# define getcwd getwd
+# define MAXPATHLEN 256 /* arbitrary? */
+# define X_OK AEXEC
+# else
+# include <strings.h>
+# endif
+# endif
+# endif
+# ifdef __amigaos__
+# include <stdlib.h>
+# include <sys/stat.h>
+# include <unistd.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
-#endif
-#ifdef __amigados__
-# include <stdlib.h>
-# include <sys/stat.h>
-# include <unistd.h>
-#endif
-#ifndef __STDC__
-# define const /**/
-#endif
-#ifdef __FreeBSD__
+# ifdef __OpenBSD__
/* 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"
-#endif
+# include <stdlib.h>
+# include <unistd.h>
+# 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"
+# endif
static char *copy_of(s)
register const char *s;
@@ -97,12 +115,12 @@ static char *copy_of(s)
}
/* ABSOLUTE_FILENAME_P(fname): True if fname is an absolute filename */
-#ifdef atarist
-# define ABSOLUTE_FILENAME_P(fname) ((fname[0] == '/') || \
+# ifdef atarist
+# define ABSOLUTE_FILENAME_P(fname) ((fname[0] == '/') || \
(fname[0] && (fname[1] == ':')))
-#else
-# define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
-#endif /* atarist */
+# else
+# define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
+# endif /* atarist */
char *dld_find_executable(name)
const char *name;
@@ -155,16 +173,21 @@ char *dld_find_executable(name)
strcat(tbuf, name);
if (access(tbuf, X_OK) == 0) {
-#ifndef hpux
-# ifndef ultrix
+# ifndef hpux
+# ifndef ultrix
+# ifndef __MACH__
+# ifndef PLAN9
struct stat stat_temp;
- if (stat(tbuf,&stat_temp)) continue;
+ if (stat(tbuf, &stat_temp)) continue;
if (S_IFREG != (S_IFMT & stat_temp.st_mode)) continue;
-# endif/* ultrix */
-#endif /* hpux */
+# endif /* PLAN9 */
+# endif /* __MACH__ */
+# endif/* ultrix */
+# endif /* hpux */
return copy_of(tbuf);
}
}
return 0;
}
+#endif /* ndef MSDOS */