aboutsummaryrefslogtreecommitdiffstats
path: root/findexec.c
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2017-03-03 00:56:40 -0800
committerBryan Newbold <bnewbold@robocracy.org>2017-08-02 00:09:46 -0700
commit879f4fa041cfdefee655eb877f1a91f86a9c62b7 (patch)
treebc68ac058e5d0a7cf8e7815cbe1070fd60e75589 /findexec.c
parentd13fcf5c0bd68f67059b2561c28c40b55e1117a3 (diff)
downloadscm-879f4fa041cfdefee655eb877f1a91f86a9c62b7.tar.gz
scm-879f4fa041cfdefee655eb877f1a91f86a9c62b7.zip
New upstream version 5f2
Diffstat (limited to 'findexec.c')
-rwxr-xr-x[-rw-r--r--]findexec.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/findexec.c b/findexec.c
index a562077..5be7f54 100644..100755
--- a/findexec.c
+++ b/findexec.c
@@ -1,5 +1,6 @@
/* "findexec.c" was part of DLD, a dynamic link/unlink editor for C.
- * Copyright (C) 1990 by W. Wilson Ho.
+ * Copyright (C) 1990 Free Software Foundation
+ * Author: W. Wilson Ho.
*
* GNU Emacs is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -148,6 +149,7 @@ static char *copy_of(s)
# define ABSOLUTE_FILENAME_P(fname) (fname[0] == '/')
# endif /* atarist */
+/* Return 0 if getcwd() returns 0. */
char *dld_find_executable(name)
const char *name;
{
@@ -160,7 +162,7 @@ char *dld_find_executable(name)
if (strchr(name, '/')) {
strcpy (tbuf, "."); /* in case getcwd doesn't work */
- getcwd(tbuf, MAXPATHLEN);
+ if (!getcwd(tbuf, MAXPATHLEN)) return (char *)0L;
if ((name[0] == '.') && (name[1] == '/')) {
strcat(tbuf, name + 1);
} else {
@@ -190,8 +192,9 @@ char *dld_find_executable(name)
*next = 0;
if (*p) p++;
- if (tbuf[0] == '.' && tbuf[1] == 0)
- getcwd(tbuf, MAXPATHLEN); /* was getwd(tbuf); */
+ if (tbuf[0] == '.' && tbuf[1] == 0) {
+ if (!getcwd(tbuf, MAXPATHLEN)) return (char *)0L;
+ }
else if (tbuf[0]=='~' && tbuf[1]==0 && getenv("HOME"))
strcpy(tbuf, (char *)getenv("HOME"));