Fixing duplicate definitions of an attribute

I suggest that duplicate definitions of an attribute, e.g.,

<foo num=7 num=8 y=9 num=3>

not simply be flagged with a warning, but repaired to the appropriate
value
using the last attribute definition---in other words this should become

<foo num="3" y="9">

I would advocate modifying lexer.c's function

AttVal *ParseAttrs(Lexer *lexer, Bool *isempty

to add

        { //Require a new block to declare new variables
            AttVal * check = list; //Check if attribute repeated in
list,
                                   //If so keep only the later value
            char duplicate = 0; //Is this a duplicate attr?
            for(; check != null; check = check->next) {
                if(strcmp(check->attribute, attribute) == 0) {
                    MemFree(check->value);
                    MemFree(attribute);
                    check->value = value;  //Overwrite value with newer
value
                    duplicate = 1;
                    break;
                }
            }
            if (duplicate) continue; //process remaining attributes
        }

right after

        value = ParseValue(lexer, attribute, no, isempty, &delim);

to do this.

Received on Wednesday, 11 April 2001 12:50:01 UTC