Changeset 1044

Show
Ignore:
Timestamp:
11/05/07 23:41:40 (10 months ago)
Author:
teqdruid
Message:

Fix for #29 as well as moving an inside function to outside, to avoid crashing arm-linux-gdc

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/mango/xml/sax/parser/teqXML.d

    r1043 r1044  
    631631    } 
    632632 
     633    void parseAttr() 
     634    { 
     635        static bool isWSorEQ(T wc) 
     636        { 
     637            return (wc == '=' || isWhiteSpace(wc)); 
     638        } 
     639         
     640        end.skipFunc!(isWhiteSpace)(); 
     641        start.moveTo(end); 
     642        end.advanceToFunc!(isWSorEQ)(); 
     643        /*We need to copy the name, since a memmove of the buffer could occure before we send the 
     644          string to the client, so let's copy it into stack space-- it's quicker 
     645        */ 
     646        T[] name = start.sliceTo(end); 
     647        T[] nameSCpy = (cast(T*)alloca(T.sizeof*name.length))[0 .. name.length]; 
     648        nameSCpy[] = name[]; 
     649         
     650        end.skipFunc!(isWhiteSpace)(); 
     651        if (end.read() != '=') 
     652            throw new TeqXMLException("Expected '=' in attribute"); 
     653        end.skipFunc!(isWhiteSpace)(); 
     654        T quote = end.read(); 
     655        if (quote != '"' && quote != '\'') 
     656            throw new TeqXMLException("Expected '\"' or \"'\" surrounding attribute values"); //" 
     657        start.moveTo(end); 
     658        end.advanceTo(quote); 
     659        T[] value = start.sliceTo(end); 
     660        T[] ueValue = null; 
     661        int ampIndx = Text.locate!(T)(value, '&'); 
     662        int last = 0; 
     663        while (ampIndx < value.length) 
     664        { 
     665            int scIndx = Text.locate!(T)(value, ';', ampIndx); 
     666            if (scIndx >= value.length) 
     667                break; 
     668             
     669            T[] entVal = entities[value[ampIndx+1..scIndx]]; 
     670            ueValue ~= value[last..ampIndx] ~ entVal; 
     671             
     672            last = scIndx + 1; 
     673            ampIndx = Text.locate!(T)(value, '&', last); 
     674        } 
     675         
     676        ueValue ~= value[last .. value.length]; 
     677 
     678        myHandler.addAttribute(nameSCpy, ueValue); 
     679        end++; 
     680    } 
     681     
    633682    void parseAttrs() 
    634683    { 
    635         void parseAttr() 
    636         { 
    637             static bool isWSorEQ(T wc) 
    638             { 
    639                 return (wc == '=' || isWhiteSpace(wc)); 
    640             } 
    641  
    642             end.skipFunc!(isWhiteSpace)(); 
    643             start.moveTo(end); 
    644             end.advanceToFunc!(isWSorEQ)(); 
    645             /*We need to copy the name, since a memmove of the buffer could occure before we send the 
    646                 string to the client, so let's copy it into stack space-- it's quicker 
    647             */ 
    648             T[] name = start.sliceTo(end); 
    649             T[] nameSCpy = (cast(T*)alloca(T.sizeof*name.length))[0 .. name.length]; 
    650             nameSCpy[] = name[]; 
    651  
    652             end.skipFunc!(isWhiteSpace)(); 
    653             if (end.read() != '=') 
    654                 throw new TeqXMLException("Expected '=' in attribute"); 
    655             end.skipFunc!(isWhiteSpace)(); 
    656             T quote = end.read(); 
    657             if (quote != '"' && quote != '\'') 
    658                 throw new TeqXMLException("Expected '\"' or \"'\" surrounding attribute values"); //" 
    659             start.moveTo(end); 
    660             end.advanceTo(quote); 
    661             T[] value = start.sliceTo(end); 
    662             T[] ueValue = null; 
    663             int ampIndx = Text.locate!(T)(value, '&'); 
    664             int last = 0; 
    665             while (ampIndx < value.length) 
    666             { 
    667                 int scIndx = Text.locate!(T)(value, ';', ampIndx); 
    668                 if (scIndx >= value.length) 
    669                     break; 
    670                  
    671                 T[] entVal = entities[value[ampIndx+1..scIndx]]; 
    672                 ueValue ~= value[last..ampIndx] ~ entVal; 
    673  
    674                 last = scIndx + 1; 
    675                 ampIndx = Text.locate!(T)(value, '&', last); 
    676             } 
    677  
    678             ueValue ~= value[last .. value.length]; 
    679  
    680             myHandler.addAttribute(nameSCpy, ueValue); 
    681             end++; 
    682         } 
     684 
    683685        start.moveTo(end); 
    684686        end.skipFunc!(isWhiteSpace)(); 
     
    11451147        { 
    11461148            gained = a.length; 
    1147             switch (decoder.getEncoding) { 
     1149            switch (decoder.encoding) { 
    11481150            case Encoding.Unknown: 
    11491151            case Encoding.UTF_8: