Do not prepend '.' to path when looking for dependencies for a package

specified without any path components. (Pointed out by Takashi Yamamoto)
Rename path_remove_first() to path_prepend_clear().
This commit is contained in:
abs 2002-08-29 21:46:33 +00:00
parent d484b67904
commit acfcf99e58
3 changed files with 19 additions and 18 deletions

View File

@ -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 <sys/cdefs.h>
#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);
}

View File

@ -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 <sys/cdefs.h>
#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 <err.h>
@ -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;
}
}
/*

View File

@ -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 *);