int
obj_read(struct fastbuf *f, struct odes *o)
{
- byte buf[1024];
+ byte buf[MAX_ATTR_SIZE];
while (bgets(f, buf, sizeof(buf)))
{
for(struct oattr *a=d->attrs; a; a=a->next)
for(struct oattr *b=a; b; b=b->same)
{
+ byte *z;
bputc(f, a->attr);
- for(byte *z = b->val; *z; z++)
+ for(z = b->val; *z; z++)
if (*z >= ' ' || *z == '\t')
bputc(f, *z);
else
bputc(f, '?');
log(L_ERROR, "obj_dump: Found non-ASCII characters (URL might be %s)", obj_find_aval(d, 'U'));
}
+ ASSERT(z - b->val <= MAX_ATTR_SIZE-2);
bputc(f, '\n');
}
}
after->same = b;
return b;
}
+
+void
+obj_move_attr_to_head(struct odes *o, uns x)
+{
+ struct oattr *a, **z;
+
+ z = &o->attrs;
+ while (a = *z)
+ {
+ if (a->attr == x)
+ {
+ *z = a->next;
+ a->next = o->attrs;
+ o->attrs = a;
+ break;
+ }
+ z = &a->next;
+ }
+}
+
+void
+obj_move_attr_to_tail(struct odes *o, uns x)
+{
+ struct oattr *a, **z;
+
+ z = &o->attrs;
+ while (a = *z)
+ {
+ if (a->attr == x)
+ {
+ *z = a->next;
+ while (*z)
+ z = &(*z)->next;
+ *z = a;
+ a->next = NULL;
+ break;
+ }
+ z = &a->next;
+ }
+}