Matt McCutchen's Web Site
/
rsync
/
rsync.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
If --partial was specified, make sure that make_backup is turned
[rsync/rsync.git]
/
popt
/
findme.c
diff --git
a/popt/findme.c
b/popt/findme.c
index
f2ad05b
..
e98e061
100644
(file)
--- a/
popt/findme.c
+++ b/
popt/findme.c
@@
-1,6
+1,10
@@
-/* (C) 1998 Red Hat Software, Inc. -- Licensing details are in the COPYING
+/** \ingroup popt
+ * \file popt/findme.c
+ */
+
+/* (C) 1998-2000 Red Hat, Inc. -- Licensing details are in the COPYING
file accompanying popt source distributions, available from
file accompanying popt source distributions, available from
- ftp://ftp.r
edhat.com/pub/code/popt
*/
+ ftp://ftp.r
pm.org/pub/rpm/dist.
*/
#include "system.h"
#include "findme.h"
#include "system.h"
#include "findme.h"
@@
-9,38
+13,38
@@
const char * findProgramPath(const char * argv0) {
char * path = getenv("PATH");
char * pathbuf;
char * start, * chptr;
char * path = getenv("PATH");
char * pathbuf;
char * start, * chptr;
- char * buf
, *local = NULL
;
+ char * buf;
- /* If there is a / in the argv[0], it has to be an absolute
-
path */
+ if (argv0 == NULL) return NULL; /* XXX can't happen */
+
/* If there is a / in the argv[0], it has to be an absolute
path */
if (strchr(argv0, '/'))
return xstrdup(argv0);
if (strchr(argv0, '/'))
return xstrdup(argv0);
- if (
!path
) return NULL;
+ if (
path == NULL
) return NULL;
- local = start = pathbuf = malloc(strlen(path) + 1);
- buf = malloc(strlen(path) + strlen(argv0) + 2);
+ start = pathbuf = alloca(strlen(path) + 1);
+ buf = malloc(strlen(path) + strlen(argv0) + sizeof("/"));
+ if (buf == NULL) return NULL; /* XXX can't happen */
strcpy(pathbuf, path);
chptr = NULL;
strcpy(pathbuf, path);
chptr = NULL;
+ /*@-branchstate@*/
do {
if ((chptr = strchr(start, ':')))
*chptr = '\0';
sprintf(buf, "%s/%s", start, argv0);
do {
if ((chptr = strchr(start, ':')))
*chptr = '\0';
sprintf(buf, "%s/%s", start, argv0);
- if (!access(buf, X_OK)) {
- if (local) free(local);
- return buf;
- }
+ if (!access(buf, X_OK))
+ return buf;
if (chptr)
start = chptr + 1;
else
start = NULL;
} while (start && *start);
if (chptr)
start = chptr + 1;
else
start = NULL;
} while (start && *start);
+ /*@=branchstate@*/
free(buf);
free(buf);
- if (local) free(local);
return NULL;
}
return NULL;
}