Author: mlschroe Date: Fri Dec 21 15:42:40 2007 New Revision: 8135 URL: http://svn.opensuse.org/viewcvs/zypp?rev=8135&view=rev Log: - fix bug in repo_addid_dep - make repo_addid_dep handle different markers, so that we can add the file provides with SOLVABLE_FILEMARKER Modified: trunk/sat-solver/src/repo.c trunk/sat-solver/src/repo.h trunk/sat-solver/tools/repo_content.c trunk/sat-solver/tools/repo_helix.c trunk/sat-solver/tools/repo_patchxml.c trunk/sat-solver/tools/repo_rpmmd.c trunk/sat-solver/tools/repo_susetags.c Modified: trunk/sat-solver/src/repo.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.c?rev=8135&r1=8134&r2=8135&view=diff ============================================================================== --- trunk/sat-solver/src/repo.c (original) +++ trunk/sat-solver/src/repo.c Fri Dec 21 15:42:40 2007 @@ -118,23 +118,27 @@ /* - * add dependency (as Id) to repo + * add dependency (as Id) to repo, also unifies dependencies * olddeps = offset into idarraydata - * isreq = 0 for normal dep - * isreq = 1 for requires - * isreq = 2 for pre-requires + * marker= 0 for normal dep + * marker > 0 add dep after marker + * marker < 0 add dep after -marker * */ - Offset -repo_addid_dep(Repo *repo, Offset olddeps, Id id, int isreq) +repo_addid_dep(Repo *repo, Offset olddeps, Id id, Id marker) { - Id oid, *oidp, *marker = 0; + Id oid, *oidp, *markerp; + int before; if (!olddeps) - return repo_addid(repo, olddeps, id); + { + if (marker > 0) + olddeps = repo_addid(repo, olddeps, marker); + return repo_addid(repo, olddeps, id); + } - if (!isreq) + if (!marker) { for (oidp = repo->idarraydata + olddeps; (oid = *oidp) != ID_NULL; oidp++) { @@ -144,45 +148,55 @@ return repo_addid(repo, olddeps, id); } + before = 0; + markerp = 0; + if (marker < 0) + { + before = 1; + marker = -marker; + } for (oidp = repo->idarraydata + olddeps; (oid = *oidp) != ID_NULL; oidp++) { - if (oid == SOLVABLE_PREREQMARKER) - marker = oidp; + if (oid == marker) + markerp = oidp; else if (oid == id) break; } if (oid) { - if (marker || isreq == 1) + if (markerp || before) return olddeps; - marker = oidp++; + /* we found it, but in the wrong half */ + markerp = oidp++; for (; (oid = *oidp) != ID_NULL; oidp++) - if (oid == SOLVABLE_PREREQMARKER) + if (oid == marker) break; if (!oid) { + /* no marker in array yet */ oidp--; - if (marker < oidp) - memmove(marker, marker + 1, (oidp - marker) * sizeof(Id)); - *oidp = SOLVABLE_PREREQMARKER; + if (markerp < oidp) + memmove(markerp, markerp + 1, (oidp - markerp) * sizeof(Id)); + *oidp = marker; return repo_addid(repo, olddeps, id); } while (oidp[1]) oidp++; - memmove(marker, marker + 1, (oidp - marker) * sizeof(Id)); + memmove(markerp, markerp + 1, (oidp - markerp) * sizeof(Id)); *oidp = id; return olddeps; } - if (isreq == 2 && !marker) - olddeps = repo_addid(repo, olddeps, SOLVABLE_PREREQMARKER); - else if (isreq == 1 && marker) + /* id not yet in array */ + if (!before && !markerp) + olddeps = repo_addid(repo, olddeps, marker); + else if (before && markerp) { - *marker++ = id; + *markerp++ = id; id = *--oidp; - if (marker < oidp) - memmove(marker + 1, marker, (oidp - marker) * sizeof(Id)); - *marker = SOLVABLE_PREREQMARKER; + if (markerp < oidp) + memmove(markerp + 1, markerp, (oidp - markerp) * sizeof(Id)); + *markerp = marker; } return repo_addid(repo, olddeps, id); } Modified: trunk/sat-solver/src/repo.h URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/repo.h?rev=8135&r1=8134&r2=8135&view=diff ============================================================================== --- trunk/sat-solver/src/repo.h (original) +++ trunk/sat-solver/src/repo.h Fri Dec 21 15:42:40 2007 @@ -108,7 +108,7 @@ extern void repo_freeallrepos(Pool *pool, int reuseids); extern Offset repo_addid(Repo *repo, Offset olddeps, Id id); -extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, int isreq); +extern Offset repo_addid_dep(Repo *repo, Offset olddeps, Id id, Id marker); extern Offset repo_reserve_ids(Repo *repo, Offset olddeps, int num); extern Offset repo_fix_legacy(Repo *repo, Offset provides, Offset supplements); Modified: trunk/sat-solver/tools/repo_content.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_content.c?rev=8135&r1=8134&r2=8135&view=diff ============================================================================== --- trunk/sat-solver/tools/repo_content.c (original) +++ trunk/sat-solver/tools/repo_content.c Fri Dec 21 15:42:40 2007 @@ -104,7 +104,7 @@ } static unsigned int -adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, int isreq) +adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker) { int flags, words; Id id, evrid; @@ -152,7 +152,7 @@ if (words == 3) line = sp[2], words = 2; } - olddeps = repo_addid_dep(pd->repo, olddeps, id, isreq); + olddeps = repo_addid_dep(pd->repo, olddeps, id, marker); if (!line) break; } @@ -235,9 +235,9 @@ arch. We don't know the latter here, though. */ s->arch = ARCH_NOARCH; else if (istag ("PREREQUIRES")) - s->requires = adddep(pool, &pd, s->requires, value, 2); + s->requires = adddep(pool, &pd, s->requires, value, SOLVABLE_PREREQMARKER); else if (istag ("REQUIRES")) - s->requires = adddep(pool, &pd, s->requires, value, 1); + s->requires = adddep(pool, &pd, s->requires, value, -SOLVABLE_PREREQMARKER); else if (istag ("PROVIDES")) s->provides = adddep(pool, &pd, s->provides, value, 0); else if (istag ("CONFLICTS")) Modified: trunk/sat-solver/tools/repo_helix.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_helix.c?rev=8135&r1=8134&r2=8135&view=diff ============================================================================== --- trunk/sat-solver/tools/repo_helix.c (original) +++ trunk/sat-solver/tools/repo_helix.c Fri Dec 21 15:42:40 2007 @@ -296,11 +296,12 @@ static unsigned int adddep(Pool *pool, Parsedata *pd, unsigned int olddeps, const char **atts, int isreq) { - Id id, name; + Id id, name, marker; const char *n, *f, *k; const char **a; n = f = k = NULL; + marker = isreq ? -SOLVABLE_PREREQMARKER : 0; /* loop over name,value pairs */ for (a = atts; *a; a += 2) @@ -312,7 +313,7 @@ else if (!strcmp(*a, "op")) f = a[1]; else if (isreq && !strcmp(*a, "pre") && a[1][0] == '1') - isreq = 2; + marker = SOLVABLE_PREREQMARKER; } if (!n) /* quit if no name found */ return olddeps; @@ -332,9 +333,10 @@ sprintf(pd->content, "%s:%s", k, n); name = str2id(pool, pd->content, 1); } - else { + else + { name = str2id(pool, n, 1); /* package: just intern <name> */ - } + } if (f) /* operator ? */ { @@ -357,7 +359,7 @@ id = name; /* no operator */ /* add new dependency to repo */ - return repo_addid_dep(pd->repo, olddeps, id, isreq); + return repo_addid_dep(pd->repo, olddeps, id, marker); } Modified: trunk/sat-solver/tools/repo_patchxml.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_patchxml.c?rev=8135&r1=8134&r2=8135&view=diff ============================================================================== --- trunk/sat-solver/tools/repo_patchxml.c (original) +++ trunk/sat-solver/tools/repo_patchxml.c Fri Dec 21 15:42:40 2007 @@ -184,11 +184,12 @@ static unsigned int adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts, int isreq) { - Id id, name; + Id id, name, marker; const char *n, *f, *k; const char **a; n = f = k = 0; + marker = isreq ? -SOLVABLE_PREREQMARKER : 0; for (a = atts; *a; a += 2) { if (!strcmp(*a, "name")) @@ -198,7 +199,7 @@ else if (!strcmp(*a, "kind")) k = a[1]; else if (isreq && !strcmp(*a, "pre") && a[1][0] == '1') - isreq = 2; + marker = SOLVABLE_PREREQMARKER; } if (!n) return olddeps; @@ -232,7 +233,7 @@ #if 0 fprintf(stderr, "new dep %s%s%s\n", id2str(pool, d), id2rel(pool, d), id2evr(pool, d)); #endif - return repo_addid_dep(pd->repo, olddeps, id, isreq); + return repo_addid_dep(pd->repo, olddeps, id, marker); } Modified: trunk/sat-solver/tools/repo_rpmmd.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_rpmmd.c?rev=8135&r1=8134&r2=8135&view=diff ============================================================================== --- trunk/sat-solver/tools/repo_rpmmd.c (original) +++ trunk/sat-solver/tools/repo_rpmmd.c Fri Dec 21 15:42:40 2007 @@ -181,11 +181,12 @@ static unsigned int adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts, int isreq) { - Id id, name; + Id id, name, marker; const char *n, *f, *k; const char **a; n = f = k = 0; + marker = isreq ? -SOLVABLE_PREREQMARKER : 0; for (a = atts; *a; a += 2) { if (!strcmp(*a, "name")) @@ -195,7 +196,7 @@ else if (!strcmp(*a, "kind")) k = a[1]; else if (isreq && !strcmp(*a, "pre") && a[1][0] == '1') - isreq = 2; + marker = SOLVABLE_PREREQMARKER; } if (!n) return olddeps; @@ -229,7 +230,7 @@ #if 0 fprintf(stderr, "new dep %s%s%s\n", id2str(pool, d), id2rel(pool, d), id2evr(pool, d)); #endif - return repo_addid_dep(pd->repo, olddeps, id, isreq); + return repo_addid_dep(pd->repo, olddeps, id, marker); } Modified: trunk/sat-solver/tools/repo_susetags.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/tools/repo_susetags.c?rev=8135&r1=8134&r2=8135&view=diff ============================================================================== --- trunk/sat-solver/tools/repo_susetags.c (original) +++ trunk/sat-solver/tools/repo_susetags.c Fri Dec 21 15:42:40 2007 @@ -106,7 +106,7 @@ } static unsigned int -adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, int isreq, char *kind) +adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, char *line, Id marker, char *kind) { int i, flags; Id id, evrid; @@ -135,7 +135,7 @@ } id = rel2id(pool, id, evrid, flags + 1, 1); } - return repo_addid_dep(pd->repo, olddeps, id, isreq); + return repo_addid_dep(pd->repo, olddeps, id, marker); } Attrstore *attr; @@ -512,13 +512,13 @@ s->provides = adddep(pool, &pd, s->provides, line, 0, pd.kind); continue; case CTAG('=', 'R', 'e', 'q'): - s->requires = adddep(pool, &pd, s->requires, line, 1, pd.kind); + s->requires = adddep(pool, &pd, s->requires, line, -SOLVABLE_PREREQMARKER, pd.kind); continue; case CTAG('=', 'P', 'r', 'q'): if (pd.kind) s->requires = adddep(pool, &pd, s->requires, line, 0, 0); else - s->requires = adddep(pool, &pd, s->requires, line, 2, 0); + s->requires = adddep(pool, &pd, s->requires, line, SOLVABLE_PREREQMARKER, 0); continue; case CTAG('=', 'O', 'b', 's'): s->obsoletes = adddep(pool, &pd, s->obsoletes, line, 0, pd.kind); -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org