mirror of
https://github.com/moparisthebest/pacman
synced 2025-02-28 17:31:52 -05:00
Discussed on IRC for a bit, this makes the following changes for clarity:
* alpm_list_is_in --> alpm_list_find * alpm_list_is_strin --> alpm_list_find_str * Flip parameters of both functions to be inline with rest of alpm_list. First commit, woohoo.
This commit is contained in:
parent
358a4a62f3
commit
1799afc9c1
@ -507,7 +507,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
||||
* eg, /home/httpd/html/index.html may be removed so index.php
|
||||
* could be used.
|
||||
*/
|
||||
if(alpm_list_is_strin(pathname, handle->noextract)) {
|
||||
if(alpm_list_find_str(handle->noextract, pathname)) {
|
||||
alpm_logaction(_("notice: %s is in NoExtract -- skipping extraction"), pathname);
|
||||
archive_read_data_skip (archive);
|
||||
continue;
|
||||
@ -516,7 +516,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
||||
if(!stat(expath, &buf) && !S_ISDIR(buf.st_mode)) {
|
||||
/* file already exists */
|
||||
if(!pmo_upgrade || oldpkg == NULL) {
|
||||
nb = alpm_list_is_strin(pathname, info->backup);
|
||||
nb = alpm_list_find_str(info->backup, pathname);
|
||||
} else {
|
||||
/* op == PM_TRANS_TYPE_UPGRADE */
|
||||
md5_orig = _alpm_needbackup(pathname, oldpkg->backup);
|
||||
@ -525,7 +525,7 @@ int _alpm_add_commit(pmtrans_t *trans, pmdb_t *db)
|
||||
nb = 1;
|
||||
}
|
||||
}
|
||||
if(alpm_list_is_strin(pathname, handle->noupgrade)) {
|
||||
if(alpm_list_find_str(handle->noupgrade, pathname)) {
|
||||
notouch = 1;
|
||||
nb = 0;
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ int alpm_db_update(int force, pmdb_t *db)
|
||||
ASSERT(handle->trans->state == STATE_INITIALIZED, RET_ERR(PM_ERR_TRANS_NOT_INITIALIZED, -1));
|
||||
ASSERT(handle->trans->type == PM_TRANS_TYPE_SYNC, RET_ERR(PM_ERR_TRANS_TYPE, -1));
|
||||
|
||||
if(!alpm_list_is_in(db, handle->dbs_sync)) {
|
||||
if(!alpm_list_find(handle->dbs_sync, db)) {
|
||||
RET_ERR(PM_ERR_DB_NOT_FOUND, -1);
|
||||
}
|
||||
|
||||
|
@ -309,7 +309,7 @@ alpm_list_t *alpm_list_remove_dupes(alpm_list_t *list)
|
||||
{ /* TODO does removing the strdup here cause invalid free's anywhere? */
|
||||
alpm_list_t *lp = list, *newlist = NULL;
|
||||
while(lp) {
|
||||
if(!alpm_list_is_in(lp->data, newlist)) {
|
||||
if(!alpm_list_find(newlist, lp->data)) {
|
||||
newlist = alpm_list_add(newlist, lp->data);
|
||||
}
|
||||
lp = lp->next;
|
||||
@ -426,7 +426,7 @@ int alpm_list_count(const alpm_list_t *list)
|
||||
* @param haystack the list to search
|
||||
* @return 1 if `needle` is found, 0 otherwise
|
||||
*/
|
||||
int alpm_list_is_in(const void *needle, alpm_list_t *haystack)
|
||||
int alpm_list_find(alpm_list_t *haystack, const void *needle)
|
||||
{
|
||||
alpm_list_t *lp = haystack;
|
||||
while(lp) {
|
||||
@ -440,12 +440,12 @@ int alpm_list_is_in(const void *needle, alpm_list_t *haystack)
|
||||
|
||||
/* Test for existence of a string in a alpm_list_t
|
||||
*/
|
||||
/** Is a _string_ in the list (optimization of alpm_list_is_in for strings)
|
||||
/** Is a _string_ in the list (optimization of alpm_list_find for strings)
|
||||
* @param needle the string to compare
|
||||
* @param haystack the list to search
|
||||
* @return 1 if `needle` is found, 0 otherwise
|
||||
*/
|
||||
int alpm_list_is_strin(const char *needle, alpm_list_t *haystack)
|
||||
int alpm_list_find_str(alpm_list_t *haystack, const char *needle)
|
||||
{
|
||||
alpm_list_t *lp = haystack;
|
||||
while(lp) {
|
||||
|
@ -64,8 +64,8 @@ void *alpm_list_getdata(const alpm_list_t *entry);
|
||||
|
||||
/* misc */
|
||||
int alpm_list_count(const alpm_list_t *list);
|
||||
int alpm_list_is_in(const void *needle, alpm_list_t *haystack);
|
||||
int alpm_list_is_strin(const char *needle, alpm_list_t *haystack);
|
||||
int alpm_list_find(alpm_list_t *haystack, const void *needle);
|
||||
int alpm_list_find_str(alpm_list_t *haystack,const char *needle);
|
||||
|
||||
#endif /* _ALPM_LIST_H */
|
||||
|
||||
|
@ -202,7 +202,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
|
||||
pmpkg_t *pkg = lp->data;
|
||||
|
||||
for(i = pkg->groups; i; i = i->next) {
|
||||
if(!alpm_list_is_strin(i->data, db->grpcache)) {
|
||||
if(!alpm_list_find_str(db->grpcache, i->data)) {
|
||||
pmgrp_t *grp = _alpm_grp_new();
|
||||
|
||||
STRNCPY(grp->name, (char *)i->data, GRP_NAME_LEN);
|
||||
@ -215,7 +215,7 @@ int _alpm_db_load_grpcache(pmdb_t *db)
|
||||
pmgrp_t *grp = j->data;
|
||||
|
||||
if(strcmp(grp->name, i->data) == 0) {
|
||||
if(!alpm_list_is_strin(pkg->name, grp->packages)) {
|
||||
if(!alpm_list_find_str(grp->packages, pkg->name)) {
|
||||
grp->packages = alpm_list_add_sorted(grp->packages, (char *)pkg->name, _alpm_grp_cmp);
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, a
|
||||
if(strcmp(filestr, ".INSTALL") == 0) {
|
||||
continue;
|
||||
}
|
||||
if(alpm_list_is_strin(filestr, p2->files)) {
|
||||
if(alpm_list_find_str(p2->files, filestr)) {
|
||||
pmconflict_t *conflict = malloc(sizeof(pmconflict_t));
|
||||
if(conflict == NULL) {
|
||||
_alpm_log(PM_LOG_ERROR, _("malloc failure: could not allocate %d bytes"),
|
||||
@ -284,7 +284,7 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, a
|
||||
_alpm_log(PM_LOG_DEBUG, _("loading FILES info for '%s'"), dbpkg->name);
|
||||
_alpm_db_read(db, INFRQ_FILES, dbpkg);
|
||||
}
|
||||
if(dbpkg && alpm_list_is_strin(j->data, dbpkg->files)) {
|
||||
if(dbpkg && alpm_list_find_str(dbpkg->files, j->data)) {
|
||||
ok = 1;
|
||||
}
|
||||
/* Make sure that the supposedly-conflicting file is not actually just
|
||||
@ -315,7 +315,8 @@ alpm_list_t *_alpm_db_find_conflicts(pmdb_t *db, pmtrans_t *trans, char *root, a
|
||||
_alpm_db_read(db, INFRQ_FILES, dbpkg2);
|
||||
}
|
||||
/* If it used to exist in there, but doesn't anymore */
|
||||
if(dbpkg2 && !alpm_list_is_strin(filestr, p1->files) && alpm_list_is_strin(filestr, dbpkg2->files)) {
|
||||
if(dbpkg2 && !alpm_list_find_str(p1->files, filestr)
|
||||
&& alpm_list_find_str(dbpkg2->files, filestr)) {
|
||||
ok = 1;
|
||||
/* Add to the "skip list" of files that we shouldn't remove during an upgrade.
|
||||
*
|
||||
|
@ -363,7 +363,7 @@ alpm_list_t *_alpm_checkdeps(pmtrans_t *trans, pmdb_t *db, pmtranstype_t op,
|
||||
spkg = k->data;
|
||||
}
|
||||
if(spkg) {
|
||||
if(alpm_list_is_strin(tp->name, spkg->provides)) {
|
||||
if(alpm_list_find_str(spkg->provides, tp->name)) {
|
||||
found = 1;
|
||||
}
|
||||
}
|
||||
@ -549,7 +549,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
|
||||
/* check if one of the packages in *list already provides this dependency */
|
||||
for(j = list; j && !found; j = j->next) {
|
||||
pmpkg_t *sp = (pmpkg_t *)j->data;
|
||||
if(alpm_list_is_strin(miss->depend.name, sp->provides)) {
|
||||
if(alpm_list_find_str(sp->provides, miss->depend.name)) {
|
||||
_alpm_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"),
|
||||
sp->name, miss->depend.name);
|
||||
found = 1;
|
||||
@ -602,7 +602,7 @@ int _alpm_resolvedeps(pmdb_t *local, alpm_list_t *dbs_sync, pmpkg_t *syncpkg,
|
||||
* something we're not supposed to.
|
||||
*/
|
||||
int usedep = 1;
|
||||
if(alpm_list_is_strin(sync->name, handle->ignorepkg)) {
|
||||
if(alpm_list_find_str(handle->ignorepkg, sync->name)) {
|
||||
pmpkg_t *dummypkg = _alpm_pkg_new(miss->target, NULL);
|
||||
QUESTION(trans, PM_TRANS_CONV_INSTALL_IGNOREPKG, dummypkg, sync, NULL, &usedep);
|
||||
FREEPKG(dummypkg);
|
||||
|
@ -42,7 +42,7 @@ alpm_list_t *_alpm_db_whatprovides(pmdb_t *db, char *package)
|
||||
for(lp = _alpm_db_get_pkgcache(db, INFRQ_DEPENDS); lp; lp = lp->next) {
|
||||
pmpkg_t *info = lp->data;
|
||||
|
||||
if(alpm_list_is_strin(package, info->provides)) {
|
||||
if(alpm_list_find_str(info->provides, package)) {
|
||||
pkgs = alpm_list_add(pkgs, info);
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,8 @@ int _alpm_remove_loadtarget(pmtrans_t *trans, pmdb_t *db, char *name)
|
||||
}
|
||||
|
||||
/* ignore holdpkgs on upgrade */
|
||||
if((trans == handle->trans) && alpm_list_is_strin(info->name, handle->holdpkg)) {
|
||||
if((trans == handle->trans)
|
||||
&& alpm_list_find_str(handle->holdpkg, info->name)) {
|
||||
int resp = 0;
|
||||
QUESTION(trans, PM_TRANS_CONV_REMOVE_HOLDPKG, info, NULL, NULL, &resp);
|
||||
if(!resp) {
|
||||
@ -177,7 +178,7 @@ static void unlink_file(pmpkg_t *info, alpm_list_t *lp, alpm_list_t *targ,
|
||||
FREE(checksum);
|
||||
} if ( !nb && trans->type == PM_TRANS_TYPE_UPGRADE ) {
|
||||
/* check noupgrade */
|
||||
if ( alpm_list_is_strin(file, handle->noupgrade) ) {
|
||||
if ( alpm_list_find_str(handle->noupgrade, file) ) {
|
||||
nb = 1;
|
||||
}
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ int _alpm_downloadfiles_forreal(alpm_list_t *servers, const char *localpath,
|
||||
snprintf(realfile, PATH_MAX, "%s/%s", localpath, fn);
|
||||
snprintf(output, PATH_MAX, "%s/%s.part", localpath, fn);
|
||||
|
||||
if(alpm_list_is_strin(fn, complete)) {
|
||||
if(alpm_list_find_str(complete, fn)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -137,7 +137,7 @@ static int find_replacements(pmtrans_t *trans, pmdb_t *db_local,
|
||||
pmpkg_t *lpkg = m->data;
|
||||
if(strcmp(k->data, lpkg->name) == 0) {
|
||||
_alpm_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), k->data, spkg->name);
|
||||
if(alpm_list_is_strin(lpkg->name, handle->ignorepkg)) {
|
||||
if(alpm_list_find_str(handle->ignorepkg, lpkg->name)) {
|
||||
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)"),
|
||||
lpkg->name, lpkg->version, spkg->name, spkg->version);
|
||||
} else {
|
||||
@ -235,7 +235,7 @@ int _alpm_sync_sysupgrade(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_s
|
||||
local->name, local->version, db->treename, spkg->version);
|
||||
} else if(cmp == 0) {
|
||||
/* versions are identical */
|
||||
} else if(alpm_list_is_strin(spkg->name, handle->ignorepkg)) {
|
||||
} else if(alpm_list_find_str(handle->ignorepkg, spkg->name)) {
|
||||
/* package should be ignored (IgnorePkg) */
|
||||
_alpm_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (%s)"),
|
||||
local->name, local->version, spkg->version);
|
||||
@ -535,7 +535,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
|
||||
local = _alpm_db_get_pkgfromcache(db_local, miss->depend.name);
|
||||
/* check if this package also "provides" the package it's conflicting with
|
||||
*/
|
||||
if(alpm_list_is_strin(miss->depend.name, sync->pkg->provides)) {
|
||||
if(alpm_list_find_str(sync->pkg->provides, miss->depend.name)) {
|
||||
/* so just treat it like a "replaces" item so the REQUIREDBY
|
||||
* fields are inherited properly.
|
||||
*/
|
||||
@ -559,8 +559,8 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
|
||||
|
||||
/* figure out which one was requested in targets. If they both were,
|
||||
* then it's still an unresolvable conflict. */
|
||||
target = alpm_list_is_strin(miss->target, trans->targets);
|
||||
depend = alpm_list_is_strin(miss->depend.name, trans->targets);
|
||||
target = alpm_list_find_str(trans->targets, miss->target);
|
||||
depend = alpm_list_find_str(trans->targets, miss->depend.name);
|
||||
if(depend && !target) {
|
||||
_alpm_log(PM_LOG_DEBUG, _("'%s' is in the target list -- keeping it"),
|
||||
miss->depend.name);
|
||||
@ -591,7 +591,7 @@ int _alpm_sync_prepare(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t *dbs_sync
|
||||
_alpm_log(PM_LOG_DEBUG, _("resolving package '%s' conflict"), miss->target);
|
||||
if(local) {
|
||||
int doremove = 0;
|
||||
if(!alpm_list_is_strin(miss->depend.name, asked)) {
|
||||
if(!alpm_list_find_str(asked, miss->depend.name)) {
|
||||
QUESTION(trans, PM_TRANS_CONV_CONFLICT_PKG, miss->target, miss->depend.name, NULL, &doremove);
|
||||
asked = alpm_list_add(asked, strdup(miss->depend.name));
|
||||
if(doremove) {
|
||||
@ -1020,7 +1020,7 @@ int _alpm_sync_commit(pmtrans_t *trans, pmdb_t *db_local, alpm_list_t **data)
|
||||
pmpkg_t *old = j->data;
|
||||
/* merge lists */
|
||||
for(k = old->requiredby; k; k = k->next) {
|
||||
if(!alpm_list_is_strin(k->data, new->requiredby)) {
|
||||
if(!alpm_list_find_str(new->requiredby, k->data)) {
|
||||
/* replace old's name with new's name in the requiredby's dependency list */
|
||||
alpm_list_t *m;
|
||||
pmpkg_t *depender = _alpm_db_get_pkgfromcache(db_local, k->data);
|
||||
|
@ -116,7 +116,7 @@ int _alpm_trans_addtarget(pmtrans_t *trans, char *target)
|
||||
ASSERT(trans != NULL, RET_ERR(PM_ERR_TRANS_NULL, -1));
|
||||
ASSERT(target != NULL, RET_ERR(PM_ERR_WRONG_ARGS, -1));
|
||||
|
||||
if(alpm_list_is_strin(target, trans->targets)) {
|
||||
if(alpm_list_find_str(trans->targets, target)) {
|
||||
RET_ERR(PM_ERR_TRANS_DUP_TARGET, -1);
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,8 @@ int _alpm_depcmp(pmpkg_t *pkg, pmdepend_t *dep)
|
||||
{
|
||||
int equal = 0;
|
||||
|
||||
if(strcmp(pkg->name, dep->name) == 0 || alpm_list_is_strin(dep->name, pkg->provides)) {
|
||||
if(strcmp(pkg->name, dep->name) == 0
|
||||
|| alpm_list_find_str(pkg->provides, dep->name)) {
|
||||
if(dep->mod == PM_DEP_MOD_ANY) {
|
||||
equal = 1;
|
||||
} else {
|
||||
|
@ -159,7 +159,7 @@ static int sync_cleancache(int level)
|
||||
/* TODO Do not remove the currently installed version EITHER */
|
||||
if(!strcmp(name, n)) {
|
||||
char *ptr = (alpm_pkg_vercmp(version, v) < 0) ? str : s;
|
||||
if(!alpm_list_is_strin(ptr, clean)) {
|
||||
if(!alpm_list_find_str(clean, ptr)) {
|
||||
clean = alpm_list_add(clean, strdup(ptr));
|
||||
}
|
||||
}
|
||||
@ -645,7 +645,7 @@ int pacman_sync(alpm_list_t *targets)
|
||||
for(j = data; j; j = alpm_list_next(j)) {
|
||||
pmpkg_t *p = alpm_list_getdata(j);
|
||||
const char *pkgname = alpm_pkg_get_name(p);
|
||||
if(!alpm_list_is_strin(pkgname, list_remove)) {
|
||||
if(!alpm_list_find_str(list_remove, pkgname)) {
|
||||
list_remove = alpm_list_add(list_remove, strdup(pkgname));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user