Changeset 237

Show
Ignore:
Timestamp:
01/11/08 20:07:37
Author:
dan
Message:

fix size calculation for "pascalU30" strings > 127 bytes.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/codegen/size.xsl

    r228 r237  
    107107 
    108108<xsl:template match="string" mode="size"> 
    109         r += ((<xsl:value-of select="@name"/> ? strlen( <xsl:value-of select="@name"/> ) : 0)+1)*8; 
     109        { 
     110                int bytes = 1; 
     111                <xsl:if test="@mode='pascalU30'"> 
     112                        if( <xsl:value-of select="@name"/> ) { 
     113                                int len = strlen( <xsl:value-of select="@name"/> ); 
     114                                uint32_t limit = 0x80; 
     115                                for(; len > limit - 1; limit *= 0x80) { 
     116                                        bytes++; 
     117                                } 
     118                        } 
     119                </xsl:if> 
     120                r += ((<xsl:value-of select="@name"/> ? strlen( <xsl:value-of select="@name"/> ) : 0)+bytes)*8; 
     121        } 
    110122</xsl:template> 
    111123