{
LongNV *nv;
unsigned int len;
- if (entry >= s->entries)
- return;
+ ensure_entry (s, entry);
if (attr.key >= s->nkeys)
return;
nv = s->attrs[entry];
/* This routine is used only when attributes are embedded into the
normal repo SOLV file. */
void
-add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, FILE *fp)
+add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, unsigned maxid, FILE *fp)
{
- //Pool *pool = s->pool;
+ Pool *pool = s->pool;
//fprintf (stderr, "%s: attribute in a repo SOLV?\n", id2str (pool, name));
switch (type)
{
case TYPE_ATTR_LOCALIDS:
{
Id i;
- while ((i = read_id(fp, 0)) != 0)
- add_attr_localids_id (s, entry, name, i);
+ /* The read ID will be pool-based. */
+ while ((i = read_id(fp, maxid)) != 0)
+ {
+ if (idmap)
+ i = idmap[i];
+ add_attr_localids_id (s, entry, name, str2localid (s, id2str (pool, i), 1));
+ }
}
break;
default:
s->ent2attr[i] += start, start = s->ent2attr[i];
}
- if (fwrite (s->flat_attrs, s->attr_next_free, 1, fp) != 1)
+ if (fwrite (s->flat_attrs + 1, s->attr_next_free - 1, 1, fp) != 1)
{
perror ("write error");
exit (1);
s->attr_next_free = start;
s->flat_attrs = xmalloc (((s->attr_next_free + FLAT_ATTR_BLOCK) & ~FLAT_ATTR_BLOCK) * sizeof (s->flat_attrs[0]));
- if (fread (s->flat_attrs, s->attr_next_free, 1, fp) != 1)
+ s->flat_attrs[0] = 0;
+ if (fread (s->flat_attrs + 1, s->attr_next_free - 1, 1, fp) != 1)
{
perror ("read error");
exit (1);