void AddAttr (Collection* C, const char* Name, const char* Value) /* Add an attribute to an alphabetically sorted attribute collection */ { /* Create a new attribute entry */ Attr* A = NewAttr (Name, Value); /* Search for the attribute. If it is there, we have a duplicate, otherwise * we have the insert position. */ unsigned Index; if (FindAttr (C, Name, &Index)) { Error ("Duplicate command line attribute `%s'", Name); } /* Insert the attribute */ CollInsert (C, A, Index); }
void VAppendAttr (VAttrList list, VStringConst name, VDictEntry *dict, VRepnKind repn, ...) { va_list args; VAttrRec *a; /* Create the new attribute node: */ va_start (args, repn); a = NewAttr (name, dict, repn, & args); va_end (args); /* Append it: */ a->next = NULL; a->prev = list->prev; if (a->prev) a->prev->next = a; else list->next = a; list->prev = a; }
void VSetAttr (VAttrList list, VStringConst name, VDictEntry *dict, VRepnKind repn, ...) { va_list args; VAttrListPosn posn; VAttrRec *a; /* Locate any existing attribute of the specified name: */ va_start (args, repn); if (VLookupAttr (list, name, & posn)) SetAttr (& posn, dict, repn, & args); else { /* None exists -- append a new attribute of that name: */ a = NewAttr (name, dict, repn, & args); a->next = NULL; if (a->prev = list->prev) a->prev->next = a; else list->next = a; list->prev = a; } va_end (args); }
void VInsertAttr (VAttrListPosn *posn, VBooleanPromoted after, VStringConst name, VDictEntry *dict, VRepnKind repn, ...) { va_list args; VAttrRec *a; /* Create the new attribute node: */ va_start (args, repn); a = NewAttr (name, dict, repn, & args); va_end (args); /* Insert it at the specified position: */ if (! posn->ptr) { /* the pointer points nowhere */ if (a->next = posn->list->next) a->next->prev = a; a->prev = 0; posn->list->next = a; if (! posn->list->prev) posn->list->prev = a; } else if (after) { if (a->next = posn->ptr->next) a->next->prev = a; else posn->list->prev = a; a->prev = posn->ptr; a->prev->next = a; if (posn->list->prev == a->prev) posn->list->prev = a; } else { a->next = posn->ptr; if (a->prev = posn->ptr->prev) a->prev->next = a; else posn->list->next = a; a->next->prev = a; if (posn->list->next == a->next) posn->list->next = a; } }