void
add_attr_special_int (Attrstore *s, unsigned int entry, Id name, unsigned int val)
{
- if (val > (TYPE_ATTR_SPECIAL_END - TYPE_ATTR_SPECIAL_START))
- add_attr_int (s, entry, name, val);
- else
- {
- LongNV nv;
- nv.key = add_key (s, name, TYPE_ATTR_SPECIAL_START + val, 0);
- add_attr (s, entry, nv);
- }
+ LongNV nv;
+ nv.key = add_key (s, name, TYPE_VOID, val);
+ add_attr (s, entry, nv);
}
static void
/* 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, Id *idmap, unsigned maxid, FILE *fp)
+add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, unsigned maxid, FILE *fp, unsigned size)
{
Pool *pool = s->pool;
//fprintf (stderr, "%s: attribute in a repo SOLV?\n", id2str (pool, name));
switch (type)
{
case TYPE_VOID:
- add_attr_void (s, entry, name);
+ if (size)
+ add_attr_special_int (s, entry, name, size);
+ else
+ add_attr_void (s, entry, name);
break;
case TYPE_ATTR_CHUNK:
{
}
break;
default:
- if (type >= TYPE_ATTR_SPECIAL_START && type <= TYPE_ATTR_SPECIAL_END)
- {
- add_attr_special_int (s, entry, name, type - TYPE_ATTR_SPECIAL_START);
- break;
- }
pool_debug(pool, SAT_FATAL, "unknown type %d\n", type);
exit(0);
}
{
unsigned i;
for (i = 0; i < s->nkeys; i++)
- if (s->keys[i].name == name && s->keys[i].type == type)
+ if (s->keys[i].name == name && s->keys[i].type == type
+ && (type != TYPE_VOID || s->keys[i].size == size))
break;
if (i < s->nkeys)
{
- s->keys[i].size += size;
+ if (type != TYPE_VOID)
+ s->keys[i].size += size;
return i;
}
if ((s->nkeys & KEY_BLOCK) == 0)
switch (ai.type)
{
case TYPE_VOID:
- add_attr_void (s, i, ai.name);
+ if (ai.as_int)
+ add_attr_special_int (s, i, ai.name, ai.as_int);
+ else
+ add_attr_void (s, i, ai.name);
break;
case TYPE_ATTR_INT:
add_attr_int (s, i, ai.name, ai.as_int);
break;
}
default:
- if (ai.type >= TYPE_ATTR_SPECIAL_START
- && ai.type <= TYPE_ATTR_SPECIAL_END)
- add_attr_special_int (s, i, ai.name, ai.type - TYPE_ATTR_SPECIAL_START);
break;
}
}
unsigned int packed:1;
};
-void add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, unsigned maxid, FILE *fp);
+void add_attr_from_file (Attrstore *s, unsigned entry, Id name, int type, Id *idmap, unsigned maxid, FILE *fp, unsigned size);
void read_or_setup_pages (FILE *fp, Attrstore *s);
#define get_num(ptr,val) do { \
switch (ai->type)
{
case TYPE_VOID:
- /* No data. */
+ /* No data, except perhaps a constant value. */
+ ai->as_int = s->keys[key].size;
break;
case TYPE_ATTR_INT:
{
break;
}
default:
- /* ??? Convert TYPE_ATTR_SPECIAL_* to _INT type with the right value? */
break;
}
return 1;
#define SAT_DEBUG_JOB (1<<11)
#define SAT_DEBUG_SCHUBI (1<<12)
+/* The void type is usable to encode one-valued attributes, they have
+ no associated data. This is useful to encode values which many solvables
+ have in common, and whose overall set is relatively limited. A prime
+ example would be the media number. The actual value is encoded in the
+ SIZE member of the key structure. Be warned: careless use of this
+ leads to combinatoric explosion of number of schemas. */
#define TYPE_VOID 0
#define TYPE_ID 1
#define TYPE_IDARRAY 2
#define TYPE_IDVALUEARRAY 13
#define TYPE_IDVALUEVALUEARRAY 14
-/* The special types are usable to encode one-valued attributes, they have
- no associated data. This is useful to encode values which many solvables
- have in common, and whose overall set is relatively limited. A prime
- example would be the media number. Be warned: careless use of this
- leads to combinatoric explosion of number of schemas. */
-#define TYPE_ATTR_SPECIAL_START 15
-#define TYPE_ATTR_SPECIAL_END (TYPE_ATTR_SPECIAL_START + 31)
-#define TYPE_ATTR_TYPE_MAX TYPE_ATTR_SPECIAL_END
+#define TYPE_ATTR_TYPE_MAX TYPE_IDVALUEVALUEARRAY
//-----------------------------------------------
fprintf (stdout, "%s:", id2str (s->pool, ai.name));
switch (ai.type)
{
+ case TYPE_VOID:
+ fprintf (stdout, "spec %d\n", ai.as_int);
+ break;
case TYPE_ATTR_INT:
fprintf (stdout, "int %u\n", ai.as_int);
break;
break;
}
default:
- if (ai.type >= TYPE_ATTR_SPECIAL_START
- && ai.type <= TYPE_ATTR_SPECIAL_END)
- fprintf (stdout, "spec %d", ai.type - TYPE_ATTR_SPECIAL_START);
- fprintf (stdout, "\n");
break;
}
}