From 879f4fa041cfdefee655eb877f1a91f86a9c62b7 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Fri, 3 Mar 2017 00:56:40 -0800 Subject: New upstream version 5f2 --- findexec.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) mode change 100644 => 100755 findexec.c (limited to 'findexec.c') diff --git a/findexec.c b/findexec.c old mode 100644 new mode 100755 index a562077..5be7f54 --- 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")); -- cgit v1.2.3