/[freetype]/freetype2/src/gxvalid/gxvcommn.c
ViewVC logotype

Diff of /freetype2/src/gxvalid/gxvcommn.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.5 by freetype, Fri Sep 23 13:22:10 2005 UTC revision 1.6 by wl, Wed Sep 28 07:34:45 2005 UTC
# Line 94  Line 94 
94        if ( j == nmemb )        if ( j == nmemb )
95          FT_INVALID_OFFSET;          FT_INVALID_OFFSET;
96    
97        *(length[i]) = (FT_UShort)(buff[j + 1] - buff[j]);        *(length[i]) = (FT_UShort)( buff[j + 1] - buff[j] );
98    
99        if ( 0 != offset[i] && 0 == *(length[i]) )        if ( 0 != offset[i] && 0 == *(length[i]) )
100          FT_INVALID_OFFSET;          FT_INVALID_OFFSET;
# Line 226  Line 226 
226        GXV_LIMIT_CHECK( 2 );        GXV_LIMIT_CHECK( 2 );
227        val = FT_NEXT_USHORT( p );        val = FT_NEXT_USHORT( p );
228    
229        *min = (FT_Byte) FT_MIN( *min, val );        *min = (FT_Byte)FT_MIN( *min, val );
230        *max = (FT_Byte) FT_MAX( *max, val );        *max = (FT_Byte)FT_MAX( *max, val );
231      }      }
232    
233      valid->subtable_length = p - table;      valid->subtable_length = p - table;
# Line 629  Line 629 
629    
630        for ( gid = firstGlyph; gid <= lastGlyph; gid++ )        for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
631        {        {
632          value = valid->lookupfmt4_trans( (FT_UShort)(gid - firstGlyph),          value = valid->lookupfmt4_trans( (FT_UShort)( gid - firstGlyph ),
633                                           base_value,                                           base_value,
634                                           limit,                                           limit,
635                                           valid );                                           valid );
# Line 742  Line 742 
742      glyphCount = FT_NEXT_USHORT( p );      glyphCount = FT_NEXT_USHORT( p );
743    
744      gxv_glyphid_validate( firstGlyph, valid );      gxv_glyphid_validate( firstGlyph, valid );
745      gxv_glyphid_validate( (FT_UShort)(firstGlyph + glyphCount), valid );      gxv_glyphid_validate( (FT_UShort)( firstGlyph + glyphCount ), valid );
746    
747      /* valueArray */      /* valueArray */
748      for ( i = 0; i < glyphCount; i++ )      for ( i = 0; i < glyphCount; i++ )
749      {      {
750        GXV_LIMIT_CHECK( 2 );        GXV_LIMIT_CHECK( 2 );
751        value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );        value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
752        valid->lookupval_func( (FT_UShort)(firstGlyph + i), value, valid );        valid->lookupval_func( (FT_UShort)( firstGlyph + i ), value, valid );
753      }      }
754    
755      valid->subtable_length = p - table;      valid->subtable_length = p - table;
# Line 915  Line 915 
915      }      }
916    
917      GXV_TRACE(( "  nameIndex = %d (UNTITLED)\n", name_index ));      GXV_TRACE(( "  nameIndex = %d (UNTITLED)\n", name_index ));
918        FT_INVALID_DATA;      FT_INVALID_DATA;
919      goto Exit;  /* make compiler happy */      goto Exit;  /* make compiler happy */
920    
921    Out:    Out:
# Line 972  Line 972 
972      if ( !nGlyphs )      if ( !nGlyphs )
973        goto Out;        goto Out;
974    
975      gxv_glyphid_validate( (FT_UShort)(firstGlyph + nGlyphs), valid );      gxv_glyphid_validate( (FT_UShort)( firstGlyph + nGlyphs ), valid );
976    
977      {      {
978        FT_Byte    nGlyphInClass[256];        FT_Byte    nGlyphInClass[256];
# Line 1005  Line 1005 
1005            break;            break;
1006          }          }
1007        }        }
1008        *length_p = (FT_UShort)(p - table);        *length_p = (FT_UShort)( p - table );
1009    
1010        /* scan max ClassID in use */        /* scan max ClassID in use */
1011        for ( i = 0; i < stateSize; i++ )        for ( i = 0; i < stateSize; i++ )
1012          if ( ( 3 < i ) && ( nGlyphInClass[i] > 0 ) )          if ( ( 3 < i ) && ( nGlyphInClass[i] > 0 ) )
1013            *maxClassID_p = (FT_Byte)i;  /* XXX: Check Range ? */            *maxClassID_p = (FT_Byte)i;  /* XXX: Check Range? */
1014      }      }
1015    
1016    Out:    Out:
# Line 1036  Line 1036 
1036      FT_Byte   clazz;      FT_Byte   clazz;
1037      FT_Byte   entry;      FT_Byte   entry;
1038    
1039        FT_UNUSED( stateSize ); /* for the non-debugging case */
1040    
1041    
1042      GXV_NAME_ENTER( "StateArray" );      GXV_NAME_ENTER( "StateArray" );
1043    
1044      GXV_TRACE(( "parse %d bytes by stateSize=%d maxClassID=%d\n",      GXV_TRACE(( "parse %d bytes by stateSize=%d maxClassID=%d\n",
1045                  (int)(*length_p), stateSize, (int)(maxClassID) ));                  (int)(*length_p), stateSize, (int)(maxClassID) ));
1046    
     FT_UNUSED( stateSize );  
   
1047      /*      /*
1048       * 2 states are predefined and must be described in StateArray:       * 2 states are predefined and must be described in StateArray:
1049       * state 0 (start of text), 1 (start of line)       * state 0 (start of text), 1 (start of line)
# Line 1060  Line 1060 
1060        for ( clazz = 0; clazz <= maxClassID; clazz++ )        for ( clazz = 0; clazz <= maxClassID; clazz++ )
1061        {        {
1062          entry = FT_NEXT_BYTE( p );          entry = FT_NEXT_BYTE( p );
1063          *maxEntry_p = (FT_Byte) FT_MAX( *maxEntry_p, entry );          *maxEntry_p = (FT_Byte)FT_MAX( *maxEntry_p, entry );
1064        }        }
1065      }      }
1066      GXV_TRACE(( "parsed: maxState=%d, maxEntry=%d\n",      GXV_TRACE(( "parsed: maxState=%d, maxEntry=%d\n",
1067                  *maxState_p, *maxEntry_p ));                  *maxState_p, *maxEntry_p ));
1068    
1069      *length_p = (FT_UShort)(p - table);      *length_p = (FT_UShort)( p - table );
1070    
1071      GXV_EXIT;      GXV_EXIT;
1072    }    }
# Line 1104  Line 1104 
1104          FT_INVALID_TOO_SHORT;          FT_INVALID_TOO_SHORT;
1105    
1106        /* ftxvalidator and FontValidator both warn and continue */        /* ftxvalidator and FontValidator both warn and continue */
1107        maxEntry = (FT_Byte)(*length_p / entrySize - 1);        maxEntry = (FT_Byte)( *length_p / entrySize - 1 );
1108        GXV_TRACE(( "too large maxEntry, shrinking to %d fit EntryTable length\n",        GXV_TRACE(( "too large maxEntry, shrinking to %d fit EntryTable length\n",
1109                    maxEntry ));                    maxEntry ));
1110      }      }
# Line 1139  Line 1139 
1139          continue;          continue;
1140        }        }
1141    
1142        state =  (FT_Byte)(( newState - stateArray ) / ( 1 + maxClassID ));        state = (FT_Byte)( ( newState - stateArray ) / ( 1 + maxClassID ) );
1143    
1144        switch ( GXV_GLYPHOFFSET_FMT( statetable ) )        switch ( GXV_GLYPHOFFSET_FMT( statetable ) )
1145        {        {
1146        case GXV_GLYPHOFFSET_NONE:        case GXV_GLYPHOFFSET_NONE:
1147          glyphOffset.uc = 0;  /* make compiler happy !! */          glyphOffset.uc = 0;  /* make compiler happy */
1148          break;          break;
1149    
1150        case GXV_GLYPHOFFSET_UCHAR:        case GXV_GLYPHOFFSET_UCHAR:
# Line 1174  Line 1174 
1174        default:        default:
1175          if ( valid->root->level >= FT_VALIDATE_PARANOID )          if ( valid->root->level >= FT_VALIDATE_PARANOID )
1176            FT_INVALID_FORMAT;            FT_INVALID_FORMAT;
   
1177          goto Exit;          goto Exit;
1178        }        }
1179    
# Line 1186  Line 1185 
1185                                                 statetable_limit,                                                 statetable_limit,
1186                                                 valid );                                                 valid );
1187      }      }
1188    
1189    Exit:    Exit:
1190      *length_p = (FT_UShort)(p - table);      *length_p = (FT_UShort)( p - table );
1191    
1192      GXV_EXIT;      GXV_EXIT;
1193    }    }
# Line 1269  Line 1269 
1269      else      else
1270        setup_func = gxv_StateTable_subtable_setup;        setup_func = gxv_StateTable_subtable_setup;
1271    
1272      setup_func( (FT_UShort)(limit - table),      setup_func( (FT_UShort)( limit - table ),
1273                  classTable,                  classTable,
1274                  stateArray,                  stateArray,
1275                  entryTable,                  entryTable,
# Line 1287  Line 1287 
1287                                 &maxClassID,                                 &maxClassID,
1288                                 valid );                                 valid );
1289      else      else
1290        maxClassID = (FT_Byte)(stateSize - 1);        maxClassID = (FT_Byte)( stateSize - 1 );
1291    
1292      if ( stateArray != 0 )      if ( stateArray != 0 )
1293        gxv_StateArray_validate( table + stateArray,        gxv_StateArray_validate( table + stateArray,
# Line 1400  Line 1400 
1400      FT_UShort            offset;      FT_UShort            offset;
1401      GXV_LookupValueDesc  value;      GXV_LookupValueDesc  value;
1402    
1403      /* XXX: check range ? */      /* XXX: check range? */
1404      offset = (FT_UShort)(base_value.u + relative_gindex * sizeof ( FT_UShort ));      offset = (FT_UShort)( base_value.u +
1405                              relative_gindex * sizeof ( FT_UShort ) );
1406    
1407      p     = valid->lookuptbl_head + offset;      p     = valid->lookuptbl_head + offset;
1408      limit = lookuptbl_limit;      limit = lookuptbl_limit;
# Line 1427  Line 1428 
1428      FT_UShort  clazz;      FT_UShort  clazz;
1429      FT_UShort  entry;      FT_UShort  entry;
1430    
1431        FT_UNUSED( stateSize ); /* for the non-debugging case */
1432    
1433    
1434      GXV_NAME_ENTER( "XStateArray" );      GXV_NAME_ENTER( "XStateArray" );
1435    
1436      GXV_TRACE(( "parse % 3d bytes by stateSize=% 3d maxClassID=% 3d\n",      GXV_TRACE(( "parse % 3d bytes by stateSize=% 3d maxClassID=% 3d\n",
1437                  (int)(*length_p), stateSize, (int)(maxClassID) ));                  (int)(*length_p), stateSize, (int)(maxClassID) ));
1438    
     FT_UNUSED( stateSize );  
   
1439      /*      /*
1440       * 2 states are predefined and must be described:       * 2 states are predefined and must be described:
1441       * state 0 (start of text), 1 (start of line)       * state 0 (start of text), 1 (start of line)
# Line 1451  Line 1452 
1452        for ( clazz = 0; clazz <= maxClassID; clazz++ )        for ( clazz = 0; clazz <= maxClassID; clazz++ )
1453        {        {
1454          entry = FT_NEXT_USHORT( p );          entry = FT_NEXT_USHORT( p );
1455          *maxEntry_p = (FT_UShort) FT_MAX( *maxEntry_p, entry );          *maxEntry_p = (FT_UShort)FT_MAX( *maxEntry_p, entry );
1456        }        }
1457      }      }
1458      GXV_TRACE(( "parsed: maxState=%d, maxEntry=%d\n",      GXV_TRACE(( "parsed: maxState=%d, maxEntry=%d\n",
# Line 1505  Line 1506 
1506            FT_INVALID_OFFSET;            FT_INVALID_OFFSET;
1507        }        }
1508    
1509        state = (FT_UShort)(newState_idx / ( 1 + maxClassID ));        state = (FT_UShort)( newState_idx / ( 1 + maxClassID ) );
1510        if ( 0 != ( newState_idx % ( 1 + maxClassID ) ) )        if ( 0 != ( newState_idx % ( 1 + maxClassID ) ) )
1511        {        {
1512          FT_TRACE4(( "-> new state = %d (supposed)\n"          FT_TRACE4(( "-> new state = %d (supposed)\n"
# Line 1639  Line 1640 
1640      }      }
1641      else      else
1642      {      {
1643        /* XXX: check range ? */        /* XXX: check range? */
1644        valid->xstatetable.maxClassID =        valid->xstatetable.maxClassID =
1645            (FT_UShort)(valid->xstatetable.nClasses - 1);          (FT_UShort)( valid->xstatetable.nClasses - 1 );
1646      }      }
1647    
1648      if ( stateArray != 0 )      if ( stateArray != 0 )

Legend:
Removed from v.1.5  
changed lines
  Added in v.1.6

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26