diff --git a/usr.sbin/pkg_install/add/perform.c b/usr.sbin/pkg_install/add/perform.c index 6c4222b335cc..69257d7e6dde 100644 --- a/usr.sbin/pkg_install/add/perform.c +++ b/usr.sbin/pkg_install/add/perform.c @@ -1,11 +1,11 @@ -/* $NetBSD: perform.c,v 1.72 2002/08/27 17:27:27 abs Exp $ */ +/* $NetBSD: perform.c,v 1.73 2002/08/29 21:46:33 abs Exp $ */ #include #ifndef lint #if 0 static const char *rcsid = "from FreeBSD Id: perform.c,v 1.44 1997/10/13 15:03:46 jkh Exp"; #else -__RCSID("$NetBSD: perform.c,v 1.72 2002/08/27 17:27:27 abs Exp $"); +__RCSID("$NetBSD: perform.c,v 1.73 2002/08/29 21:46:33 abs Exp $"); #endif #endif @@ -720,7 +720,7 @@ pkg_perform(lpkg_head_t *pkgs) while ((lpp = TAILQ_FIRST(pkgs)) != NULL) { path_prepend_from_pkgname(lpp->lp_name); err_cnt += pkg_do(lpp->lp_name); - path_remove_first(); + path_prepend_clear(); TAILQ_REMOVE(pkgs, lpp, lp_link); free_lpkg(lpp); } diff --git a/usr.sbin/pkg_install/lib/path.c b/usr.sbin/pkg_install/lib/path.c index 2ad3b605bba2..730143cb581d 100644 --- a/usr.sbin/pkg_install/lib/path.c +++ b/usr.sbin/pkg_install/lib/path.c @@ -1,4 +1,4 @@ -/* $NetBSD: path.c,v 1.3 2002/08/27 17:27:30 abs Exp $ */ +/* $NetBSD: path.c,v 1.4 2002/08/29 21:46:34 abs Exp $ */ /*- * Copyright (c)2002 YAMAMOTO Takashi, @@ -28,7 +28,7 @@ #include #ifndef lint -__RCSID("$NetBSD: path.c,v 1.3 2002/08/27 17:27:30 abs Exp $"); +__RCSID("$NetBSD: path.c,v 1.4 2002/08/29 21:46:34 abs Exp $"); #endif #include @@ -36,6 +36,7 @@ __RCSID("$NetBSD: path.c,v 1.3 2002/08/27 17:27:30 abs Exp $"); #include "lib.h" struct pathhead PkgPath = TAILQ_HEAD_INITIALIZER(PkgPath); +static struct path *prepend = 0; static struct path *path_new_entry(const char *cp, size_t len); @@ -134,28 +135,28 @@ path_new_entry(const char *cp, size_t len) } /* - * Given a package name, push its path onto the start of 'PkgPath' + * path_prepend_from_pkgname: prepend the path for a package onto 'PkgPath' */ void path_prepend_from_pkgname(const char *pkgname) { - struct path *new; char *ptr; - if ((ptr = strrchr(pkgname , '/'))) - new = path_new_entry(pkgname, ptr - pkgname); - else - new = path_new_entry(".", 1); - - TAILQ_INSERT_HEAD(&PkgPath, new, pl_entry); + if ((ptr = strrchr(pkgname , '/'))) { + prepend = path_new_entry(pkgname, ptr - pkgname); + TAILQ_INSERT_HEAD(&PkgPath, prepend, pl_entry); + } } /* - * Remove the first entry of 'PkgPath' - used after path_prepend_from_pkgname() + * path_prepend_clear: Remove any prepended entry from 'PkgPath' */ void -path_remove_first() +path_prepend_clear() { - TAILQ_REMOVE(&PkgPath, TAILQ_FIRST(&PkgPath), pl_entry); + if (prepend) { + TAILQ_REMOVE(&PkgPath, prepend, pl_entry); + prepend = 0; + } } /* diff --git a/usr.sbin/pkg_install/lib/path.h b/usr.sbin/pkg_install/lib/path.h index 8cdab28c5c3c..d5d979d41998 100644 --- a/usr.sbin/pkg_install/lib/path.h +++ b/usr.sbin/pkg_install/lib/path.h @@ -1,4 +1,4 @@ -/* $NetBSD: path.h,v 1.2 2002/08/27 17:27:31 abs Exp $ */ +/* $NetBSD: path.h,v 1.3 2002/08/29 21:46:34 abs Exp $ */ /*- * Copyright (c)2002 YAMAMOTO Takashi, @@ -36,5 +36,5 @@ extern struct pathhead PkgPath; void path_create(const char *); void path_free(void); void path_prepend_from_pkgname(const char *); -void path_remove_first(void); +void path_prepend_clear(void); void path_setenv(const char *);