The following commit has been merged in the master branch:
commit b407cde7c7acc7dcb21cba9d81e164b507b93912
Author: Guillem Jover <[email protected]>
Date: Sun Sep 27 17:26:58 2009 +0200
dpkg: Use more meaningful and clearer variable names in checkpath()
Variable renames:
checklist → prog_list
clp → prog
path → path_list
s → path
p → path_end
l → path_len
buf → filename
diff --git a/src/help.c b/src/help.c
index 2ebffc1..7dc9288 100644
--- a/src/help.c
+++ b/src/help.c
@@ -80,7 +80,7 @@ struct filenamenode *namenodetouse(struct filenamenode
*namenode, struct pkginfo
void checkpath(void) {
/* Verify that some programs can be found in the PATH. */
- static const char *const checklist[] = {
+ static const char *const prog_list[] = {
DEFAULTSHELL,
RM,
TAR,
@@ -95,35 +95,40 @@ void checkpath(void) {
};
struct stat stab;
- const char *const *clp;
- const char *path, *s, *p;
- char* buf;
+ const char *const *prog;
+ const char *path_list, *path, *path_end;
+ char *filename;
int warned= 0;
- long l;
+ long path_len;
- path= getenv("PATH");
- if (!path)
+ path_list = getenv("PATH");
+ if (!path_list)
ohshit(_("error: PATH is not set."));
- buf=(char*)m_malloc(strlen(path)+2+strlen("start-stop-daemon"));
+ filename = m_malloc(strlen(path_list) + 2 + strlen("start-stop-daemon"));
- for (clp=checklist; *clp; clp++) {
- s= path;
- while (s) {
- p= strchr(s,':');
- l= p ? p-s : (long)strlen(s);
- memcpy(buf,s,l);
- if (l) buf[l++]= '/';
- strcpy(buf+l,*clp);
- if (stat(buf,&stab) == 0 && (stab.st_mode & 0111)) break;
- s= p; if (s) s++;
+ for (prog = prog_list; *prog; prog++) {
+ path = path_list;
+ while (path) {
+ path_end = strchr(path, ':');
+ path_len = path_end ? path_end - path : (long)strlen(path);
+ memcpy(filename, path, path_len);
+ if (path_len)
+ filename[path_len++] = '/';
+ strcpy(filename + path_len, *prog);
+ if (stat(filename, &stab) == 0 && (stab.st_mode & 0111))
+ break;
+ path = path_end;
+ if (path)
+ path++;
}
- if (!s) {
- warning(_("'%s' not found on PATH."), *clp);
+ if (!path) {
+ warning(_("'%s' not found on PATH."), *prog);
warned++;
}
}
- free(buf);
+ free(filename);
+
if (warned)
forcibleerr(fc_badpath,_("%d expected program(s) not found on PATH.\nNB:
root's "
"PATH should usually contain /usr/local/sbin, /usr/sbin and
/sbin."),
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]