From b1ee445b23f86f8e9595b71ea2c42e56bd6278a0 Mon Sep 17 00:00:00 2001 From: sobomax Date: Fri, 12 Jan 2001 11:36:12 +0000 Subject: 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 --- usr.sbin/pkg_install/create/pl.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'usr.sbin/pkg_install/create/pl.c') 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 -- cgit v1.1