Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=bf6943613586068956e63602a2f7984cc6ea8f5e
commit bf6943613586068956e63602a2f7984cc6ea8f5e Author: Michel Hermier <[email protected]> Date: Tue Sep 9 20:28:13 2014 +0200 libpacman: Make FPtrList::iterator a value class. diff --git a/lib/libpacman/cache.cpp b/lib/libpacman/cache.cpp index e6b200c..3ae15f0 100644 --- a/lib/libpacman/cache.cpp +++ b/lib/libpacman/cache.cpp @@ -147,7 +147,7 @@ Group *_pacman_db_get_grpfromlist(FPtrList *list, const char *target) } for(auto i = list->begin(), end = list->end(); i != end; i = i->next()) { - Group *info = f_ptrlistitem_data(i); + Group *info = *i; if(strcmp(info->name, target) == 0) { return(info); @@ -168,7 +168,7 @@ int _pacman_db_load_grpcache(Database *db) _pacman_log(PM_LOG_DEBUG, _("loading group cache for repository '%s'"), db->treename()); for(auto it = cache.begin(), end = cache.end(); it != end; it = it->next()) { - Package *pkg = f_ptrlistitem_data(it); + Package *pkg = *it; if(!(pkg->flags & INFRQ_DESC)) { pkg->read(INFRQ_DESC); @@ -176,7 +176,7 @@ int _pacman_db_load_grpcache(Database *db) auto &groups = pkg->groups(); for(auto git = groups.begin(), git_end = groups.end(); git != git_end; git = git->next()) { - const char *grp_name = f_stringlistitem_to_str(git); + const char *grp_name = *git; Group *grp = _pacman_db_get_grpfromlist(&db->grpcache, grp_name); diff --git a/lib/libpacman/conflict.cpp b/lib/libpacman/conflict.cpp index 97fe9f6..3ff6140 100644 --- a/lib/libpacman/conflict.cpp +++ b/lib/libpacman/conflict.cpp @@ -64,7 +64,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) howmany = f_ptrlist_count(&packages); for(auto i = packages.begin(), end = packages.end(); i != end; i = i->next()) { - Package *tp = (Package *)f_ptrlistitem_data(i); + Package *tp = (Package *)*i; if(tp == NULL) { continue; } @@ -79,7 +79,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) auto &conflicts = tp->conflicts(); for(auto j = conflicts.begin(), j_end = conflicts.end(); j != j_end; j = j->next()) { - const char *conflict = f_stringlistitem_to_str(j); + const char *conflict = (const char *)*j; if(!strcmp(tp->name(), conflict)) { /* a package cannot conflict with itself -- that's just not nice */ continue; @@ -88,7 +88,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) _pacman_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs db"), tp->name()); auto &cache = _pacman_db_get_pkgcache(db_local); for(auto k = cache.begin(), k_end = cache.end(); k != k_end; k = k->next()) { - Package *dp = (Package *)f_ptrlistitem_data(k); + Package *dp = (Package *)*k; if(!strcmp(dp->name(), tp->name())) { /* a package cannot conflict with itself -- that's just not nice */ continue; @@ -103,7 +103,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) /* see if dp provides something in tp's conflict list */ auto &provides = dp->provides(); for(auto m = provides.begin(), m_end = provides.end(); m != m_end; m = m->next()) { - if(!strcmp(f_stringlistitem_to_str(m), conflict)) { + if(!strcmp((const char *)*m, conflict)) { /* confict */ _pacman_log(PM_LOG_DEBUG, _("targs vs db: found %s as a conflict for %s"), dp->name(), tp->name()); @@ -116,7 +116,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) /* CHECK 2: check targets against targets */ _pacman_log(PM_LOG_DEBUG, _("checkconflicts: targ '%s' vs targs"), tp->name()); for(auto k = packages.begin(), k_end = packages.end(); k != k_end; k = k->next()) { - Package *otp = (Package *)f_ptrlistitem_data(k); + Package *otp = (Package *)*k; if(!strcmp(otp->name(), tp->name())) { /* a package cannot conflict with itself -- that's just not nice */ continue; @@ -131,7 +131,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) /* see if otp provides something in tp's conflict list */ auto &provides = otp->provides(); for(auto m = provides.begin(), m_end = provides.end(); m != m_end; m = m->next()) { - if(!strcmp(f_stringlistitem_to_str(m), conflict)) { + if(!strcmp((const char *)*m, conflict)) { _pacman_log(PM_LOG_DEBUG, _("targs vs targs: found %s as a conflict for %s"), otp->name(), tp->name()); miss = new __pmdepmissing_t(tp->name(), PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, otp->name(), NULL); @@ -148,7 +148,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) FStringList *conflicts; int usenewconflicts = 0; - info = (Package *)f_ptrlistitem_data(k); + info = (Package *)*k; if(!strcmp(info->name(), tp->name())) { /* a package cannot conflict with itself -- that's just not nice */ continue; @@ -157,7 +157,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) * conflicts list from the new package, not the old one (*info) */ for(auto j = packages.begin(), j_end = packages.end(); j != j_end; j = j->next()) { - Package *pkg = (Package *)f_ptrlistitem_data(j); + Package *pkg = (Package *)*j; if(!strcmp(pkg->name(), info->name())) { /* Use the new, to-be-installed package's conflicts */ conflicts = &pkg->conflicts(); @@ -169,7 +169,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) conflicts = &info->conflicts(); } for(auto j = conflicts->begin(), j_end = conflicts->end(); j != j_end; j = j->next()) { - if(!strcmp(tp->name(), f_stringlistitem_to_str(j))) { + if(!strcmp(tp->name(), (const char *)*j)) { _pacman_log(PM_LOG_DEBUG, _("db vs targs: found %s as a conflict for %s"), info->name(), tp->name()); miss = new __pmdepmissing_t(tp->name(), PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name(), NULL); @@ -179,7 +179,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) for(auto m = conflicts->begin(), m_end = conflicts->end(); m != m_end; m = m->next()) { auto &provides = tp->provides(); for(auto n = provides.begin(), n_end = provides.end(); n != n_end; n = n->next()) { - if(!strcmp(f_stringlistitem_to_str(m), f_stringlistitem_to_str(n))) { + if(!strcmp((const char *)*m, (const char *)*n)) { _pacman_log(PM_LOG_DEBUG, _("db vs targs: found %s as a conflict for %s"), info->name(), tp->name()); miss = new __pmdepmissing_t(tp->name(), PM_DEP_TYPE_CONFLICT, PM_DEP_MOD_ANY, info->name(), NULL); @@ -204,8 +204,8 @@ static FStringList chk_fileconflicts(const FStringList &filesA, const FStringLis auto pA = filesA.begin(), pB = filesB.begin(); while(pA != filesA.end() && pB != filesB.end()) { - const char *strA = f_stringlistitem_to_str(pA); - const char *strB = f_stringlistitem_to_str(pB); + const char *strA = (const char *)*pA; + const char *strB = (const char *)*pB; /* skip directories, we don't care about dir conflicts */ if(strA[strlen(strA)-1] == '/') { pA = pA->next(); @@ -249,12 +249,12 @@ FPtrList _pacman_db_find_conflicts(pmtrans_t *trans) /* CHECK 1: check every target against every target */ for(auto i = trans->packages.begin(), end = trans->packages.end(); i != end; i = i->next()) { - Package *p1 = (Package*)f_ptrlistitem_data(i); + Package *p1 = (Package*)*i; remain = f_ptrlistiterator_count(i, end); percent = (double)(howmany - remain + 1) / howmany; PROGRESS(trans, PM_TRANS_PROGRESS_CONFLICTS_START, "", (percent * 100), howmany, howmany - remain + 1); for(auto j = i; j != end; j = j->next()) { - Package *p2 = (Package*)f_ptrlistitem_data(j); + Package *p2 = (Package*)*j; if(strcmp(p1->name(), p2->name())) { auto ret = chk_fileconflicts(p1->files(), p2->files()); for(auto k = ret.begin(), k_end = ret.end(); k != k_end; k = k->next()) { @@ -264,7 +264,7 @@ FPtrList _pacman_db_find_conflicts(pmtrans_t *trans) } conflict->type = PM_CONFLICT_TYPE_TARGET; STRNCPY(conflict->target, p1->name(), PKG_NAME_LEN); - STRNCPY(conflict->file, f_stringlistitem_to_str(k), CONFLICT_FILE_LEN); + STRNCPY(conflict->file, (const char *)*k, CONFLICT_FILE_LEN); STRNCPY(conflict->ctarget, p2->name(), PKG_NAME_LEN); conflicts.add(conflict); } @@ -272,11 +272,11 @@ FPtrList _pacman_db_find_conflicts(pmtrans_t *trans) } /* CHECK 2: check every target against the filesystem */ - p = (Package*)f_ptrlistitem_data(i); + p = (Package*)*i; dbpkg = NULL; auto &files = p->files(); for(auto j = files.begin(), j_end = files.end(); j != j_end; j = j->next()) { - filestr = f_stringlistitem_to_str(j); + filestr = (const char *)*j; snprintf(path, PATH_MAX, "%s%s", root, filestr); /* is this target a file or directory? */ if(path[strlen(path)-1] == '/') { @@ -304,7 +304,7 @@ FPtrList _pacman_db_find_conflicts(pmtrans_t *trans) if(!ok) { /* Look at all the targets */ for(auto k = trans->packages.begin(), k_end = trans->packages.end(); k != k_end && !ok; k = k->next()) { - Package *p2 = (Package *)f_ptrlistitem_data(k); + Package *p2 = (Package *)*k; /* As long as they're not the current package */ if(strcmp(p2->name(), p->name())) { Package *dbpkg2 = NULL; diff --git a/lib/libpacman/db.cpp b/lib/libpacman/db.cpp index 1126f5d..8ca636a 100644 --- a/lib/libpacman/db.cpp +++ b/lib/libpacman/db.cpp @@ -102,7 +102,7 @@ FPtrList Database::filter(const PackageMatcher &packagematcher) FPtrList &cache = _pacman_db_get_pkgcache(this), ret; for(auto it = cache.begin(), end = cache.end(); it != end; it = it->next()) { - Package *pkg = (Package *)f_ptrlistitem_data(it); + Package *pkg = (Package *)*it; if(packagematcher.match(pkg)) { ret.add(pkg); @@ -121,7 +121,7 @@ FPtrList Database::filter(const FStringList &needles, int packagestrmatcher_flag FPtrList ret; for(auto i = needles.begin(), end = needles.end(); i != end; i = i->next()) { - const char *pattern = f_stringlistitem_to_str(i); + const char *pattern = (const char *)*i; if(f_strempty(pattern)) { continue; @@ -132,7 +132,7 @@ FPtrList Database::filter(const FStringList &needles, int packagestrmatcher_flag FPtrList &cache = _pacman_db_get_pkgcache(this); for(auto j = cache.begin(), j_end = cache.end(); j != j_end; j = j->next()) { - Package *pkg = (Package *)f_ptrlistitem_data(j); + Package *pkg = (Package *)*j; if(packagematcher.match(pkg)) { ret.add(pkg); @@ -156,7 +156,7 @@ Package *Database::find(const PackageMatcher &packagematcher) FPtrList &cache = _pacman_db_get_pkgcache(this); for(auto i = cache.begin(), end = cache.end(); i != end; i = i->next()) { - Package *pkg = (Package *)f_ptrlistitem_data(i); + Package *pkg = (Package *)*i; if(packagematcher.match(pkg)) { if(packagematcher.match(pkg, ~PM_PACKAGE_FLAG_PROVIDES)) { diff --git a/lib/libpacman/db/localdb.cpp b/lib/libpacman/db/localdb.cpp index e0c9c5b..b62d797 100644 --- a/lib/libpacman/db/localdb.cpp +++ b/lib/libpacman/db/localdb.cpp @@ -145,7 +145,7 @@ int _pacman_localpackage_remove(Package *pkg, pmtrans_t *trans, int howmany, int for(auto lp = pkg->files().rbegin(), end = pkg->files().rend(); lp != end; lp = lp->previous()) { int nb = 0; double percent = 0; - const char *file = f_stringlistitem_to_str(lp); + const char *file = *lp; char *hash_orig = pkg->fileneedbackup(file); if (position != 0) { @@ -179,7 +179,7 @@ int _pacman_localpackage_remove(Package *pkg, pmtrans_t *trans, int howmany, int * explanation. */ int skipit = 0; for(auto j = trans->skiplist.begin(), end = trans->skiplist.end(); j != end; j = j->next()) { - if(!strcmp(file, f_stringlistitem_to_str(j))) { + if(!strcmp(file, *j)) { skipit = 1; } } @@ -392,7 +392,7 @@ void _pacman_localdb_write_stringlist(const char *entry, const FStringList &valu if(!values.empty()) { fprintf(stream, "%%%s%%\n", entry); for(auto lp = values.begin(), end = values.end(); lp != end; lp = lp->next()) { - fprintf(stream, "%s\n", f_stringlistitem_to_str(lp)); + fprintf(stream, "%s\n", *lp); } fputc('\n', stream); } @@ -510,13 +510,13 @@ FPtrList LocalDatabase::getowners(const char *filename) FPtrList &cache = _pacman_db_get_pkgcache(this); for(auto lp = cache.begin(), end = cache.end(); lp != end; lp = lp->next()) { - Package *info = (Package *)f_ptrlistitem_data(lp); + Package *info = (Package *)*lp; auto &files = info->files(); for(auto i = files.begin(), end = files.end(); i != end; i = i->next()) { char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s%s", m_handle->root, f_stringlistitem_to_str(i)); + snprintf(path, PATH_MAX, "%s%s", m_handle->root, *i); if(!strcmp(path, rpath)) { ret.add(info); if(rpath[strlen(rpath)-1] != '/') { diff --git a/lib/libpacman/db/localdb_files.cpp b/lib/libpacman/db/localdb_files.cpp index 6758cc5..ed28ddf 100644 --- a/lib/libpacman/db/localdb_files.cpp +++ b/lib/libpacman/db/localdb_files.cpp @@ -73,9 +73,9 @@ int _pacman_localdb_desc_fread(Package *info, FILE *fp) f_strtrim(line); if(!strcmp(line, "%DESC%")) { _pacman_db_read_lines(info->desc_localized, line, sline, fp); - STRNCPY(info->m_description, f_stringlistitem_to_str(info->desc_localized.begin()), sizeof(info->m_description)); + STRNCPY(info->m_description, *info->desc_localized.begin(), sizeof(info->m_description)); for (auto i = info->desc_localized.begin(), end = info->desc_localized.end(); i != end; i = i->next()) { - const char *desc = f_stringlistitem_to_str(i); + const char *desc = *i; const size_t language_len = strlen(handle->language); if (!strncmp(desc, handle->language, language_len) && *(desc+language_len) == ' ') { STRNCPY(info->m_description, desc+language_len+1, sizeof(info->m_description)); diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp index d50e792..9882858 100644 --- a/lib/libpacman/deps.cpp +++ b/lib/libpacman/deps.cpp @@ -54,7 +54,7 @@ typedef struct __pmgraph_t { Package *data; struct __pmgraph_t *parent; /* where did we come from? */ FPtrList children; - FPtrListIterator *childptr; /* points to a child in children list */ + FPtrList::iterator childptr; /* points to a child in children list */ } pmgraph_t; static pmgraph_t *_pacman_graph_new(void) @@ -80,7 +80,7 @@ static int _pacman_depmiss_isin(pmdepmissing_t *needle, FPtrList *haystack) { for(auto i = haystack->begin(), end = haystack->end(); i != end; i = i->next()) { - pmdepmissing_t *miss = f_ptrlistitem_data(i); + pmdepmissing_t *miss = (pmdepmissing_t *)*i; if(!memcmp(needle, miss, sizeof(pmdepmissing_t)) && !memcmp(&needle->depend, &miss->depend, sizeof(pmdepend_t))) { return(1); @@ -130,23 +130,23 @@ FPtrList _pacman_sortbydeps(const FPtrList &targets, int mode) /* We create the vertices */ for(auto i = targets.begin(), end = targets.end(); i != end; i = i->next()) { pmgraph_t *v = _pacman_graph_new(); - v->data = f_ptrlistitem_data(i); + v->data = *i; vertices.add(v); } /* We compute the edges */ for(auto i = vertices.begin(), end = vertices.end(); i != end; i = i->next()) { - pmgraph_t *vertex_i = f_ptrlistitem_data(i); + pmgraph_t *vertex_i = (pmgraph_t *)*i; Package *p_i = vertex_i->data; /* TODO this should be somehow combined with _pacman_checkdeps */ for(auto j = vertices.begin(); j != end; j = j->next()) { - pmgraph_t *vertex_j = f_ptrlistitem_data(j); + pmgraph_t *vertex_j = *j; Package *p_j = vertex_j->data; int child = 0; auto &depends = p_i->depends(); for(auto k = depends.begin(), k_end = depends.end(); k != k_end && !child; k = k->next()) { pmdepend_t depend; - _pacman_splitdep(f_ptrlistitem_data(k), &depend); + _pacman_splitdep((char *)*k, &depend); child = _pacman_depcmp(p_j, &depend); } if(child) { @@ -156,14 +156,14 @@ FPtrList _pacman_sortbydeps(const FPtrList &targets, int mode) vertex_i->childptr = vertex_i->children.begin(); } - FPtrListIterator *vptr = vertices.begin(), *end = vertices.end(); - vertex = f_ptrlistitem_data(vptr); + FPtrList::iterator vptr = vertices.begin(), end = vertices.end(); + vertex = *vptr; while(vptr != end) { /* mark that we touched the vertex */ vertex->state = -1; found = 0; while(vertex->childptr != vertex->children.end() && !found) { - pmgraph_t *nextchild = f_ptrlistitem_data(vertex->childptr); + pmgraph_t *nextchild = *vertex->childptr; vertex->childptr = vertex->childptr->next(); if (nextchild->state == 0) { found = 1; @@ -181,7 +181,7 @@ FPtrList _pacman_sortbydeps(const FPtrList &targets, int mode) if(!vertex) { vptr = vptr->next(); while(vptr != end) { - vertex = f_ptrlistitem_data(vptr); + vertex = *vptr; if (vertex->state == 0) break; vptr = vptr->next(); } @@ -218,7 +218,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p } for(auto i = packages.begin(), end = packages.end(); i != end; i = i->next()) { - Package *tp = f_ptrlistitem_data(i); + Package *tp = *i; Package *pkg_local; if(tp == NULL) { @@ -235,7 +235,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p found = 0; auto &requiredby = pkg_local->requiredby(); for(auto j = requiredby.begin(), j_end = requiredby.end(); j != j_end; j = j->next()) { - const char *requiredby_name = f_stringlistitem_to_str(j); + const char *requiredby_name = (const char *)*j; if(op == PM_TRANS_TYPE_UPGRADE) { /* PM_TRANS_TYPE_UPGRADE handles the backwards dependencies, ie, the packages @@ -253,7 +253,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p } auto &depends = p->depends(); for(auto k = depends.begin(), k_end = depends.end(); k != k_end; k = k->next()) { - const char *depend_name = f_stringlistitem_to_str(k); + const char *depend_name = (const char *)*k; /* don't break any existing dependencies (possible provides) */ _pacman_splitdep(depend_name, &depend); @@ -270,14 +270,14 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p if(!_pacman_pkg_isin(requiredby_name, &packages)) { /* check if a package in trans->packages provides this package */ for(auto k = trans->packages.begin(), k_end = trans->packages.end(); !found && k != k_end; k = k->next()) { - Package *spkg = f_ptrlistitem_data(k); + Package *spkg = *k; if(spkg && spkg->provides(pkg_local->name())) { found=1; } } for(auto k = trans->syncpkgs.begin(), k_end = trans->syncpkgs.end(); !found && k != k_end; k = k->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(k); + pmsyncpkg_t *ps = *k; if(ps->pkg_new->provides(pkg_local->name())) { found=1; @@ -296,7 +296,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p /* DEPENDENCIES -- look for unsatisfied dependencies */ auto &depends = tp->depends(); for(auto j = depends.begin(), j_end = depends.end(); j != j_end; j = j->next()) { - const char *depend_name = f_stringlistitem_to_str(j); + const char *depend_name = (const char *)*j; /* split into name/version pairs */ _pacman_splitdep(depend_name, &depend); @@ -304,7 +304,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p /* check database for literal packages */ auto &cache = _pacman_db_get_pkgcache(db_local); for(auto k = cache.begin(), k_end = cache.end(); k != k_end && !found; k = k->next()) { - Package *p = (Package *)f_ptrlistitem_data(k); + Package *p = (Package *)*k; if(!strcmp(p->name(), depend.name)) { if(depend.mod == PM_DEP_MOD_ANY) { /* accept any version */ @@ -339,10 +339,10 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p * to install. this way, if we match against a to-be-installed * package, we'll defer to the NEW one, not the one already * installed. */ - Package *p = f_ptrlistitem_data(m); + Package *p = *m; int skip = 0; for(auto n = packages.begin(), n_end = packages.end(); n != n_end && !skip; n = n->next()) { - Package *ptp = f_ptrlistitem_data(n); + Package *ptp = *n; if(!strcmp(ptp->name(), p->name())) { skip = 1; } @@ -378,7 +378,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p } /* check other targets */ for(auto k = packages.begin(), k_end = packages.end(); k != k_end && !found; k = k->next()) { - Package *p = (Package *)f_ptrlistitem_data(k); + Package *p = (Package *)*k; /* see if the package names match OR if p provides depend.name */ if(!strcmp(p->name(), depend.name) || p->provides(depend.name)) { if(depend.mod == PM_DEP_MOD_ANY || @@ -481,15 +481,15 @@ FPtrList &_pacman_removedeps(Database *db, FPtrList &targs) } bool again = false; - for(auto i = targs.begin(), end = targs.end(); i != end; i = again ? targs.begin() : i->next()) { + for(auto i = targs.begin(), end = targs.end(); i != end; i = again ? targs.begin() : FPtrList::iterator(i->next())) { again = false; - auto &depends = ((Package *)f_ptrlistitem_data(i))->depends(); + auto &depends = ((Package *)*i)->depends(); for(auto j = depends.begin(), j_end = depends.end(); j != j_end; j = j->next()) { pmdepend_t depend; Package *dep; int needed = 0; - if(_pacman_splitdep(f_stringlistitem_to_str(j), &depend)) { + if(_pacman_splitdep((const char *)*j, &depend)) { continue; } @@ -501,7 +501,7 @@ FPtrList &_pacman_removedeps(Database *db, FPtrList &targs) _pacman_log(PM_LOG_WARNING, _("cannot find package \"%s\" or anything that provides it!"), depend.name); continue; } - dep = db->find(((Package *)f_ptrlistitem_data(whatPackagesProvide.begin()))->name()); + dep = db->find(((Package *)*whatPackagesProvide.begin())->name()); if(dep == NULL) { _pacman_log(PM_LOG_ERROR, _("dep is NULL!")); /* wtf */ @@ -521,7 +521,7 @@ FPtrList &_pacman_removedeps(Database *db, FPtrList &targs) /* see if other packages need it */ auto &requiredby = dep->requiredby(); for(auto k = requiredby.begin(), k_end = requiredby.end(); k != k_end && !needed; k = k->next()) { - Package *dummy = db->find(f_stringlistitem_to_str(k)); + Package *dummy = db->find((const char *)*k); if(!_pacman_pkg_isin(dummy->name(), &targs)) { needed = 1; } @@ -567,12 +567,12 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, FPtrList &list, for(auto i = deps.begin(), end = deps.end(); i != end; i = i->next()) { int found = 0; - pmdepmissing_t *miss = f_ptrlistitem_data(i); + pmdepmissing_t *miss = (pmdepmissing_t *)*i; Package *ps = NULL; /* check if one of the packages in *list already provides this dependency */ for(auto j = list.begin(), j_end = list.end(); j != j_end && !found; j = j->next()) { - Package *sp = (Package *)f_ptrlistitem_data(j); + Package *sp = (Package *)*j; if(sp->provides(miss->depend.name)) { _pacman_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"), sp->name(), miss->depend.name); @@ -586,13 +586,13 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, FPtrList &list, /* find the package in one of the repositories */ /* check literals */ for(auto j = handle->dbs_sync.begin(), j_end = handle->dbs_sync.end(); !ps && j != j_end; j = j->next()) { - ps = ((Database *)f_ptrlistitem_data(j))->find(miss->depend.name); + ps = ((Database *)*j)->find(miss->depend.name); } /* check provides */ for(auto j = handle->dbs_sync.begin(), j_end = handle->dbs_sync.end(); !ps && j != j_end; j = j->next()) { - FPtrList provides = ((Database *)f_ptrlistitem_data(j))->whatPackagesProvide(miss->depend.name); + FPtrList provides = ((Database *)*j)->whatPackagesProvide(miss->depend.name); if(!provides.empty()) { - ps = f_ptrlistitem_data(provides.begin()); + ps = *provides.begin(); } } if(ps == NULL) { @@ -603,7 +603,7 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, FPtrList &list, FREELIST(*data); goto error; } - *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); + *miss = *(pmdepmissing_t *)*i; ((FPtrList *)*data)->add(miss); } pm_errno = PM_ERR_UNSATISFIED_DEPS; @@ -641,7 +641,7 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, FPtrList &list, FREELIST(*data); goto error; } - *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); + *miss = *(pmdepmissing_t *)*i; ((FPtrList *)*data)->add(miss); } pm_errno = PM_ERR_UNSATISFIED_DEPS; @@ -714,7 +714,7 @@ static int str_cmp(const void *s1, const void *s2) int inList(FPtrList *lst, char *lItem) { auto ll = lst->begin(), end = lst->end(); while(ll != end) { - if(!strcmp(lItem, (char *)f_ptrlistitem_data(ll))) { + if(!strcmp(lItem, (const char *)*ll)) { return 1; } ll = ll->next(); @@ -730,7 +730,7 @@ int pacman_output_generate(FStringList *targets, FPtrList *dblist) { int foundMatch = 0; unsigned int inforeq = INFRQ_DEPENDS; for(auto j = dblist->begin(), end = dblist->end(); j != end; j = j->next()) { - Database *db = f_ptrlistitem_data(j); + Database *db = *j; do { foundMatch = 0; pkg = db->readpkg(inforeq); @@ -740,7 +740,7 @@ int pacman_output_generate(FStringList *targets, FPtrList *dblist) { foundMatch = 1; auto &depends = pkg->depends(); for(auto k = depends.begin(), k_end = depends.end(); k != k_end; k = k->next()) { - char *fullDep = f_stringlistitem_to_str(k); + char *fullDep = *k; pmdepend_t depend; if(_pacman_splitdep(fullDep, &depend)) { continue; diff --git a/lib/libpacman/handle.cpp b/lib/libpacman/handle.cpp index 46cb16f..5ff3207 100644 --- a/lib/libpacman/handle.cpp +++ b/lib/libpacman/handle.cpp @@ -168,7 +168,7 @@ Database *Handle::getDatabase(const char *treename) } for(auto i = dbs_sync.begin(), end = dbs_sync.end(); i != end; i = i->next()) { - Database *sdb = (Database *)f_ptrlistitem_data(i); + Database *sdb = (Database *)*i; if(strcmp(treename, sdb->treename()) == 0) { return sdb; } diff --git a/lib/libpacman/kernel/fstr.cpp b/lib/libpacman/kernel/fstr.cpp index ff80128..22bc65d 100644 --- a/lib/libpacman/kernel/fstr.cpp +++ b/lib/libpacman/kernel/fstr.cpp @@ -82,7 +82,7 @@ int f_stringlist_any_match(const FStringList *list, const FStrMatcher *matcher) { #ifndef F_NOCOMPAT for(auto it = list->begin(), end = list->end(); it != end; it = it->next()) { - if(matcher->match(f_stringlistitem_to_str(it)) != 0) { + if(matcher->match((const char *)*it) != 0) { return 1; } } diff --git a/lib/libpacman/package.cpp b/lib/libpacman/package.cpp index 2b982b6..c877511 100644 --- a/lib/libpacman/package.cpp +++ b/lib/libpacman/package.cpp @@ -153,7 +153,7 @@ Package *_pacman_pkg_isin(const char *needle, FPtrList *haystack) } for(auto lp = haystack->begin(), end = haystack->end(); lp != end; lp = lp->next()) { - Package *info = f_ptrlistitem_data(lp); + Package *info = *lp; if(info && !strcmp(info->name(), needle)) { return info; @@ -241,7 +241,7 @@ char *Package::fileneedbackup(const char *file) const /* run through the backup list and parse out the md5 or sha1 hash for our file */ for(auto lp = m_backup.begin(), end = m_backup.end(); lp != end; lp = lp->next()) { - char *str = strdup(f_stringlistitem_to_str(lp)); + char *str = strdup((const char *)*lp); char *ptr; /* tab delimiter */ diff --git a/lib/libpacman/package/packagecache.cpp b/lib/libpacman/package/packagecache.cpp index e7a6920..52900bf 100644 --- a/lib/libpacman/package/packagecache.cpp +++ b/lib/libpacman/package/packagecache.cpp @@ -58,7 +58,7 @@ int _pacman_packagecache_clean(int level) closedir(dir); for(auto i = cache.begin(), end = cache.end(); i != end; i = i->next()) { - const char *str = f_stringlistitem_to_str(i); + const char *str = *i; char name[PKG_NAME_LEN], version[PKG_VERSION_LEN]; if(strstr(str, PM_EXT_PKG) == NULL) { @@ -73,8 +73,8 @@ int _pacman_packagecache_clean(int level) clean.add(str); continue; } - for(auto j = i->next(); j != end; j = j->next()) { - const char *s = f_stringlistitem_to_str(j); + for(FPtrList::iterator j = i->next(); j != end; j = j->next()) { + const char *s = *j; char n[PKG_NAME_LEN], v[PKG_VERSION_LEN]; if(strstr(s, PM_EXT_PKG) == NULL) { @@ -97,7 +97,7 @@ int _pacman_packagecache_clean(int level) for(auto i = clean.begin(), end = clean.end(); i != end; i = i->next()) { char path[PATH_MAX]; - snprintf(path, PATH_MAX, "%s/%s", dirpath, f_stringlistitem_to_str(i)); + snprintf(path, PATH_MAX, "%s/%s", dirpath, *i); unlink(path); } } else { diff --git a/lib/libpacman/packages_transaction.cpp b/lib/libpacman/packages_transaction.cpp index 7caa0fa..10c6746 100644 --- a/lib/libpacman/packages_transaction.cpp +++ b/lib/libpacman/packages_transaction.cpp @@ -56,7 +56,7 @@ _pacman_packages_transaction_set_state(pmtrans_t *trans, int new_state) _pacman_log(PM_LOG_FLOW2, _("executing %s triggers..."), trigger_function); for(auto lp = trans->triggers.begin(), end = trans->triggers.end(); lp != end; lp = lp->next()) { - const char *trigger = f_stringlistitem_to_str(lp); + const char *trigger = *lp; char buf[PATH_MAX]; snprintf(buf, sizeof(buf), "%s/%s/%s", root, triggersdir, trigger); diff --git a/lib/libpacman/pacman.cpp b/lib/libpacman/pacman.cpp index 0dcc1d4..4e516ba 100644 --- a/lib/libpacman/pacman.cpp +++ b/lib/libpacman/pacman.cpp @@ -118,7 +118,7 @@ int pacman_release(void) /* and also sync ones */ while(!handle->dbs_sync.empty()) { /* db_unregister() will also update the handle->dbs_sync list */ - pacman_db_unregister(f_ptrlistitem_data(handle->dbs_sync.begin())); + pacman_db_unregister(*handle->dbs_sync.begin()); } if(handle->unlock() != 0) { @@ -471,7 +471,7 @@ void *pacman_db_getinfo(pmdb_t *_db, unsigned char parm) switch(parm) { case PM_DB_TREENAME: data = db->treename(); break; case PM_DB_FIRSTSERVER: - server = (pmserver_t*)f_ptrlistitem_data(db->servers.begin()); + server = (pmserver_t*)*db->servers.begin(); if(!strcmp(server->protocol, "file")) { snprintf(path, PATH_MAX, "%s://%s", server->protocol, server->path); } else { diff --git a/lib/libpacman/server.cpp b/lib/libpacman/server.cpp index 8743cdd..2efaf5a 100644 --- a/lib/libpacman/server.cpp +++ b/lib/libpacman/server.cpp @@ -395,12 +395,12 @@ int _pacman_downloadfiles_forreal(Handle *handle, const FPtrList &servers, const pm_errno = 0; if (count < skip) continue; /* the caller requested skip of this server */ - server = (pmserver_t*)f_ptrlistitem_data(i); + server = (pmserver_t*)*i; _pacman_log(PM_LOG_DEBUG, _("trying to download with server url: %s://%s%s"), server->protocol, server->server, server->path); /* get each file in the list */ for(auto lp = files.begin(), end = files.end(); lp != end; lp = lp->next()) { - const char *fn = f_stringlistitem_to_str(lp); + const char *fn = *lp; if(_pacman_list_is_strin(fn, &complete)) { continue; diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp index 81c0d5a..5e91d7e 100644 --- a/lib/libpacman/trans.cpp +++ b/lib/libpacman/trans.cpp @@ -122,12 +122,12 @@ int _pacman_trans_compute_triggers(pmtrans_t *trans) { /* NOTE: Not the most efficient way, but will do until we add some string hash. */ for(auto lp = trans->packages.begin(), end = trans->packages.end(); lp != end; lp = lp->next()) { - Package *pkg = f_ptrlistitem_data(lp); + Package *pkg = *lp; trans->triggers.add(pkg->triggers()); } for(auto lp = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); lp != end; lp = lp->next()) { - Package *pkg = ((pmsyncpkg_t *)f_ptrlistitem_data(lp))->pkg_new; + Package *pkg = ((pmsyncpkg_t *)*lp)->pkg_new; /* FIXME: might be incomplete */ trans->triggers.add(pkg->triggers()); @@ -186,7 +186,7 @@ int _pacman_trans_event(pmtrans_t *trans, unsigned char event, void *data1, void pmsyncpkg_t *__pmtrans_t::find(const char *pkgname) const { for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end ; i = i->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(i); + pmsyncpkg_t *ps = *i; if(ps && !strcmp(ps->pkg_name, pkgname)) { return ps; @@ -237,7 +237,7 @@ static int check_olddelay(Handle *handle) } for(auto i = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); i != end; i = i->next()) { - Database *db = f_ptrlistitem_data(i); + Database *db = *i; if(db->gettimestamp(&tm) == -1) { continue; } @@ -313,7 +313,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) *targ = '\0'; targ++; for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end && !spkg; i = i->next()) { - Database *dbs = f_ptrlistitem_data(i); + Database *dbs = *i; if(strcmp(dbs->treename(), targline) == 0) { spkg = dbs->find(targ); if(spkg == NULL) { @@ -321,7 +321,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) _pacman_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ); FPtrList p = dbs->whatPackagesProvide(targ); if(!p.empty()) { - spkg = f_ptrlistitem_data(p.begin()); + spkg = *p.begin(); _pacman_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), spkg->name(), targ); } break; @@ -331,17 +331,17 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) } else { targ = targline; for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end && !spkg; i = i->next()) { - Database *dbs = f_ptrlistitem_data(i); + Database *dbs = *i; spkg = dbs->find(targ); } if(spkg == NULL) { /* Search provides */ _pacman_log(PM_LOG_FLOW2, _("target '%s' not found -- looking for provisions"), targ); for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end && !spkg; i = i->next()) { - Database *dbs = f_ptrlistitem_data(i); + Database *dbs = *i; FPtrList p = dbs->whatPackagesProvide(targ); if(!p.empty()) { - spkg = f_ptrlistitem_data(p.begin()); + spkg = *p.begin(); _pacman_log(PM_LOG_DEBUG, _("found '%s' as a provision for '%s'"), spkg->name(), targ); } } @@ -421,9 +421,9 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) /* check if an older version of said package is already in transaction packages. * if so, replace it in the list */ - FPtrListIterator *i, *end; + FPtrList::iterator i, end; for(i = packages.begin(), end = packages.end(); i != end; i = i->next()) { - Package *pkg = f_ptrlistitem_data(i); + Package *pkg = *i; if(strcmp(pkg->name(), pkg_new->name()) == 0) { pkg_queued = pkg; break; @@ -499,7 +499,7 @@ int __pmtrans_t::prepare(FPtrList **data) if(m_type == PM_TRANS_TYPE_SYNC) { for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(i); + pmsyncpkg_t *ps = *i; list.add(ps->pkg_new); } @@ -510,7 +510,7 @@ int __pmtrans_t::prepare(FPtrList **data) EVENT(this, PM_TRANS_EVT_RESOLVEDEPS_START, NULL, NULL); _pacman_log(PM_LOG_FLOW1, _("resolving targets dependencies")); for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { - Package *spkg = ((pmsyncpkg_t *)f_ptrlistitem_data(i))->pkg_new; + Package *spkg = ((pmsyncpkg_t *)*i)->pkg_new; if(_pacman_resolvedeps(this, spkg, list, trail, data) == -1) { /* pm_errno is set by resolvedeps */ ret = -1; @@ -520,7 +520,7 @@ int __pmtrans_t::prepare(FPtrList **data) for(auto i = list.begin(), end = list.end(); i != end; i = i->next()) { /* add the dependencies found by resolvedeps to the transaction set */ - Package *spkg = f_ptrlistitem_data(i); + Package *spkg = *i; if(!find(spkg->name())) { pmsyncpkg_t *ps = new __pmsyncpkg_t(PM_SYNC_TYPE_DEPEND, spkg); if(ps == NULL) { @@ -542,14 +542,14 @@ int __pmtrans_t::prepare(FPtrList **data) /* re-order w.r.t. dependencies */ FPtrList k, l; for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { - pmsyncpkg_t *s = (pmsyncpkg_t*)f_ptrlistitem_data(i); + pmsyncpkg_t *s = (pmsyncpkg_t*)*i; k.add(s->pkg_new); } FPtrList m = _pacman_sortbydeps(k, PM_TRANS_TYPE_ADD); for(auto i = m.begin(), end = m.end(); i != end; i = i->next()) { for(auto j = syncpkgs.begin(), j_end = syncpkgs.end(); j != j_end; j = j->next()) { - pmsyncpkg_t *s = (pmsyncpkg_t*)f_ptrlistitem_data(j); - if(s->pkg_new == f_ptrlistitem_data(i)) { + pmsyncpkg_t *s = (pmsyncpkg_t*)*j; + if(s->pkg_new == *i) { l.add(s); } } @@ -582,7 +582,7 @@ int __pmtrans_t::prepare(FPtrList **data) FStringList asked; for(auto i = deps.begin(), end = deps.end(); i != end && !errorout; i = i->next()) { - pmdepmissing_t *miss = f_ptrlistitem_data(i); + pmdepmissing_t *miss = *i; int found = 0; pmsyncpkg_t *ps; Package *local; @@ -594,7 +594,7 @@ int __pmtrans_t::prepare(FPtrList **data) * if so, then just ignore it */ for(auto j = syncpkgs.begin(), j_end = syncpkgs.end(); j != j_end && !found; j = j->next()) { - ps = f_ptrlistitem_data(j); + ps = *j; if(_pacman_pkg_isin(miss->depend.name, &ps->m_replaces)) { found = 1; } @@ -708,7 +708,7 @@ int __pmtrans_t::prepare(FPtrList **data) ret = -1; goto cleanup; } - *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); + *miss = *(pmdepmissing_t *)*i; ((FPtrList *)*data)->add(miss); } } @@ -722,7 +722,7 @@ int __pmtrans_t::prepare(FPtrList **data) ret = -1; goto cleanup; } - *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); + *miss = *(pmdepmissing_t *)*i; ((FPtrList *)*data)->add(miss); } } @@ -754,9 +754,9 @@ int __pmtrans_t::prepare(FPtrList **data) */ /*EVENT(this, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);*/ for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(i); + pmsyncpkg_t *ps = *i; for(auto j = ps->m_replaces.begin(), j_end = ps->m_replaces.end(); j != j_end; j = j->next()) { - list.add(f_ptrlistitem_data(j)); + list.add(*j); } } if(!list.empty()) { @@ -765,7 +765,7 @@ int __pmtrans_t::prepare(FPtrList **data) if(!deps.empty()) { int errorout = 0; for(auto i = deps.begin(), end = deps.end(); i != end; i = i->next()) { - pmdepmissing_t *miss = f_ptrlistitem_data(i); + pmdepmissing_t *miss = *i; if(!find(miss->depend.name)) { int pfound = 0; /* If miss->depend.name depends on something that miss->target and a @@ -783,18 +783,18 @@ int __pmtrans_t::prepare(FPtrList **data) for(auto k = depends.begin(), k_end = depends.end(); k != k_end && !pfound; k = k->next()) { auto &provides = leavingp->provides(); for(auto m = provides.begin(), m_end = provides.end(); m != m_end && !pfound; m = m->next()) { - if(!strcmp(f_stringlistitem_to_str(k), f_stringlistitem_to_str(m))) { + if(!strcmp((const char *)*k, (const char *)*m)) { /* Found a match -- now look through final for a package that * provides the same thing. If none are found, then it truly * is an unresolvable conflict. */ for(auto n = syncpkgs.begin(), n_end = syncpkgs.end(); n != n_end && !pfound; n = n->next()) { - pmsyncpkg_t *sp = f_ptrlistitem_data(n); + pmsyncpkg_t *sp = *n; auto &provides = sp->pkg_new->provides(); for(auto o = provides.begin(), o_end = provides.end(); o != o_end && !pfound; o = o->next()) { - if(!strcmp(f_stringlistitem_to_str(m), f_stringlistitem_to_str(o))) { + if(!strcmp((const char *)*m, (const char *)*o)) { /* found matching provisio -- we're good to go */ _pacman_log(PM_LOG_FLOW2, _("found '%s' as a provision for '%s' -- conflict aborted"), - sp->pkg_name, f_stringlistitem_to_str(o)); + sp->pkg_name, (const char *)*o); pfound = 1; } } @@ -812,7 +812,7 @@ int __pmtrans_t::prepare(FPtrList **data) ret = -1; goto cleanup; } - *miss = *(pmdepmissing_t *)f_ptrlistitem_data(i); + *miss = *(pmdepmissing_t *)*i; ((FPtrList *)*data)->add(miss); } } @@ -861,7 +861,7 @@ cleanup: if((m_type == PM_TRANS_TYPE_REMOVE) && (flags & PM_TRANS_FLAG_CASCADE)) { while(!lp.empty()) { for(auto i = lp.begin(), end = lp.end(); i != end; i = i->next()) { - pmdepmissing_t *miss = (pmdepmissing_t *)f_ptrlistitem_data(i); + pmdepmissing_t *miss = (pmdepmissing_t *)*i; Package *pkg_local = db_local->scan(miss->depend.name, INFRQ_ALL); if(pkg_local) { _pacman_log(PM_LOG_FLOW2, _("pulling %s in the targets list"), pkg_local->name()); @@ -927,13 +927,13 @@ cleanup: EVENT(this, PM_TRANS_EVT_CLEANUP_START, NULL, NULL); _pacman_log(PM_LOG_FLOW1, _("cleaning up")); for (auto lp = packages.begin(), lp_end = packages.end(); lp != lp_end; lp = lp->next()) { - Package *pkg_new = (Package *)f_ptrlistitem_data(lp); + Package *pkg_new = (Package *)*lp; auto &removes = pkg_new->removes(); for (auto rmlist = removes.begin(), rmlist_end = removes.end(); rmlist != rmlist_end; rmlist = rmlist->next()) { char rm_fname[PATH_MAX]; - snprintf(rm_fname, PATH_MAX, "%s%s", m_handle->root, f_stringlistitem_to_str(rmlist)); + snprintf(rm_fname, PATH_MAX, "%s%s", m_handle->root, (const char *)*rmlist); remove(rm_fname); } } @@ -1102,7 +1102,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran */ auto &backup = pkg->backup(); for(auto lp = backup.begin(), lp_end = backup.end(); lp != lp_end; lp = lp->next()) { - char *file = f_stringlistitem_to_str(lp); + char *file = (const char *)*lp; if(!file) continue; if(!strcmp(file, pathname)) { @@ -1233,7 +1233,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran for(auto lp = backup.begin(), lp_end = backup.end(); lp != lp_end; lp = lp->next()) { char *fn, *md5, *sha1; char path[PATH_MAX]; - char *file = f_stringlistitem_to_str(lp); + char *file = (const char *)*lp; if(!file) continue; if(!strcmp(file, pathname)) { @@ -1415,10 +1415,10 @@ int __pmtrans_t::commit(FPtrList **data) int done = 1; for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end; i = i->next()) { struct stat buf; - Database *current = f_ptrlistitem_data(i); + Database *current = *i; for(auto j = syncpkgs.begin(), j_end = syncpkgs.end(); j != j_end; j = j->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(j); + pmsyncpkg_t *ps = *j; Package *spkg = ps->pkg_new; Database *dbs = spkg->database(); @@ -1484,7 +1484,7 @@ int __pmtrans_t::commit(FPtrList **data) EVENT(this, PM_TRANS_EVT_INTEGRITY_START, NULL, NULL); for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(i); + pmsyncpkg_t *ps = *i; retval = _pacman_cachedpkg_check_integrity(ps->pkg_new, this, data); } @@ -1522,9 +1522,9 @@ int __pmtrans_t::commit(FPtrList **data) tr->conv.connect(&conv); tr->progress.connect(&progress); for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(i); + pmsyncpkg_t *ps = *i; for(auto j = ps->m_replaces.begin(), end = ps->m_replaces.end(); j != end; j = j->next()) { - Package *pkg = f_ptrlistitem_data(j); + Package *pkg = *j; if(!_pacman_pkg_isin(pkg->name(), &tr->packages)) { if(tr->add(pkg->name(), tr->m_type, tr->flags) == -1) { goto error; @@ -1559,7 +1559,7 @@ int __pmtrans_t::commit(FPtrList **data) tr->conv.connect(&conv); tr->progress.connect(&progress); for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(i); + pmsyncpkg_t *ps = *i; Package *spkg = ps->pkg_new; char str[PATH_MAX]; snprintf(str, PATH_MAX, "%s%s/%s-%s-%s" PM_EXT_PKG, m_handle->root, m_handle->cachedir, spkg->name(), spkg->version(), spkg->arch); @@ -1568,7 +1568,7 @@ int __pmtrans_t::commit(FPtrList **data) } /* using f_ptrlist_last() is ok because addtarget() adds the new target at the * end of the tr->packages list */ - spkg = f_ptrlistitem_data(tr->packages.last()); + spkg = *tr->packages.last(); if(ps->type == PM_SYNC_TYPE_DEPEND || flags & PM_TRANS_FLAG_ALLDEPS) { spkg->m_reason = PM_PKG_REASON_DEPEND; } else if(ps->type == PM_SYNC_TYPE_UPGRADE && !m_handle->sysupgrade) { @@ -1591,17 +1591,17 @@ int __pmtrans_t::commit(FPtrList **data) if(replaces) { _pacman_log(PM_LOG_FLOW1, _("updating database for replaced packages' dependencies")); for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(i); + pmsyncpkg_t *ps = *i; if(ps->type == PM_SYNC_TYPE_REPLACE) { Package *pkg_new = db_local->find(ps->pkg_name); for(auto j = ps->m_replaces.begin(), end = ps->m_replaces.end(); j != end; j = j->next()) { - Package *old = f_ptrlistitem_data(j); + Package *old = *j; /* merge lists */ auto &requiredby = old->requiredby(); for(auto k = requiredby.begin(), end = requiredby.end(); k != end; k = k->next()) { - if(!_pacman_list_is_strin(f_stringlistitem_to_str(k), &pkg_new->requiredby())) { + if(!_pacman_list_is_strin((const char *)*k, &pkg_new->requiredby())) { /* replace old's name with new's name in the requiredby's dependency list */ - Package *depender = db_local->find(f_stringlistitem_to_str(k)); + Package *depender = db_local->find((const char *)*k); if(depender == NULL) { /* If the depending package no longer exists in the local db, * then it must have ALSO conflicted with ps->pkg. If @@ -1611,7 +1611,7 @@ int __pmtrans_t::commit(FPtrList **data) } auto &depends = depender->depends(); for(auto m = depends.begin(), end = depends.end(); m != end; m = m->next()) { - if(!strcmp(f_stringlistitem_to_str(m), old->name())) { + if(!strcmp((const char *)*m, old->name())) { void *str = strdup(pkg_new->name()); m->swap_data(&str); free(str); @@ -1622,7 +1622,7 @@ int __pmtrans_t::commit(FPtrList **data) pkg_new->name(), pkg_new->version()); } /* add the new requiredby */ - pkg_new->m_requiredby.add(f_stringlistitem_to_str(k)); + pkg_new->m_requiredby.add((const char *)*k); } } } @@ -1643,7 +1643,7 @@ int __pmtrans_t::commit(FPtrList **data) if(!varcache && !(flags & PM_TRANS_FLAG_DOWNLOADONLY)) { /* delete packages */ for(auto i = files.begin(), end = files.end(); i != end; i = i->next()) { - unlink(f_stringlistitem_to_str(i)); + unlink((const char *)*i); } } return(retval); @@ -1664,9 +1664,9 @@ int __pmtrans_t::commit(FPtrList **data) } if(type & PM_TRANS_TYPE_ADD) { - pkg_new = (Package *)f_ptrlistitem_data(targ); + pkg_new = (Package *)*targ; } else { - pkg_local = (Package *)f_ptrlistitem_data(targ); + pkg_local = (Package *)*targ; } /* see if this is an upgrade. if so, remove the old package first */ @@ -1755,7 +1755,7 @@ int __pmtrans_t::commit(FPtrList **data) Package *depinfo = NULL; pmdepend_t depend; char *data; - if(_pacman_splitdep((char*)f_stringlistitem_to_str(lp), &depend)) { + if(_pacman_splitdep((char *)*lp, &depend)) { continue; } /* if this dependency is in the transaction targets, no need to update @@ -1774,7 +1774,7 @@ int __pmtrans_t::commit(FPtrList **data) * the first one. */ /* use the first one */ - depinfo = db_local->find(((Package *)f_ptrlistitem_data(provides.begin()))->name()); + depinfo = db_local->find(((Package *)*provides.begin())->name()); } if(depinfo == NULL) { _pacman_log(PM_LOG_ERROR, _("could not find dependency '%s'"), depend.name); @@ -1814,17 +1814,17 @@ int __pmtrans_t::commit(FPtrList **data) * looking for packages depending on the package to add */ auto &cache = _pacman_db_get_pkgcache(db_local); for(auto lp = cache.begin(), lp_end = cache.end(); lp != lp_end; lp = lp->next()) { - Package *tmpp = f_ptrlistitem_data(lp); + Package *tmpp = *lp; if(tmpp == NULL) { continue; } auto &depends = tmpp->depends(); for(auto tmppm = depends.begin(), end = depends.end(); tmppm != end; tmppm = tmppm->next()) { pmdepend_t depend; - if(_pacman_splitdep(f_ptrlistitem_data(tmppm), &depend)) { + if(_pacman_splitdep(*tmppm, &depend)) { continue; } - if(f_ptrlistitem_data(tmppm) && (!strcmp(depend.name, pkg_new->name()) || pkg_new->provides(depend.name))) { + if(*tmppm && (!strcmp(depend.name, pkg_new->name()) || pkg_new->provides(depend.name))) { _pacman_log(PM_LOG_DEBUG, _("adding '%s' in requiredby field for '%s'"), tmpp->name(), pkg_new->name()); pkg_new->m_requiredby.add(tmpp->name()); } @@ -1855,7 +1855,7 @@ int __pmtrans_t::commit(FPtrList **data) for(auto lp = depends.begin(), lp_end = depends.end(); lp != lp_end; lp = lp->next()) { Package *depinfo; pmdepend_t depend; - if(_pacman_splitdep(f_stringlistitem_to_str(lp), &depend)) { + if(_pacman_splitdep((const char *)*lp, &depend)) { continue; } depinfo = db_local->find(depend.name); @@ -1867,7 +1867,7 @@ int __pmtrans_t::commit(FPtrList **data) * the first one. */ /* use the first one */ - depinfo = db_local->find(((Package *)f_ptrlistitem_data(provides.begin()))->name()); + depinfo = db_local->find(((Package *)*provides.begin())->name()); } if(depinfo == NULL) { _pacman_log(PM_LOG_ERROR, _("could not find dependency '%s'"), depend.name); diff --git a/lib/libpacman/trans_sysupgrade.cpp b/lib/libpacman/trans_sysupgrade.cpp index a2ca6fb..3397ead 100644 --- a/lib/libpacman/trans_sysupgrade.cpp +++ b/lib/libpacman/trans_sysupgrade.cpp @@ -83,23 +83,23 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) /* check for "recommended" package replacements */ _pacman_log(PM_LOG_FLOW1, _("checking for package replacements")); for(auto i = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); i != end; i = i->next()) { - FPtrList &cache = _pacman_db_get_pkgcache(f_ptrlistitem_data(i)); + FPtrList &cache = _pacman_db_get_pkgcache(*i); for(auto j = cache.begin(), end = cache.end(); j != end; j = j->next()) { - Package *spkg = f_ptrlistitem_data(j); + Package *spkg = *j; auto &replaces = spkg->replaces(); for(auto k = replaces.begin(), end = replaces.end(); k != end; k = k->next()) { FPtrList &cache_local = _pacman_db_get_pkgcache(db_local); for(auto m = cache_local.begin(), end = cache_local.end(); m != end; m = m->next()) { - Package *lpkg = f_ptrlistitem_data(m); - if(!strcmp(f_stringlistitem_to_str(k), lpkg->name())) { - _pacman_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), f_stringlistitem_to_str(k), spkg->name()); + Package *lpkg = *m; + if(!strcmp((const char *)*k, lpkg->name())) { + _pacman_log(PM_LOG_DEBUG, _("checking replacement '%s' for package '%s'"), (const char *)*k, spkg->name()); if(_pacman_list_is_strin(lpkg->name(), &handle->ignorepkg)) { _pacman_log(PM_LOG_WARNING, _("%s-%s: ignoring package upgrade (to be replaced by %s-%s)"), lpkg->name(), lpkg->version(), spkg->name(), spkg->version()); } else { /* get confirmation for the replacement */ int doreplace = 0; - QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, (void *)((Database *)f_ptrlistitem_data(i))->treename(), &doreplace); + QUESTION(trans, PM_TRANS_CONV_REPLACE_PKG, lpkg, spkg, (void *)((Database *)*i)->treename(), &doreplace); if(doreplace) { /* if confirmed, add this to the 'final' list, designating 'lpkg' as @@ -136,12 +136,12 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) for(auto i = cache_local.begin(), end= cache_local.end(); i != end; i = i->next()) { int cmp; int replace=0; - Package *local = f_ptrlistitem_data(i); + Package *local = *i; Package *spkg = NULL; pmsyncpkg_t *ps; for(auto j = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); !spkg && j != end; j = j->next()) { - spkg = ((Database *)f_ptrlistitem_data(j))->find(local->name()); + spkg = ((Database *)*j)->find(local->name()); } if(spkg == NULL) { _pacman_log(PM_LOG_DEBUG, _("'%s' not found in sync db -- skipping"), local->name()); @@ -150,7 +150,7 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) /* we don't care about a to-be-replaced package's newer version */ for(auto j = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); j != end && !replace; j = j->next()) { - ps = f_ptrlistitem_data(j); + ps = *j; if(_pacman_pkg_isin(spkg->name(), &ps->m_replaces)) { replace=1; } diff --git a/lib/libpacman/util.cpp b/lib/libpacman/util.cpp index 1111a91..fbd300f 100644 --- a/lib/libpacman/util.cpp +++ b/lib/libpacman/util.cpp @@ -128,7 +128,7 @@ typedef struct __cache_t { static int list_startswith(char *needle, FPtrList *haystack) { for (auto i = haystack->begin(), end = haystack->end(); i != end; i = i->next()) { - cache_t *c = f_ptrlistitem_data(i); + cache_t *c = *i; if (!strncmp(c->str, needle, strlen(c->str))) { c->hit = 1; return(1); @@ -198,7 +198,7 @@ int _pacman_unpack(const char *archive, const char *prefix, const char *fn) /* finally delete the old ones */ for (auto i = cache.begin(), end = cache.end(); i != end; i = i->next()) { - cache_t *c = f_ptrlistitem_data(i); + cache_t *c = *i; if (!c->hit) { snprintf(expath, PATH_MAX, "%s/%s", prefix, c->str); _pacman_rmrf(expath); @@ -482,11 +482,11 @@ int _pacman_check_freespace(pmtrans_t *trans, pmlist_t **data) long long pkgsize=0, freespace; for(auto i = trans->packages.begin(), end = trans->packages.end(); i != end; i = i->next()) { - Package *pkg = f_ptrlistitem_data(i); + Package *pkg = *i; pkgsize += pkg->size; } for(auto i = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); i != end; i = i->next()) { - pmsyncpkg_t *ps = f_ptrlistitem_data(i); + pmsyncpkg_t *ps = *i; if(ps->type != PM_SYNC_TYPE_REPLACE) { Package *pkg = ps->pkg_new; diff --git a/lib/libpacman/util/fptrlist.cpp b/lib/libpacman/util/fptrlist.cpp index 8b928c8..2e10f32 100644 --- a/lib/libpacman/util/fptrlist.cpp +++ b/lib/libpacman/util/fptrlist.cpp @@ -34,12 +34,12 @@ FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn) list = new FPtrList(); } - FPtrListIterator *add = new FPtrListItem(data); + FPtrListItem *add = new FPtrListItem(data); /* Find insertion point. */ - FCListItem *previous = list; - for(FCListItem *end = f_ptrlist_end(list); previous->next() != end; previous = previous->next()) { - if(fn(data, f_ptrlistitem_data((FPtrListItem *)previous->next())) <= 0) { + FPtrListItem *previous, *end; + for(previous = end = list->_self(); previous->next() != end; previous = previous->next()) { + if(fn(data, previous->next()->m_data) <= 0) { break; } } @@ -73,7 +73,7 @@ FPtrList *_pacman_list_reverse(FPtrList *list) FPtrList *newlist = f_ptrlist_new(); for(auto it = list->rbegin(), end = list->rend(); it != end; it = it->previous()) { - newlist->add(f_ptrlistitem_data(it)); + newlist->add(*it); } return(newlist); @@ -83,7 +83,7 @@ void *f_ptrlistitem_data(const FPtrListIterator *self) { ASSERT(self != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - return self->m_data; + return **self; } FPtrListIterator *f_ptrlistitem_next(FPtrListIterator *self) @@ -119,7 +119,7 @@ int f_ptrlist_delete(FPtrList *self, FVisitor *visitor) FPtrList &FPtrList::add(void *data) { - (new FPtrListItem(data))->insert_after(last()); + (new FPtrListItem(data))->insert_after(_previous()); return *this; } @@ -136,7 +136,7 @@ bool FPtrList::remove(void *ptr, _pacman_fn_cmp fn, void **data) if(data) { *data = i->m_data; } - delete i; + delete i.m_iterable; return true; } } diff --git a/lib/libpacman/util/fptrlist.h b/lib/libpacman/util/fptrlist.h index c72ec84..da0d479 100644 --- a/lib/libpacman/util/fptrlist.h +++ b/lib/libpacman/util/fptrlist.h @@ -78,7 +78,53 @@ class FPtrList public: friend FPtrList *f_ptrlist_add_sorted(FPtrList *list, void *data, _pacman_fn_cmp fn); - typedef FPtrListItem *iterator; + typedef FPtrListItem *iterable; + + class iterator + { + public: + iterator(iterable it = iterable()) + : m_iterable(it) + { } + + bool operator == (const iterator &o) + { + return m_iterable == o.m_iterable; + } + + bool operator != (const iterator &o) + { + return !operator == (o); + } + + iterable operator -> () const + { + return m_iterable; + } + + void *operator * () const + { + return m_iterable->m_data; + } + + operator iterable () + { + return m_iterable; + } + + iterator next() const + { + return m_iterable->next(); + } + + iterator previous() const + { + return m_iterable->previous(); + } + + iterable m_iterable; + }; + typedef iterator const_iterator; typedef iterator reverse_iterator; typedef iterator const_reverse_iterator; @@ -102,7 +148,7 @@ public: iterator begin() { ASSERT(this != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - return iterator(next()); + return iterator(_next()); } const_iterator begin() const @@ -113,12 +159,12 @@ public: const_iterator cbegin() const { ASSERT(this != NULL, RET_ERR(PM_ERR_WRONG_ARGS, NULL)); - return const_iterator(next()); + return const_iterator(_next()); } iterator end() { - return iterator(this); + return iterator(_self()); } const_iterator end() const @@ -128,12 +174,12 @@ public: const_iterator cend() const { - return const_iterator(this); + return const_iterator(_self()); } iterator last() { - return iterator(previous()); + return iterator(_previous()); } const_iterator last() const @@ -143,12 +189,12 @@ public: const_iterator clast() const { - return const_iterator(previous()); + return const_iterator(_previous()); } reverse_iterator rbegin() { - return reverse_iterator(previous()); + return reverse_iterator(_previous()); } const_reverse_iterator rbegin() const @@ -158,12 +204,12 @@ public: const_reverse_iterator crbegin() const { - return const_reverse_iterator(previous()); + return const_reverse_iterator(_previous()); } reverse_iterator rend() { - return reverse_iterator(this); + return reverse_iterator(_self()); } const_reverse_iterator rend() const @@ -173,7 +219,7 @@ public: const_reverse_iterator crend() const { - return const_reverse_iterator(this); + return const_reverse_iterator(_self()); } bool empty() const @@ -196,6 +242,22 @@ public: FCListItem::swap(o); } +protected: + iterable _next() const + { + return static_cast<iterable>(m_next); + } + + iterable _previous() const + { + return static_cast<iterable>(m_previous); + } + + iterable _self() const + { + return static_cast<iterable>((FCListItem *)this); + } + private: FPtrList(const FPtrList &o); FPtrList &operator = (const FPtrList &o); diff --git a/lib/libpacman/util/fstringlist.cpp b/lib/libpacman/util/fstringlist.cpp index cb6159a..be05baf 100644 --- a/lib/libpacman/util/fstringlist.cpp +++ b/lib/libpacman/util/fstringlist.cpp @@ -35,7 +35,7 @@ int _pacman_list_is_strin(const char *needle, FStringList *haystack) { for(auto lp = haystack->begin(), end = haystack->end(); lp != end; lp = lp->next()) { - const char *str = f_stringlistitem_to_str(lp); + const char *str = *lp; if(str && !strcmp(str, needle)) { return(1); @@ -55,7 +55,7 @@ FStringList *_pacman_list_remove_dupes(FStringList *list) FStringList *newlist = NULL; for(auto i = list->begin(), end = list->end(); i != end; i = i->next()) { - const char *str = f_stringlistitem_to_str(i); + const char *str = *i; if(!_pacman_list_is_strin(str, newlist)) { newlist = f_stringlist_add(newlist, str); @@ -139,7 +139,7 @@ FStringList::FStringList(FStringList &&o) FStringList &FStringList::operator = (const FStringList &o) { for(auto lp = o.begin(), end = o.end(); lp != end; lp = lp->next()) { - f_stringlist_add(this, f_stringlistitem_to_str(lp)); + f_stringlist_add(this, *lp); } return *this; @@ -160,7 +160,7 @@ FStringList &FStringList::add(const char *s) FStringList &FStringList::add(const FStringList &o) { for(auto lp = o.begin(), end = o.end(); lp != end; lp = lp->next()) { - add(f_stringlistitem_to_str(lp)); + add((const char *)*lp); } return *this; } _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
