summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install/create/pl.c
diff options
context:
space:
mode:
authorsobomax <sobomax@FreeBSD.org>2001-01-12 11:36:12 +0000
committersobomax <sobomax@FreeBSD.org>2001-01-12 11:36:12 +0000
commitb1ee445b23f86f8e9595b71ea2c42e56bd6278a0 (patch)
tree178c72ceba496c4de001ae48e67b9398093eb71c /usr.sbin/pkg_install/create/pl.c
parent8c5796361494bfe7782ea98cda3ef20813ce9b07 (diff)
downloadFreeBSD-src-b1ee445b23f86f8e9595b71ea2c42e56bd6278a0.zip
FreeBSD-src-b1ee445b23f86f8e9595b71ea2c42e56bd6278a0.tar.gz
Fix a bug where pkg_create does not make an md5 entry for the last item in
the packing list. Also use switch() instead of zillion "else if ()" and for() loop instead of while() loop for traversing through linked list. MFC candidate. Submitted by: Alec Wolman <wolman@cs.washington.edu>
Diffstat (limited to 'usr.sbin/pkg_install/create/pl.c')
-rw-r--r--usr.sbin/pkg_install/create/pl.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/usr.sbin/pkg_install/create/pl.c b/usr.sbin/pkg_install/create/pl.c
index 863e533..fc65560 100644
--- a/usr.sbin/pkg_install/create/pl.c
+++ b/usr.sbin/pkg_install/create/pl.c
@@ -35,19 +35,21 @@ check_list(char *home, Package *pkg)
{
char *where = home;
char *there = NULL;
- PackingList p = pkg->head;
+ char *cp, name[FILENAME_MAX], buf[33];
+ PackingList p;
- while (p) {
- if (p->type == PLIST_CWD)
+ for (p = pkg->head; p != NULL; p = p->next)
+ switch (p->type) {
+ case PLIST_CWD:
where = p->name;
- else if (p->type == PLIST_IGNORE)
+ break;
+ case PLIST_IGNORE:
p = p->next;
- else if (p->type == PLIST_SRC) {
+ break;
+ case PLIST_SRC:
there = p->name;
- }
- else if (p->type == PLIST_FILE) {
- char *cp, name[FILENAME_MAX], buf[33];
-
+ break;
+ case PLIST_FILE:
sprintf(name, "%s/%s", there ? there : where, p->name);
if ((cp = MD5File(name, buf)) != NULL) {
PackingList tmp = new_plist_entry();
@@ -57,11 +59,14 @@ check_list(char *home, Package *pkg)
tmp->next = p->next;
tmp->prev = p;
p->next = tmp;
+ if (pkg->tail == p)
+ pkg->tail = tmp;
p = tmp;
}
+ break;
+ default:
+ break;
}
- p = p->next;
- }
}
static int
OpenPOWER on IntegriCloud