From 1edcb9b62a1a520eddae8403c19d841c9b18737f Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Mon, 20 Feb 2017 00:05:24 -0800 Subject: Import Upstream version 5b3 --- findexec.c | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) (limited to 'findexec.c') 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 # include # endif #endif +#ifdef __amigados__ +# include +# include +#endif #ifndef __STDC__ # define const /**/ #endif +#ifdef freebsd +/* This might be same for 44bsd derived system. */ +# include +# include +#endif +#ifdef __alpha +# include +# include +# include +# include +#endif +#ifdef __GO32__ +# include +#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); } -- cgit v1.2.3