Git-Url: http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=b7fc4ddc458f07c066c8e3d2a664aa0a7656c62d
commit b7fc4ddc458f07c066c8e3d2a664aa0a7656c62d Author: Michel Hermier <[email protected]> Date: Wed Sep 10 07:06:37 2014 +0200 libpacman: Moake the temporary iterator work with ++/--. diff --git a/lib/libpacman/cache.cpp b/lib/libpacman/cache.cpp index 3ae15f0..ba92763 100644 --- a/lib/libpacman/cache.cpp +++ b/lib/libpacman/cache.cpp @@ -146,7 +146,7 @@ Group *_pacman_db_get_grpfromlist(FPtrList *list, const char *target) return(NULL); } - for(auto i = list->begin(), end = list->end(); i != end; i = i->next()) { + for(auto i = list->begin(), end = list->end(); i != end; ++i) { Group *info = *i; if(strcmp(info->name, target) == 0) { @@ -167,7 +167,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()) { + for(auto it = cache.begin(), end = cache.end(); it != end; ++it) { Package *pkg = *it; if(!(pkg->flags & INFRQ_DESC)) { @@ -175,7 +175,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()) { + for(auto git = groups.begin(), git_end = groups.end(); git != git_end; ++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 3ff6140..6a9f331 100644 --- a/lib/libpacman/conflict.cpp +++ b/lib/libpacman/conflict.cpp @@ -63,7 +63,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()) { + for(auto i = packages.begin(), end = packages.end(); i != end; ++i) { Package *tp = (Package *)*i; if(tp == NULL) { continue; @@ -78,7 +78,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()) { + for(auto j = conflicts.begin(), j_end = conflicts.end(); j != j_end; ++j) { const char *conflict = (const char *)*j; if(!strcmp(tp->name(), conflict)) { /* a package cannot conflict with itself -- that's just not nice */ @@ -87,7 +87,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) /* CHECK 1: check targets against database */ _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()) { + for(auto k = cache.begin(), k_end = cache.end(); k != k_end; ++k) { Package *dp = (Package *)*k; if(!strcmp(dp->name(), tp->name())) { /* a package cannot conflict with itself -- that's just not nice */ @@ -102,7 +102,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) } else { /* 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()) { + for(auto m = provides.begin(), m_end = provides.end(); m != m_end; ++m) { if(!strcmp((const char *)*m, conflict)) { /* confict */ _pacman_log(PM_LOG_DEBUG, _("targs vs db: found %s as a conflict for %s"), @@ -115,7 +115,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()) { + for(auto k = packages.begin(), k_end = packages.end(); k != k_end; ++k) { Package *otp = (Package *)*k; if(!strcmp(otp->name(), tp->name())) { /* a package cannot conflict with itself -- that's just not nice */ @@ -130,7 +130,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) } else { /* 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()) { + for(auto m = provides.begin(), m_end = provides.end(); m != m_end; ++m) { 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()); @@ -144,7 +144,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) /* CHECK 3: check database against targets */ _pacman_log(PM_LOG_DEBUG, _("checkconflicts: db vs targ '%s'"), 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()) { + for(auto k = cache.begin(), k_end = cache.end(); k != k_end; ++k) { FStringList *conflicts; int usenewconflicts = 0; @@ -156,7 +156,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) /* If this package (*info) is also in our packages FPtrList, use the * 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()) { + for(auto j = packages.begin(), j_end = packages.end(); j != j_end; ++j) { Package *pkg = (Package *)*j; if(!strcmp(pkg->name(), info->name())) { /* Use the new, to-be-installed package's conflicts */ @@ -168,7 +168,7 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) /* Use the old package's conflicts, it's the only set we have */ conflicts = &info->conflicts(); } - for(auto j = conflicts->begin(), j_end = conflicts->end(); j != j_end; j = j->next()) { + for(auto j = conflicts->begin(), j_end = conflicts->end(); j != j_end; ++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()); @@ -176,9 +176,9 @@ FPtrList _pacman_checkconflicts(pmtrans_t *trans, const FPtrList &packages) _pacman_depmisslist_add(baddeps, miss); } else { /* see if the db package conflicts with something we provide */ - for(auto m = conflicts->begin(), m_end = conflicts->end(); m != m_end; m = m->next()) { + for(auto m = conflicts->begin(), m_end = conflicts->end(); m != m_end; ++m) { auto &provides = tp->provides(); - for(auto n = provides.begin(), n_end = provides.end(); n != n_end; n = n->next()) { + for(auto n = provides.begin(), n_end = provides.end(); n != n_end; ++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()); @@ -208,22 +208,22 @@ static FStringList chk_fileconflicts(const FStringList &filesA, const FStringLis const char *strB = (const char *)*pB; /* skip directories, we don't care about dir conflicts */ if(strA[strlen(strA)-1] == '/') { - pA = pA->next(); + ++pA; } else if(strB[strlen(strB)-1] == '/') { - pB = pB->next(); + ++pB; } else { int cmp = strcmp(strA, strB); if(cmp < 0) { /* item only in filesA, ignore it */ - pA = pA->next(); + ++pA; } else if(cmp > 0) { /* item only in filesB, ignore it */ - pB = pB->next(); + ++pB; } else { /* item in both, record it */ ret.add(strA); - pA = pA->next(); - pB = pB->next(); + ++pA; + ++pB; } } } @@ -248,16 +248,16 @@ FPtrList _pacman_db_find_conflicts(pmtrans_t *trans) howmany = f_ptrlist_count(&trans->packages); /* CHECK 1: check every target against every target */ - for(auto i = trans->packages.begin(), end = trans->packages.end(); i != end; i = i->next()) { + for(auto i = trans->packages.begin(), end = trans->packages.end(); i != end; ++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()) { + for(auto j = i; j != end; ++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()) { + for(auto k = ret.begin(), k_end = ret.end(); k != k_end; ++k) { pmconflict_t *conflict = _pacman_malloc(sizeof(pmconflict_t)); if(conflict == NULL) { continue; @@ -275,7 +275,7 @@ FPtrList _pacman_db_find_conflicts(pmtrans_t *trans) p = (Package*)*i; dbpkg = NULL; auto &files = p->files(); - for(auto j = files.begin(), j_end = files.end(); j != j_end; j = j->next()) { + for(auto j = files.begin(), j_end = files.end(); j != j_end; ++j) { filestr = (const char *)*j; snprintf(path, PATH_MAX, "%s%s", root, filestr); /* is this target a file or directory? */ @@ -303,7 +303,7 @@ FPtrList _pacman_db_find_conflicts(pmtrans_t *trans) /* Check if the conflicting file has been moved to another package/target */ 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()) { + for(auto k = trans->packages.begin(), k_end = trans->packages.end(); k != k_end && !ok; ++k) { Package *p2 = (Package *)*k; /* As long as they're not the current package */ if(strcmp(p2->name(), p->name())) { diff --git a/lib/libpacman/db.cpp b/lib/libpacman/db.cpp index 8ca636a..97e66ae 100644 --- a/lib/libpacman/db.cpp +++ b/lib/libpacman/db.cpp @@ -101,7 +101,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()) { + for(auto it = cache.begin(), end = cache.end(); it != end; ++it) { Package *pkg = (Package *)*it; if(packagematcher.match(pkg)) { @@ -120,7 +120,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()) { + for(auto i = needles.begin(), end = needles.end(); i != end; ++i) { const char *pattern = (const char *)*i; if(f_strempty(pattern)) { @@ -131,7 +131,7 @@ FPtrList Database::filter(const FStringList &needles, int packagestrmatcher_flag PackageMatcher packagematcher(pattern, packagestrmatcher_flags, strmatcher_flags); FPtrList &cache = _pacman_db_get_pkgcache(this); - for(auto j = cache.begin(), j_end = cache.end(); j != j_end; j = j->next()) { + for(auto j = cache.begin(), j_end = cache.end(); j != j_end; ++j) { Package *pkg = (Package *)*j; if(packagematcher.match(pkg)) { @@ -155,7 +155,7 @@ Package *Database::find(const PackageMatcher &packagematcher) Package *ret = NULL; FPtrList &cache = _pacman_db_get_pkgcache(this); - for(auto i = cache.begin(), end = cache.end(); i != end; i = i->next()) { + for(auto i = cache.begin(), end = cache.end(); i != end; ++i) { Package *pkg = (Package *)*i; if(packagematcher.match(pkg)) { diff --git a/lib/libpacman/db/localdb.cpp b/lib/libpacman/db/localdb.cpp index b62d797..85b7c19 100644 --- a/lib/libpacman/db/localdb.cpp +++ b/lib/libpacman/db/localdb.cpp @@ -142,7 +142,7 @@ int _pacman_localpackage_remove(Package *pkg, pmtrans_t *trans, int howmany, int _pacman_log(PM_LOG_FLOW1, _("removing files")); /* iterate through the list backwards, unlinking files */ - for(auto lp = pkg->files().rbegin(), end = pkg->files().rend(); lp != end; lp = lp->previous()) { + for(auto lp = pkg->files().rbegin(), end = pkg->files().rend(); lp != end; --lp /* FIXME: should be ++lp when operators are really working */) { int nb = 0; double percent = 0; const char *file = *lp; @@ -178,7 +178,7 @@ int _pacman_localpackage_remove(Package *pkg, pmtrans_t *trans, int howmany, int * see the big comment block in db_find_conflicts() for an * explanation. */ int skipit = 0; - for(auto j = trans->skiplist.begin(), end = trans->skiplist.end(); j != end; j = j->next()) { + for(auto j = trans->skiplist.begin(), end = trans->skiplist.end(); j != end; ++j) { if(!strcmp(file, *j)) { skipit = 1; } @@ -391,7 +391,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()) { + for(auto lp = values.begin(), end = values.end(); lp != end; ++lp) { fprintf(stream, "%s\n", *lp); } fputc('\n', stream); @@ -509,11 +509,11 @@ 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()) { + for(auto lp = cache.begin(), end = cache.end(); lp != end; ++lp) { Package *info = (Package *)*lp; auto &files = info->files(); - for(auto i = files.begin(), end = files.end(); i != end; i = i->next()) { + for(auto i = files.begin(), end = files.end(); i != end; ++i) { char path[PATH_MAX]; snprintf(path, PATH_MAX, "%s%s", m_handle->root, *i); diff --git a/lib/libpacman/db/localdb_files.cpp b/lib/libpacman/db/localdb_files.cpp index ed28ddf..396774d 100644 --- a/lib/libpacman/db/localdb_files.cpp +++ b/lib/libpacman/db/localdb_files.cpp @@ -74,7 +74,7 @@ int _pacman_localdb_desc_fread(Package *info, FILE *fp) if(!strcmp(line, "%DESC%")) { _pacman_db_read_lines(info->desc_localized, line, sline, fp); 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()) { + for (auto i = info->desc_localized.begin(), end = info->desc_localized.end(); i != end; ++i) { const char *desc = *i; const size_t language_len = strlen(handle->language); if (!strncmp(desc, handle->language, language_len) && *(desc+language_len) == ' ') { diff --git a/lib/libpacman/deps.cpp b/lib/libpacman/deps.cpp index 9882858..e9aab2c 100644 --- a/lib/libpacman/deps.cpp +++ b/lib/libpacman/deps.cpp @@ -79,7 +79,7 @@ __pmdepmissing_t::__pmdepmissing_t(const char *target, unsigned char type, unsig static int _pacman_depmiss_isin(pmdepmissing_t *needle, FPtrList *haystack) { - for(auto i = haystack->begin(), end = haystack->end(); i != end; i = i->next()) { + for(auto i = haystack->begin(), end = haystack->end(); i != end; ++i) { pmdepmissing_t *miss = (pmdepmissing_t *)*i; if(!memcmp(needle, miss, sizeof(pmdepmissing_t)) && !memcmp(&needle->depend, &miss->depend, sizeof(pmdepend_t))) { @@ -128,23 +128,23 @@ FPtrList _pacman_sortbydeps(const FPtrList &targets, int mode) _pacman_log(PM_LOG_DEBUG, _("started sorting dependencies")); /* We create the vertices */ - for(auto i = targets.begin(), end = targets.end(); i != end; i = i->next()) { + for(auto i = targets.begin(), end = targets.end(); i != end; ++i) { pmgraph_t *v = _pacman_graph_new(); v->data = *i; vertices.add(v); } /* We compute the edges */ - for(auto i = vertices.begin(), end = vertices.end(); i != end; i = i->next()) { + for(auto i = vertices.begin(), end = vertices.end(); i != end; ++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()) { + for(auto j = vertices.begin(); j != end; ++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()) { + for(auto k = depends.begin(), k_end = depends.end(); k != k_end && !child; ++k) { pmdepend_t depend; _pacman_splitdep((char *)*k, &depend); child = _pacman_depcmp(p_j, &depend); @@ -164,7 +164,7 @@ FPtrList _pacman_sortbydeps(const FPtrList &targets, int mode) found = 0; while(vertex->childptr != vertex->children.end() && !found) { pmgraph_t *nextchild = *vertex->childptr; - vertex->childptr = vertex->childptr->next(); + ++vertex->childptr; if (nextchild->state == 0) { found = 1; nextchild->parent = vertex; @@ -179,11 +179,11 @@ FPtrList _pacman_sortbydeps(const FPtrList &targets, int mode) vertex->state = 1; vertex = vertex->parent; if(!vertex) { - vptr = vptr->next(); + ++vptr; while(vptr != end) { vertex = *vptr; if (vertex->state == 0) break; - vptr = vptr->next(); + ++vptr; } } } @@ -217,7 +217,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p return baddeps; } - for(auto i = packages.begin(), end = packages.end(); i != end; i = i->next()) { + for(auto i = packages.begin(), end = packages.end(); i != end; ++i) { Package *tp = *i; Package *pkg_local; @@ -234,7 +234,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p if(pkg_local != NULL) { found = 0; auto &requiredby = pkg_local->requiredby(); - for(auto j = requiredby.begin(), j_end = requiredby.end(); j != j_end; j = j->next()) { + for(auto j = requiredby.begin(), j_end = requiredby.end(); j != j_end; ++j) { const char *requiredby_name = (const char *)*j; if(op == PM_TRANS_TYPE_UPGRADE) { @@ -252,7 +252,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p continue; } auto &depends = p->depends(); - for(auto k = depends.begin(), k_end = depends.end(); k != k_end; k = k->next()) { + for(auto k = depends.begin(), k_end = depends.end(); k != k_end; ++k) { const char *depend_name = (const char *)*k; /* don't break any existing dependencies (possible provides) */ @@ -269,14 +269,14 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p /* check requiredby fields */ 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()) { + for(auto k = trans->packages.begin(), k_end = trans->packages.end(); !found && k != k_end; ++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()) { + for(auto k = trans->syncpkgs.begin(), k_end = trans->syncpkgs.end(); !found && k != k_end; ++k) { pmsyncpkg_t *ps = *k; if(ps->pkg_new->provides(pkg_local->name())) { @@ -295,7 +295,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p if(op == PM_TRANS_TYPE_ADD || op == PM_TRANS_TYPE_UPGRADE) { /* DEPENDENCIES -- look for unsatisfied dependencies */ auto &depends = tp->depends(); - for(auto j = depends.begin(), j_end = depends.end(); j != j_end; j = j->next()) { + for(auto j = depends.begin(), j_end = depends.end(); j != j_end; ++j) { const char *depend_name = (const char *)*j; /* split into name/version pairs */ @@ -303,7 +303,7 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p found = 0; /* 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()) { + for(auto k = cache.begin(), k_end = cache.end(); k != k_end && !found; ++k) { Package *p = (Package *)*k; if(!strcmp(p->name(), depend.name)) { if(depend.mod == PM_DEP_MOD_ANY) { @@ -334,14 +334,14 @@ FPtrList _pacman_checkdeps(pmtrans_t *trans, unsigned char op, const FPtrList &p /* check database for provides matches */ if(!found) { auto whatPackagesProvide = db_local->whatPackagesProvide(depend.name); - for(auto m = whatPackagesProvide.begin(), m_end = whatPackagesProvide.end(); m != m_end && !found; m = m->next()) { + for(auto m = whatPackagesProvide.begin(), m_end = whatPackagesProvide.end(); m != m_end && !found; ++m) { /* look for a match that isn't one of the packages we're trying * 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 = *m; int skip = 0; - for(auto n = packages.begin(), n_end = packages.end(); n != n_end && !skip; n = n->next()) { + for(auto n = packages.begin(), n_end = packages.end(); n != n_end && !skip; ++n) { Package *ptp = *n; if(!strcmp(ptp->name(), p->name())) { skip = 1; @@ -377,7 +377,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()) { + for(auto k = packages.begin(), k_end = packages.end(); k != k_end && !found; ++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)) { @@ -481,10 +481,10 @@ FPtrList &_pacman_removedeps(Database *db, FPtrList &targs) } bool again = false; - for(auto i = targs.begin(), end = targs.end(); i != end; i = again ? targs.begin() : FPtrList::iterator(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 *)*i)->depends(); - for(auto j = depends.begin(), j_end = depends.end(); j != j_end; j = j->next()) { + for(auto j = depends.begin(), j_end = depends.end(); j != j_end; ++j) { pmdepend_t depend; Package *dep; int needed = 0; @@ -520,7 +520,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()) { + for(auto k = requiredby.begin(), k_end = requiredby.end(); k != k_end && !needed; ++k) { Package *dummy = db->find((const char *)*k); if(!_pacman_pkg_isin(dummy->name(), &targs)) { needed = 1; @@ -565,13 +565,13 @@ int _pacman_resolvedeps(pmtrans_t *trans, Package *syncpkg, FPtrList &list, return 0; } - for(auto i = deps.begin(), end = deps.end(); i != end; i = i->next()) { + for(auto i = deps.begin(), end = deps.end(); i != end; ++i) { int found = 0; 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()) { + for(auto j = list.begin(), j_end = list.end(); j != j_end && !found; ++j) { Package *sp = (Package *)*j; if(sp->provides(miss->depend.name)) { _pacman_log(PM_LOG_DEBUG, _("%s provides dependency %s -- skipping"), @@ -585,11 +585,11 @@ 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()) { + for(auto j = handle->dbs_sync.begin(), j_end = handle->dbs_sync.end(); !ps && j != j_end; ++j) { 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()) { + for(auto j = handle->dbs_sync.begin(), j_end = handle->dbs_sync.end(); !ps && j != j_end; ++j) { FPtrList provides = ((Database *)*j)->whatPackagesProvide(miss->depend.name); if(!provides.empty()) { ps = *provides.begin(); @@ -717,7 +717,7 @@ int inList(FPtrList *lst, char *lItem) { if(!strcmp(lItem, (const char *)*ll)) { return 1; } - ll = ll->next(); + ++ll; } return 0; } @@ -729,7 +729,7 @@ int pacman_output_generate(FStringList *targets, FPtrList *dblist) { char *match = NULL; int foundMatch = 0; unsigned int inforeq = INFRQ_DEPENDS; - for(auto j = dblist->begin(), end = dblist->end(); j != end; j = j->next()) { + for(auto j = dblist->begin(), end = dblist->end(); j != end; ++j) { Database *db = *j; do { foundMatch = 0; @@ -739,7 +739,7 @@ int pacman_output_generate(FStringList *targets, FPtrList *dblist) { if(_pacman_list_remove(targets, (void*) pname, str_cmp, (void **)&match)) { foundMatch = 1; auto &depends = pkg->depends(); - for(auto k = depends.begin(), k_end = depends.end(); k != k_end; k = k->next()) { + for(auto k = depends.begin(), k_end = depends.end(); k != k_end; ++k) { char *fullDep = *k; pmdepend_t depend; if(_pacman_splitdep(fullDep, &depend)) { diff --git a/lib/libpacman/handle.cpp b/lib/libpacman/handle.cpp index 5ff3207..b00e20b 100644 --- a/lib/libpacman/handle.cpp +++ b/lib/libpacman/handle.cpp @@ -167,7 +167,7 @@ Database *Handle::getDatabase(const char *treename) return db_local; } - for(auto i = dbs_sync.begin(), end = dbs_sync.end(); i != end; i = i->next()) { + for(auto i = dbs_sync.begin(), end = dbs_sync.end(); i != end; ++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 22bc65d..393b8ac 100644 --- a/lib/libpacman/kernel/fstr.cpp +++ b/lib/libpacman/kernel/fstr.cpp @@ -81,7 +81,7 @@ bool FStrMatcher::match(const char *str) const 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()) { + for(auto it = list->begin(), end = list->end(); it != end; ++it) { if(matcher->match((const char *)*it) != 0) { return 1; } diff --git a/lib/libpacman/package.cpp b/lib/libpacman/package.cpp index c877511..c2d03e7 100644 --- a/lib/libpacman/package.cpp +++ b/lib/libpacman/package.cpp @@ -152,7 +152,7 @@ Package *_pacman_pkg_isin(const char *needle, FPtrList *haystack) return(NULL); } - for(auto lp = haystack->begin(), end = haystack->end(); lp != end; lp = lp->next()) { + for(auto lp = haystack->begin(), end = haystack->end(); lp != end; ++lp) { Package *info = *lp; if(info && !strcmp(info->name(), needle)) { @@ -240,7 +240,7 @@ char *Package::fileneedbackup(const char *file) const ASSERT(!_pacman_strempty(file), RET_ERR(PM_ERR_WRONG_ARGS, NULL)); /* 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()) { + for(auto lp = m_backup.begin(), end = m_backup.end(); lp != end; ++lp) { char *str = strdup((const char *)*lp); char *ptr; diff --git a/lib/libpacman/package/packagecache.cpp b/lib/libpacman/package/packagecache.cpp index 52900bf..f81a3d6 100644 --- a/lib/libpacman/package/packagecache.cpp +++ b/lib/libpacman/package/packagecache.cpp @@ -57,7 +57,7 @@ int _pacman_packagecache_clean(int level) } closedir(dir); - for(auto i = cache.begin(), end = cache.end(); i != end; i = i->next()) { + for(auto i = cache.begin(), end = cache.end(); i != end; ++i) { const char *str = *i; char name[PKG_NAME_LEN], version[PKG_VERSION_LEN]; @@ -73,7 +73,7 @@ int _pacman_packagecache_clean(int level) clean.add(str); continue; } - for(FPtrList::iterator j = i->next(); j != end; j = j->next()) { + for(FPtrList::iterator j = i.next(); j != end; ++j) { const char *s = *j; char n[PKG_NAME_LEN], v[PKG_VERSION_LEN]; @@ -94,7 +94,7 @@ int _pacman_packagecache_clean(int level) } } } - for(auto i = clean.begin(), end = clean.end(); i != end; i = i->next()) { + for(auto i = clean.begin(), end = clean.end(); i != end; ++i) { char path[PATH_MAX]; snprintf(path, PATH_MAX, "%s/%s", dirpath, *i); diff --git a/lib/libpacman/packages_transaction.cpp b/lib/libpacman/packages_transaction.cpp index 10c6746..1c9bcb8 100644 --- a/lib/libpacman/packages_transaction.cpp +++ b/lib/libpacman/packages_transaction.cpp @@ -55,7 +55,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()) { + for(auto lp = trans->triggers.begin(), end = trans->triggers.end(); lp != end; ++lp) { const char *trigger = *lp; char buf[PATH_MAX]; diff --git a/lib/libpacman/server.cpp b/lib/libpacman/server.cpp index 2efaf5a..c0ace47 100644 --- a/lib/libpacman/server.cpp +++ b/lib/libpacman/server.cpp @@ -391,7 +391,7 @@ int _pacman_downloadfiles_forreal(Handle *handle, const FPtrList &servers, const } int count = 0; - for(auto i = servers.begin(), end = servers.end(); i != end && !done; i = i->next(), count++) { + for(auto i = servers.begin(), end = servers.end(); i != end && !done; ++i, count++) { pm_errno = 0; if (count < skip) continue; /* the caller requested skip of this server */ @@ -399,7 +399,7 @@ int _pacman_downloadfiles_forreal(Handle *handle, const FPtrList &servers, const _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()) { + for(auto lp = files.begin(), end = files.end(); lp != end; ++lp) { const char *fn = *lp; if(_pacman_list_is_strin(fn, &complete)) { diff --git a/lib/libpacman/trans.cpp b/lib/libpacman/trans.cpp index 5e91d7e..04292e3 100644 --- a/lib/libpacman/trans.cpp +++ b/lib/libpacman/trans.cpp @@ -121,12 +121,12 @@ static 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()) { + for(auto lp = trans->packages.begin(), end = trans->packages.end(); lp != end; ++lp) { Package *pkg = *lp; trans->triggers.add(pkg->triggers()); } - for(auto lp = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); lp != end; lp = lp->next()) { + for(auto lp = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); lp != end; ++lp) { Package *pkg = ((pmsyncpkg_t *)*lp)->pkg_new; /* FIXME: might be incomplete */ @@ -185,7 +185,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()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end ; ++i) { pmsyncpkg_t *ps = *i; if(ps && !strcmp(ps->pkg_name, pkgname)) { @@ -236,7 +236,7 @@ static int check_olddelay(Handle *handle) return(0); } - for(auto i = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); i != end; i = i->next()) { + for(auto i = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); i != end; ++i) { Database *db = *i; if(db->gettimestamp(&tm) == -1) { continue; @@ -312,7 +312,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) if(targ) { *targ = '\0'; targ++; - for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end && !spkg; i = i->next()) { + for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end && !spkg; ++i) { Database *dbs = *i; if(strcmp(dbs->treename(), targline) == 0) { spkg = dbs->find(targ); @@ -330,14 +330,14 @@ 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()) { + for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end && !spkg; ++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()) { + for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end && !spkg; ++i) { Database *dbs = *i; FPtrList p = dbs->whatPackagesProvide(targ); if(!p.empty()) { @@ -422,7 +422,7 @@ 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 */ FPtrList::iterator i, end; - for(i = packages.begin(), end = packages.end(); i != end; i = i->next()) { + for(i = packages.begin(), end = packages.end(); i != end; ++i) { Package *pkg = *i; if(strcmp(pkg->name(), pkg_new->name()) == 0) { pkg_queued = pkg; @@ -434,7 +434,7 @@ int __pmtrans_t::add(const char *target, pmtranstype_t type, int flags) if(_pacman_versioncmp(pkg_queued->version(), pkg_new->version()) < 0) { _pacman_log(PM_LOG_WARNING, _("replacing older version %s-%s by %s in target list"), pkg_queued->name(), pkg_queued->version(), pkg_new->version()); - i->swap_data((void **)&pkg_new); + i.m_iterable->swap_data((void **)&pkg_new); } else { _pacman_log(PM_LOG_WARNING, _("newer version %s-%s is in the target list -- skipping"), pkg_queued->name(), pkg_queued->version(), pkg_new->version()); @@ -498,7 +498,7 @@ int __pmtrans_t::prepare(FPtrList **data) _pacman_trans_compute_triggers(this); if(m_type == PM_TRANS_TYPE_SYNC) { - for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++i) { pmsyncpkg_t *ps = *i; list.add(ps->pkg_new); } @@ -509,7 +509,7 @@ int __pmtrans_t::prepare(FPtrList **data) /* Resolve targets dependencies */ 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()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++i) { Package *spkg = ((pmsyncpkg_t *)*i)->pkg_new; if(_pacman_resolvedeps(this, spkg, list, trail, data) == -1) { /* pm_errno is set by resolvedeps */ @@ -518,7 +518,7 @@ int __pmtrans_t::prepare(FPtrList **data) } } - for(auto i = list.begin(), end = list.end(); i != end; i = i->next()) { + for(auto i = list.begin(), end = list.end(); i != end; ++i) { /* add the dependencies found by resolvedeps to the transaction set */ Package *spkg = *i; if(!find(spkg->name())) { @@ -541,13 +541,13 @@ 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()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++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()) { + for(auto i = m.begin(), end = m.end(); i != end; ++i) { + for(auto j = syncpkgs.begin(), j_end = syncpkgs.end(); j != j_end; ++j) { pmsyncpkg_t *s = (pmsyncpkg_t*)*j; if(s->pkg_new == *i) { l.add(s); @@ -581,7 +581,7 @@ int __pmtrans_t::prepare(FPtrList **data) int errorout = 0; FStringList asked; - for(auto i = deps.begin(), end = deps.end(); i != end && !errorout; i = i->next()) { + for(auto i = deps.begin(), end = deps.end(); i != end && !errorout; ++i) { pmdepmissing_t *miss = *i; int found = 0; pmsyncpkg_t *ps; @@ -593,7 +593,7 @@ int __pmtrans_t::prepare(FPtrList **data) /* check if the conflicting package is one that's about to be removed/replaced. * if so, then just ignore it */ - for(auto j = syncpkgs.begin(), j_end = syncpkgs.end(); j != j_end && !found; j = j->next()) { + for(auto j = syncpkgs.begin(), j_end = syncpkgs.end(); j != j_end && !found; ++j) { ps = *j; if(_pacman_pkg_isin(miss->depend.name, &ps->m_replaces)) { found = 1; @@ -753,9 +753,9 @@ int __pmtrans_t::prepare(FPtrList **data) * package that's in our final (upgrade) list. */ /*EVENT(this, PM_TRANS_EVT_CHECKDEPS_DONE, NULL, NULL);*/ - for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++i) { pmsyncpkg_t *ps = *i; - for(auto j = ps->m_replaces.begin(), j_end = ps->m_replaces.end(); j != j_end; j = j->next()) { + for(auto j = ps->m_replaces.begin(), j_end = ps->m_replaces.end(); j != j_end; ++j) { list.add(*j); } } @@ -764,7 +764,7 @@ int __pmtrans_t::prepare(FPtrList **data) deps = _pacman_checkdeps(this, PM_TRANS_TYPE_REMOVE, list); if(!deps.empty()) { int errorout = 0; - for(auto i = deps.begin(), end = deps.end(); i != end; i = i->next()) { + for(auto i = deps.begin(), end = deps.end(); i != end; ++i) { pmdepmissing_t *miss = *i; if(!find(miss->depend.name)) { int pfound = 0; @@ -780,17 +780,17 @@ int __pmtrans_t::prepare(FPtrList **data) /* Look through the upset package's dependencies and try to match one up * to a provisio from the package we want to remove */ auto &depends = conflictp->depends(); - for(auto k = depends.begin(), k_end = depends.end(); k != k_end && !pfound; k = k->next()) { + for(auto k = depends.begin(), k_end = depends.end(); k != k_end && !pfound; ++k) { auto &provides = leavingp->provides(); - for(auto m = provides.begin(), m_end = provides.end(); m != m_end && !pfound; m = m->next()) { + for(auto m = provides.begin(), m_end = provides.end(); m != m_end && !pfound; ++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()) { + for(auto n = syncpkgs.begin(), n_end = syncpkgs.end(); n != n_end && !pfound; ++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()) { + for(auto o = provides.begin(), o_end = provides.end(); o != o_end && !pfound; ++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"), @@ -860,7 +860,7 @@ cleanup: if(!lp.empty()) { 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()) { + for(auto i = lp.begin(), end = lp.end(); i != end; ++i) { pmdepmissing_t *miss = (pmdepmissing_t *)*i; Package *pkg_local = db_local->scan(miss->depend.name, INFRQ_ALL); if(pkg_local) { @@ -926,11 +926,11 @@ cleanup: if(m_type & PM_TRANS_TYPE_ADD) { 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()) { + for (auto lp = packages.begin(), lp_end = packages.end(); lp != lp_end; ++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()) { + for (auto rmlist = removes.begin(), rmlist_end = removes.end(); rmlist != rmlist_end; ++rmlist) { char rm_fname[PATH_MAX]; snprintf(rm_fname, PATH_MAX, "%s%s", m_handle->root, (const char *)*rmlist); @@ -1101,7 +1101,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran * (it will be the new orginal) */ auto &backup = pkg->backup(); - for(auto lp = backup.begin(), lp_end = backup.end(); lp != lp_end; lp = lp->next()) { + for(auto lp = backup.begin(), lp_end = backup.end(); lp != lp_end; ++lp) { char *file = (const char *)*lp; if(!file) continue; @@ -1120,7 +1120,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran } sprintf(fn, "%s\t%s", file, sha1_pkg); } - lp->swap_data((void **)&fn); + lp.m_iterable->swap_data((void **)&fn); free(fn); } } @@ -1230,7 +1230,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran } /* calculate an md5 or sha1 hash if this is in pkg->backup */ auto &backup = pkg->backup(); - for(auto lp = backup.begin(), lp_end = backup.end(); lp != lp_end; lp = lp->next()) { + for(auto lp = backup.begin(), lp_end = backup.end(); lp != lp_end; ++lp) { char *fn, *md5, *sha1; char path[PATH_MAX]; char *file = (const char *)*lp; @@ -1256,7 +1256,7 @@ int _pacman_fpmpackage_install(Package *pkg, pmtranstype_t type, pmtrans_t *tran sprintf(fn, "%s\t%s", file, sha1); FREE(sha1); } - lp->swap_data((void **)fn); + lp.m_iterable->swap_data((void **)fn); free(fn); } } @@ -1413,11 +1413,11 @@ int __pmtrans_t::commit(FPtrList **data) retval = 0; FREELIST(*data); int done = 1; - for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end; i = i->next()) { + for(auto i = m_handle->dbs_sync.begin(), end = m_handle->dbs_sync.end(); i != end; ++i) { struct stat buf; Database *current = *i; - for(auto j = syncpkgs.begin(), j_end = syncpkgs.end(); j != j_end; j = j->next()) { + for(auto j = syncpkgs.begin(), j_end = syncpkgs.end(); j != j_end; ++j) { pmsyncpkg_t *ps = *j; Package *spkg = ps->pkg_new; Database *dbs = spkg->database(); @@ -1483,7 +1483,7 @@ int __pmtrans_t::commit(FPtrList **data) if(!(flags & PM_TRANS_FLAG_NOINTEGRITY)) { EVENT(this, PM_TRANS_EVT_INTEGRITY_START, NULL, NULL); - for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++i) { pmsyncpkg_t *ps = *i; retval = _pacman_cachedpkg_check_integrity(ps->pkg_new, this, data); @@ -1521,9 +1521,9 @@ int __pmtrans_t::commit(FPtrList **data) tr->event.connect(&event); tr->conv.connect(&conv); tr->progress.connect(&progress); - for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++i) { pmsyncpkg_t *ps = *i; - for(auto j = ps->m_replaces.begin(), end = ps->m_replaces.end(); j != end; j = j->next()) { + for(auto j = ps->m_replaces.begin(), end = ps->m_replaces.end(); j != end; ++j) { Package *pkg = *j; if(!_pacman_pkg_isin(pkg->name(), &tr->packages)) { if(tr->add(pkg->name(), tr->m_type, tr->flags) == -1) { @@ -1558,7 +1558,7 @@ int __pmtrans_t::commit(FPtrList **data) tr->event.connect(&event); tr->conv.connect(&conv); tr->progress.connect(&progress); - for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; i = i->next()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++i) { pmsyncpkg_t *ps = *i; Package *spkg = ps->pkg_new; char str[PATH_MAX]; @@ -1590,15 +1590,15 @@ int __pmtrans_t::commit(FPtrList **data) /* propagate replaced packages' requiredby fields to their new owners */ 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()) { + for(auto i = syncpkgs.begin(), end = syncpkgs.end(); i != end; ++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()) { + for(auto j = ps->m_replaces.begin(), end = ps->m_replaces.end(); j != end; ++j) { Package *old = *j; /* merge lists */ auto &requiredby = old->requiredby(); - for(auto k = requiredby.begin(), end = requiredby.end(); k != end; k = k->next()) { + for(auto k = requiredby.begin(), end = requiredby.end(); k != end; ++k) { 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((const char *)*k); @@ -1610,10 +1610,10 @@ int __pmtrans_t::commit(FPtrList **data) continue; } auto &depends = depender->depends(); - for(auto m = depends.begin(), end = depends.end(); m != end; m = m->next()) { + for(auto m = depends.begin(), end = depends.end(); m != end; ++m) { if(!strcmp((const char *)*m, old->name())) { void *str = strdup(pkg_new->name()); - m->swap_data(&str); + m.m_iterable->swap_data(&str); free(str); } } @@ -1642,7 +1642,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()) { + for(auto i = files.begin(), end = files.end(); i != end; ++i) { unlink((const char *)*i); } } @@ -1652,7 +1652,7 @@ int __pmtrans_t::commit(FPtrList **data) howmany = f_ptrlist_count(&packages); - for(auto targ = packages.begin(), end = packages.end(); targ != end; targ = targ->next()) { + for(auto targ = packages.begin(), end = packages.end(); targ != end; ++targ) { Package *pkg_new = NULL, *pkg_local = NULL; void *event_arg0 = NULL, *event_arg1 = NULL; pmtranstype_t type = m_type; @@ -1751,7 +1751,7 @@ int __pmtrans_t::commit(FPtrList **data) /* update dependency packages' REQUIREDBY fields */ _pacman_log(PM_LOG_FLOW2, _("updating dependency packages 'requiredby' fields")); auto &depends = pkg_local->depends(); - for(auto lp = depends.begin(), lp_end = depends.end(); lp != lp_end; lp = lp->next()) { + for(auto lp = depends.begin(), lp_end = depends.end(); lp != lp_end; ++lp) { Package *depinfo = NULL; pmdepend_t depend; char *data; @@ -1813,13 +1813,13 @@ int __pmtrans_t::commit(FPtrList **data) /* Update the requiredby field by scanning the whole database * 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()) { + for(auto lp = cache.begin(), lp_end = cache.end(); lp != lp_end; ++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()) { + for(auto tmppm = depends.begin(), end = depends.end(); tmppm != end; ++tmppm) { pmdepend_t depend; if(_pacman_splitdep(*tmppm, &depend)) { continue; @@ -1852,7 +1852,7 @@ int __pmtrans_t::commit(FPtrList **data) if(!depends.empty()) { _pacman_log(PM_LOG_FLOW2, _("updating dependency packages 'requiredby' fields")); } - for(auto lp = depends.begin(), lp_end = depends.end(); lp != lp_end; lp = lp->next()) { + for(auto lp = depends.begin(), lp_end = depends.end(); lp != lp_end; ++lp) { Package *depinfo; pmdepend_t depend; if(_pacman_splitdep((const char *)*lp, &depend)) { diff --git a/lib/libpacman/trans_sysupgrade.cpp b/lib/libpacman/trans_sysupgrade.cpp index 3397ead..f6bfb86 100644 --- a/lib/libpacman/trans_sysupgrade.cpp +++ b/lib/libpacman/trans_sysupgrade.cpp @@ -82,14 +82,14 @@ 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()) { + for(auto i = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); i != end; ++i) { FPtrList &cache = _pacman_db_get_pkgcache(*i); - for(auto j = cache.begin(), end = cache.end(); j != end; j = j->next()) { + for(auto j = cache.begin(), end = cache.end(); j != end; ++j) { Package *spkg = *j; auto &replaces = spkg->replaces(); - for(auto k = replaces.begin(), end = replaces.end(); k != end; k = k->next()) { + for(auto k = replaces.begin(), end = replaces.end(); k != end; ++k) { FPtrList &cache_local = _pacman_db_get_pkgcache(db_local); - for(auto m = cache_local.begin(), end = cache_local.end(); m != end; m = m->next()) { + for(auto m = cache_local.begin(), end = cache_local.end(); m != end; ++m) { 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()); @@ -133,14 +133,14 @@ int _pacman_trans_sysupgrade(pmtrans_t *trans) /* match installed packages with the sync dbs and compare versions */ _pacman_log(PM_LOG_FLOW1, _("checking for package upgrades")); FPtrList &cache_local = _pacman_db_get_pkgcache(db_local); - for(auto i = cache_local.begin(), end= cache_local.end(); i != end; i = i->next()) { + for(auto i = cache_local.begin(), end= cache_local.end(); i != end; ++i) { int cmp; int replace=0; 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()) { + for(auto j = handle->dbs_sync.begin(), end = handle->dbs_sync.end(); !spkg && j != end; ++j) { spkg = ((Database *)*j)->find(local->name()); } if(spkg == NULL) { @@ -149,7 +149,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()) { + for(auto j = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); j != end && !replace; ++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 fbd300f..a7e2885 100644 --- a/lib/libpacman/util.cpp +++ b/lib/libpacman/util.cpp @@ -127,7 +127,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()) { + for (auto i = haystack->begin(), end = haystack->end(); i != end; ++i) { cache_t *c = *i; if (!strncmp(c->str, needle, strlen(c->str))) { c->hit = 1; @@ -197,7 +197,7 @@ int _pacman_unpack(const char *archive, const char *prefix, const char *fn) archive_read_finish (_archive); /* finally delete the old ones */ - for (auto i = cache.begin(), end = cache.end(); i != end; i = i->next()) { + for (auto i = cache.begin(), end = cache.end(); i != end; ++i) { cache_t *c = *i; if (!c->hit) { snprintf(expath, PATH_MAX, "%s/%s", prefix, c->str); @@ -481,11 +481,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()) { + for(auto i = trans->packages.begin(), end = trans->packages.end(); i != end; ++i) { Package *pkg = *i; pkgsize += pkg->size; } - for(auto i = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); i != end; i = i->next()) { + for(auto i = trans->syncpkgs.begin(), end = trans->syncpkgs.end(); i != end; ++i) { pmsyncpkg_t *ps = *i; if(ps->type != PM_SYNC_TYPE_REPLACE) { diff --git a/lib/libpacman/util/fptrlist.cpp b/lib/libpacman/util/fptrlist.cpp index 2e10f32..2d5e9dc 100644 --- a/lib/libpacman/util/fptrlist.cpp +++ b/lib/libpacman/util/fptrlist.cpp @@ -72,7 +72,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()) { + for(auto it = list->rbegin(), end = list->rend(); it != end; --it /* FIXME: should be ++it when operators are really working */) { newlist->add(*it); } @@ -129,12 +129,12 @@ bool FPtrList::remove(void *ptr, _pacman_fn_cmp fn, void **data) *data = NULL; } - for(auto i = begin(), end = this->end(); i != end; i = i->next()) { - if(fn(ptr, i->m_data) == 0) { + for(auto i = begin(), end = this->end(); i != end; ++i) { + if(fn(ptr, *i) == 0) { /* we found a matching item */ - i->remove(); + i.m_iterable->remove(); if(data) { - *data = i->m_data; + *data = *i; } delete i.m_iterable; return true; diff --git a/lib/libpacman/util/fptrlist.h b/lib/libpacman/util/fptrlist.h index da0d479..082090c 100644 --- a/lib/libpacman/util/fptrlist.h +++ b/lib/libpacman/util/fptrlist.h @@ -97,11 +97,6 @@ public: return !operator == (o); } - iterable operator -> () const - { - return m_iterable; - } - void *operator * () const { return m_iterable->m_data; @@ -112,6 +107,19 @@ public: return m_iterable; } + iterator &operator ++ () + { + m_iterable = m_iterable->next(); + return *this; + } + + iterator &operator -- () + { + m_iterable = m_iterable->previous(); + return *this; + } + + iterator next() const { return m_iterable->next(); diff --git a/lib/libpacman/util/fstringlist.cpp b/lib/libpacman/util/fstringlist.cpp index be05baf..815211d 100644 --- a/lib/libpacman/util/fstringlist.cpp +++ b/lib/libpacman/util/fstringlist.cpp @@ -34,7 +34,7 @@ */ int _pacman_list_is_strin(const char *needle, FStringList *haystack) { - for(auto lp = haystack->begin(), end = haystack->end(); lp != end; lp = lp->next()) { + for(auto lp = haystack->begin(), end = haystack->end(); lp != end; ++lp) { const char *str = *lp; if(str && !strcmp(str, needle)) { @@ -54,7 +54,7 @@ FStringList *_pacman_list_remove_dupes(FStringList *list) { FStringList *newlist = NULL; - for(auto i = list->begin(), end = list->end(); i != end; i = i->next()) { + for(auto i = list->begin(), end = list->end(); i != end; ++i) { const char *str = *i; if(!_pacman_list_is_strin(str, newlist)) { @@ -138,7 +138,7 @@ FStringList::FStringList(FStringList &&o) FStringList &FStringList::operator = (const FStringList &o) { - for(auto lp = o.begin(), end = o.end(); lp != end; lp = lp->next()) { + for(auto lp = o.begin(), end = o.end(); lp != end; ++lp) { f_stringlist_add(this, *lp); } @@ -159,7 +159,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()) { + for(auto lp = o.begin(), end = o.end(); lp != end; ++lp) { add((const char *)*lp); } return *this; _______________________________________________ Frugalware-git mailing list [email protected] http://frugalware.org/mailman/listinfo/frugalware-git
