X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2Fobject.c;h=d3e9b9aa4f45c316f2c0cdbed8e630f3d9786014;hb=0c53af3db5fdca461f49998194ecbfd8f55b7a8a;hp=d12461527a4a24889e38cf900b1ecbaf65745e14;hpb=ee29b327c99803abb3426de894601d0655312b13;p=libucw.git diff --git a/lib/object.c b/lib/object.c index d1246152..d3e9b9aa 100644 --- a/lib/object.c +++ b/lib/object.c @@ -2,6 +2,9 @@ * Sherlock Library -- Object Functions * * (c) 1997--2001 Martin Mares + * + * This software may be freely distributed and used according to the terms + * of the GNU Lesser General Public License. */ #include "lib/lib.h" @@ -60,7 +63,7 @@ obj_free(struct odes *o) int obj_read(struct fastbuf *f, struct odes *o) { - byte buf[1024]; + byte buf[4096]; struct oattr **last = &o->attrs; struct oattr *a, *la; @@ -100,7 +103,7 @@ obj_write(struct fastbuf *f, struct odes *d) { bputc(f, a->attr); for(z = b->val; *z; z++) - if (*z >= ' ') + if (*z >= ' ' || *z == '\t') bputc(f, *z); else { @@ -220,5 +223,43 @@ obj_add_attr(struct odes *o, struct oattr *a, uns x, byte *v) b = oa_new(o, x, v); a->last_same->same = b; a->last_same = b; + return a; +} + +struct oattr * +obj_prepend_attr(struct odes *o, uns x, byte *v) +{ + struct oattr *a, *b, **z; + + b = oa_new(o, x, v); + z = &o->attrs; + while (a = *z) + { + if (a->attr == x) + { + b->same = a; + b->next = a->next; + a->next = NULL; + *z = b; + b->last_same = a->last_same; + return b; + } + z = &a->next; + } + b->next = o->attrs; + o->attrs = b; + return b; +} + +struct oattr * +obj_insert_attr(struct odes *o, struct oattr *first, struct oattr *after, byte *v) +{ + struct oattr *b; + + b = oa_new(o, first->attr, v); + b->same = after->same; + after->same = b; + if (first->last_same == after) + first->last_same = b; return b; }