From: Michael Matz Date: Thu, 27 Dec 2007 21:39:00 +0000 (+0000) Subject: Enable ATTR_INTLIST to contain zeros. Use the same encoding as IDARRAY. X-Git-Tag: BASE-SuSE-Code-12_1-Branch~1041 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f3f136ef95c196ce257940fd04a7ea74ba1ad5f1;p=platform%2Fupstream%2Flibsolv.git Enable ATTR_INTLIST to contain zeros. Use the same encoding as IDARRAY. --- diff --git a/src/attr_store.c b/src/attr_store.c index a96523c..1870532 100644 --- a/src/attr_store.c +++ b/src/attr_store.c @@ -369,24 +369,19 @@ void add_attr_intlist_int (Attrstore *s, unsigned int entry, Id name, int val) { LongNV *nv = find_attr (s, entry, name); - if (val == 0) - return; if (nv) { - unsigned len = 0; - while (nv->v.intlist[len]) - len++; + unsigned len = nv->v.intlist[0]++; nv->v.intlist = realloc (nv->v.intlist, (len + 2) * sizeof (nv->v.intlist[0])); - nv->v.intlist[len] = val; - nv->v.intlist[len+1] = 0; + nv->v.intlist[len+1] = val; } else { LongNV mynv; mynv.key = add_key (s, name, TYPE_ATTR_INTLIST, 0); mynv.v.intlist = malloc (2 * sizeof (mynv.v.intlist[0])); - mynv.v.intlist[0] = val; - mynv.v.intlist[1] = 0; + mynv.v.intlist[0] = 1; + mynv.v.intlist[1] = val; add_attr (s, entry, mynv); } } @@ -437,9 +432,9 @@ merge_attrs (Attrstore *s, unsigned dest, unsigned src) { case TYPE_ATTR_INTLIST: { - unsigned len = 0; - while (nv->v.intlist[len]) - add_attr_intlist_int (s, dest, s->keys[nv->key].name, nv->v.intlist[len++]); + unsigned i, len = nv->v.intlist[0]; + for (i = 0; i < len; i++) + add_attr_intlist_int (s, dest, s->keys[nv->key].name, nv->v.intlist[i + 1]); } break; case TYPE_ATTR_LOCALIDS: @@ -523,10 +518,11 @@ add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, } break; case TYPE_ATTR_INTLIST: - { - unsigned i; - while ((i = read_id(fp, 0)) != 0) - add_attr_intlist_int (s, entry, name, i); + { + int i; + while ((i = read_id(fp, 0)) & 64) + add_attr_intlist_int (s, entry, name, (i & 63) | ((i >> 1) & ~63)); + add_attr_intlist_int (s, entry, name, (i & 63) | ((i >> 1) & ~63)); } break; case TYPE_ATTR_LOCALIDS: @@ -881,11 +877,18 @@ attr_store_pack (Attrstore *s) case TYPE_ATTR_INTLIST: { const int *il = nv[ofs].v.intlist; - int i; - for (; (i = *il) != 0; il++, old_mem += 4) - add_num (s->flat_attrs, s->attr_next_free, i, FLAT_ATTR_BLOCK); - add_num (s->flat_attrs, s->attr_next_free, 0, FLAT_ATTR_BLOCK); - old_mem+=4; + int len = *il++; + //add_num (s->flat_attrs, s->attr_next_free, len, FLAT_ATTR_BLOCK); + old_mem += 4 * (len + 1); + while (len--) + { + int i = *il++; + if (i >= 64) + i = (i & 63) | ((i & ~63) << 1); + if (len) + i |= 64; + add_num (s->flat_attrs, s->attr_next_free, i, FLAT_ATTR_BLOCK); + } xfree (nv[ofs].v.intlist); break; } @@ -974,9 +977,9 @@ attr_store_unpack (Attrstore *s) { int val; get_num (ai.as_numlist, val); - if (!val) + add_attr_intlist_int (s, i, ai.name, (val & 63) | ((val >> 1) & ~63)); + if (!(val & 64)) break; - add_attr_intlist_int (s, i, ai.name, val); } break; } diff --git a/src/attr_store_p.h b/src/attr_store_p.h index e840333..981d383 100644 --- a/src/attr_store_p.h +++ b/src/attr_store_p.h @@ -179,12 +179,12 @@ ai_step (Attrstore *s, attr_iterator *ai) } case TYPE_ATTR_INTLIST: { - ai->as_numlist = ai->attrs_next; + ai->as_numlist = ai->attrs_next; while (1) { int val; get_num (ai->attrs_next, val); - if (!val) + if (!(val & 64)) break; } break; diff --git a/src/repo_solv.c b/src/repo_solv.c index e494c0a..0371320 100644 --- a/src/repo_solv.c +++ b/src/repo_solv.c @@ -269,6 +269,7 @@ skip_item (Repodata *data, unsigned type, unsigned numid, unsigned numrel) case TYPE_IDVALUEARRAY: case TYPE_IDVALUEVALUEARRAY: case TYPE_REL_IDARRAY: + case TYPE_ATTR_INTLIST: while ((read_u8(data) & 0xc0) != 0) ; break; @@ -297,7 +298,6 @@ skip_item (Repodata *data, unsigned type, unsigned numid, unsigned numrel) case TYPE_ATTR_INT: read_id(data, 0); break; - case TYPE_ATTR_INTLIST: case TYPE_ATTR_LOCALIDS: while (read_id(data, 0) != 0) ; diff --git a/tools/dumpattr.c b/tools/dumpattr.c index 5930f1c..3fb8d4f 100644 --- a/tools/dumpattr.c +++ b/tools/dumpattr.c @@ -49,9 +49,9 @@ dump_attrs (Attrstore *s, unsigned int entry) { int val; get_num (ai.as_numlist, val); - if (!val) + fprintf (stdout, " %d", (val & 63) | ((val >> 1) & ~63)); + if (!(val & 64)) break; - fprintf (stdout, " %d", val); } fprintf (stdout, "\n"); break; diff --git a/tools/dumpsolv.c b/tools/dumpsolv.c index f130227..06083d9 100644 --- a/tools/dumpsolv.c +++ b/tools/dumpsolv.c @@ -46,9 +46,9 @@ dump_attrs_1 (Attrstore *s, unsigned int entry) { int val; get_num (ai.as_numlist, val); - if (!val) + fprintf (stdout, " %d", (val & 63) | ((val >> 1) & ~63)); + if (!(val & 64)) break; - fprintf (stdout, " %d", val); } fprintf (stdout, "\n"); break;