Commit 998b168b authored by David Turner's avatar David Turner
Browse files

* src/base/Jamfile: adding src/base/ftgxval.c

        * src/gxvalid/gxvbsln.c, src/gxvalid/gxvcommn.c, src/gxvalid/gxvfeat.c,
        src/gxvalid/gxvjust.c, src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c,
        src/gxvalid/gxvmort.c, src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
        src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c, src/gxvalid/gxvmort5.c,
        src/gxvalid/gxvmorx.c, src/gxvalid/gxvmorx0.c, src/gxvalid/gxvmorx1.c,
        src/gxvalid/gxvmorx2.c, src/gxvalid/gxvmorx5.c, src/gxvalid/gxvopbd.c,
        src/gxvalid/gxvprop.c, src/sfnt/sfdriver.c, src/truetype/ttgload.c:
          removing _many_ compiler warnings when compiling with Visual C++
          at maximum level (/W4)
parent a879e8e2
......@@ -3,6 +3,18 @@
* src/autofit/aflatin.c (af_latin_hints_init): fixed a bug that
prevented internal hint mode bitflags from being computed correctly
* src/base/Jamfile: adding src/base/ftgxval.c
* src/gxvalid/gxvbsln.c, src/gxvalid/gxvcommn.c, src/gxvalid/gxvfeat.c,
src/gxvalid/gxvjust.c, src/gxvalid/gxvkern.c, src/gxvalid/gxvlcar.c,
src/gxvalid/gxvmort.c, src/gxvalid/gxvmort0.c, src/gxvalid/gxvmort1.c,
src/gxvalid/gxvmort2.c, src/gxvalid/gxvmort4.c, src/gxvalid/gxvmort5.c,
src/gxvalid/gxvmorx.c, src/gxvalid/gxvmorx0.c, src/gxvalid/gxvmorx1.c,
src/gxvalid/gxvmorx2.c, src/gxvalid/gxvmorx5.c, src/gxvalid/gxvopbd.c,
src/gxvalid/gxvprop.c, src/sfnt/sfdriver.c, src/truetype/ttgload.c:
removing _many_ compiler warnings when compiling with Visual C++
at maximum level (/W4)
2005-09-22 Werner Lemberg <wl@gnu.org>
* docs/CHANGES: Mention SING Glyphlet support.
......
......@@ -30,10 +30,15 @@ SubDir FT2_TOP $(FT2_SRC_DIR) base ;
# Add the optional/replaceable files.
#
Library $(FT2_LIB) : ftsystem.c ftinit.c ftglyph.c ftmm.c ftbdf.c
ftbbox.c ftdebug.c ftxf86.c fttype1.c ftpfr.c
ftstroke.c ftwinfnt.c ftotval.c ftbitmap.c
ftsynth.c ;
{
local _sources = system init glyph mm bdf
bbox debug xf86 type1 pfr
stroke winfnt otval bitmap synth
gxval
;
Library $(FT2_LIB) : ft$(_sources).c ;
}
# Add Macintosh-specific file to the library when necessary.
#
......
......@@ -131,8 +131,8 @@
FT_UShort offset;
GXV_LookupValueDesc value;
offset = base_value.u + ( relative_gindex * sizeof ( FT_UShort ) );
/* XXX: check range ? */
offset = (FT_UShort)(base_value.u + ( relative_gindex * sizeof ( FT_UShort ) ));
p = valid->lookuptbl_head + offset;
limit = lookuptbl_limit;
......
......@@ -94,7 +94,7 @@
if ( j == nmemb )
FT_INVALID_OFFSET;
*(length[i]) = buff[j + 1] - buff[j];
*(length[i]) = (FT_UShort)(buff[j + 1] - buff[j]);
if ( 0 != offset[i] && 0 == *(length[i]) )
FT_INVALID_OFFSET;
......@@ -197,8 +197,8 @@
GXV_LIMIT_CHECK( 1 );
val = FT_NEXT_BYTE( p );
*min = FT_MIN( *min, val );
*max = FT_MAX( *max, val );
*min = (FT_Byte)FT_MIN( *min, val );
*max = (FT_Byte)FT_MAX( *max, val );
}
valid->subtable_length = p - table;
......@@ -226,8 +226,8 @@
GXV_LIMIT_CHECK( 2 );
val = FT_NEXT_USHORT( p );
*min = FT_MIN( *min, val );
*max = FT_MAX( *max, val );
*min = (FT_Byte) FT_MIN( *min, val );
*max = (FT_Byte) FT_MAX( *max, val );
}
valid->subtable_length = p - table;
......@@ -282,9 +282,9 @@
;
entrySelector--;
searchRange *= binSrchHeader->unitSize;
rangeShift = binSrchHeader->nUnits * binSrchHeader->unitSize -
searchRange;
searchRange = (FT_UShort)( searchRange * binSrchHeader->unitSize );
rangeShift = (FT_UShort)( binSrchHeader->nUnits * binSrchHeader->unitSize
- searchRange );
if ( searchRange != binSrchHeader->searchRange ||
entrySelector != binSrchHeader->entrySelector ||
......@@ -629,8 +629,11 @@
for ( gid = firstGlyph; gid <= lastGlyph; gid++ )
{
value = valid->lookupfmt4_trans( gid - firstGlyph, base_value,
limit, valid );
value = valid->lookupfmt4_trans( (FT_UShort)(gid - firstGlyph),
base_value,
limit,
valid );
valid->lookupval_func( gid, value, valid );
}
}
......@@ -739,14 +742,14 @@
glyphCount = FT_NEXT_USHORT( p );
gxv_glyphid_validate( firstGlyph, valid );
gxv_glyphid_validate( firstGlyph + glyphCount, valid );
gxv_glyphid_validate( (FT_UShort)(firstGlyph + glyphCount), valid );
/* valueArray */
for ( i = 0; i < glyphCount; i++ )
{
GXV_LIMIT_CHECK( 2 );
value = GXV_LOOKUP_VALUE_LOAD( p, valid->lookupval_sign );
valid->lookupval_func( firstGlyph + i, value, valid );
valid->lookupval_func( (FT_UShort)(firstGlyph + i), value, valid );
}
valid->subtable_length = p - table;
......@@ -912,13 +915,15 @@
}
GXV_TRACE(( " nameIndex = %d (UNTITLED)\n", name_index ));
FT_INVALID_DATA;
FT_INVALID_DATA;
goto Exit; /* make compiler happy */
Out:
FT_TRACE1(( " nameIndex = %d (", name_index ));
GXV_TRACE_HEXDUMP_SFNTNAME( name );
FT_TRACE1(( ")\n" ));
Exit:
GXV_EXIT;
}
......@@ -967,7 +972,7 @@
if ( !nGlyphs )
goto Out;
gxv_glyphid_validate( firstGlyph + nGlyphs, valid );
gxv_glyphid_validate( (FT_UShort)(firstGlyph + nGlyphs), valid );
{
FT_Byte nGlyphInClass[256];
......@@ -1000,12 +1005,12 @@
break;
}
}
*length_p = p - table;
*length_p = (FT_UShort)(p - table);
/* scan max ClassID in use */
for ( i = 0; i < stateSize; i++ )
if ( ( 3 < i ) && ( nGlyphInClass[i] > 0 ) )
*maxClassID_p = i;
*maxClassID_p = (FT_Byte)i; /* XXX: Check Range ? */
}
Out:
......@@ -1037,6 +1042,8 @@
GXV_TRACE(( "parse %d bytes by stateSize=%d maxClassID=%d\n",
(int)(*length_p), stateSize, (int)(maxClassID) ));
FT_UNUSED( stateSize );
/*
* 2 states are predefined and must be described in StateArray:
* state 0 (start of text), 1 (start of line)
......@@ -1053,13 +1060,13 @@
for ( clazz = 0; clazz <= maxClassID; clazz++ )
{
entry = FT_NEXT_BYTE( p );
*maxEntry_p = FT_MAX( *maxEntry_p, entry );
*maxEntry_p = (FT_Byte) FT_MAX( *maxEntry_p, entry );
}
}
GXV_TRACE(( "parsed: maxState=%d, maxEntry=%d\n",
*maxState_p, *maxEntry_p ));
*length_p = p - table;
*length_p = (FT_UShort)(p - table);
GXV_EXIT;
}
......@@ -1097,7 +1104,7 @@
FT_INVALID_TOO_SHORT;
/* ftxvalidator and FontValidator both warn and continue */
maxEntry = *length_p / entrySize - 1;
maxEntry = (FT_Byte)(*length_p / entrySize - 1);
GXV_TRACE(( "too large maxEntry, shrinking to %d fit EntryTable length\n",
maxEntry ));
}
......@@ -1132,11 +1139,12 @@
continue;
}
state = ( newState - stateArray ) / ( 1 + maxClassID );
state = (FT_Byte)(( newState - stateArray ) / ( 1 + maxClassID ));
switch ( GXV_GLYPHOFFSET_FMT( statetable ) )
{
case GXV_GLYPHOFFSET_NONE:
glyphOffset.uc = 0; /* make compiler happy !! */
break;
case GXV_GLYPHOFFSET_UCHAR:
......@@ -1166,6 +1174,8 @@
default:
if ( valid->root->level >= FT_VALIDATE_PARANOID )
FT_INVALID_FORMAT;
goto Exit;
}
if ( NULL != valid->statetable.entry_validate_func )
......@@ -1176,7 +1186,8 @@
statetable_limit,
valid );
}
*length_p = p - table;
Exit:
*length_p = (FT_UShort)(p - table);
GXV_EXIT;
}
......@@ -1258,7 +1269,7 @@
else
setup_func = gxv_StateTable_subtable_setup;
setup_func( limit - table,
setup_func( (FT_UShort)(limit - table),
classTable,
stateArray,
entryTable,
......@@ -1276,7 +1287,7 @@
&maxClassID,
valid );
else
maxClassID = stateSize - 1;
maxClassID = (FT_Byte)(stateSize - 1);
if ( stateArray != 0 )
gxv_StateArray_validate( table + stateArray,
......@@ -1389,8 +1400,8 @@
FT_UShort offset;
GXV_LookupValueDesc value;
offset = base_value.u + relative_gindex * sizeof ( FT_UShort );
/* XXX: check range ? */
offset = (FT_UShort)(base_value.u + relative_gindex * sizeof ( FT_UShort ));
p = valid->lookuptbl_head + offset;
limit = lookuptbl_limit;
......@@ -1422,6 +1433,8 @@
GXV_TRACE(( "parse % 3d bytes by stateSize=% 3d maxClassID=% 3d\n",
(int)(*length_p), stateSize, (int)(maxClassID) ));
FT_UNUSED( stateSize );
/*
* 2 states are predefined and must be described:
* state 0 (start of text), 1 (start of line)
......@@ -1438,7 +1451,7 @@
for ( clazz = 0; clazz <= maxClassID; clazz++ )
{
entry = FT_NEXT_USHORT( p );
*maxEntry_p = FT_MAX( *maxEntry_p, entry );
*maxEntry_p = (FT_UShort) FT_MAX( *maxEntry_p, entry );
}
}
GXV_TRACE(( "parsed: maxState=%d, maxEntry=%d\n",
......@@ -1492,7 +1505,7 @@
FT_INVALID_OFFSET;
}
state = newState_idx / ( 1 + maxClassID );
state = (FT_UShort)(newState_idx / ( 1 + maxClassID ));
if ( 0 != ( newState_idx % ( 1 + maxClassID ) ) )
{
FT_TRACE4(( "-> new state = %d (supposed)\n"
......@@ -1505,6 +1518,7 @@
switch ( GXV_GLYPHOFFSET_FMT( xstatetable ) )
{
case GXV_GLYPHOFFSET_NONE:
glyphOffset.uc = 0; /* make compiler happy */
break;
case GXV_GLYPHOFFSET_UCHAR:
......@@ -1534,6 +1548,7 @@
default:
if ( valid->root->level >= FT_VALIDATE_PARANOID )
FT_INVALID_FORMAT;
goto Exit;
}
if ( NULL != valid->xstatetable.entry_validate_func )
......@@ -1545,6 +1560,7 @@
valid );
}
Exit:
*length_p = p - table;
GXV_EXIT;
......@@ -1622,7 +1638,11 @@
classTable_length = valid->subtable_length;
}
else
valid->xstatetable.maxClassID = valid->xstatetable.nClasses - 1;
{
/* XXX: check range ? */
valid->xstatetable.maxClassID =
(FT_UShort)(valid->xstatetable.nClasses - 1);
}
if ( stateArray != 0 )
gxv_XStateArray_validate( table + stateArray,
......
......@@ -225,14 +225,15 @@
( featureFlags & GXV_FEAT_MASK_UNUSED ) == 0 )
FT_INVALID_DATA;
exclusive = featureFlags & GXV_FEAT_MASK_EXCLUSIVE_SETTINGS;
exclusive = FT_BOOL(featureFlags & GXV_FEAT_MASK_EXCLUSIVE_SETTINGS);
if ( exclusive )
{
FT_Byte dynamic_default;
if ( featureFlags & GXV_FEAT_MASK_DYNAMIC_DEFAULT )
dynamic_default = featureFlags & GXV_FEAT_MASK_DEFAULT_SETTING;
dynamic_default = (FT_Byte)( featureFlags &
GXV_FEAT_MASK_DEFAULT_SETTING);
else
dynamic_default = 0;
......
......@@ -401,10 +401,10 @@
FT_UNUSED( valid );
setMark = ( 0x8000U & flags ) / 0x8000U;
dontAdvance = ( 0x4000 & flags ) / 0x4000;
markClass = ( 0x3F80 & flags ) / 0x0080;
currentClass = 0x007F & flags ;
setMark = (FT_UShort)( (flags >> 15) & 1 );
dontAdvance = (FT_UShort)( (flags >> 14) & 1);
markClass = (FT_UShort)( (flags >> 7) & 0x7F );
currentClass = (FT_UShort)( flags & 0x7F );
/* TODO: validate markClass & currentClass */
}
......
......@@ -234,9 +234,9 @@
FT_UNUSED( glyphOffset );
push = flags / 0x8000U;
dontAdvance = ( flags & 0x4000 ) / 0x4000;
valueOffset = flags & 0x3FFF;
push = (FT_UShort)( (flags >> 15) & 1 );
dontAdvance = (FT_UShort)( (flags >> 14) & 1 );
valueOffset = (FT_UShort)( flags & 0x3FFF );
{
GXV_kern_fmt1_StateOptRecData vt_rec =
......@@ -341,7 +341,7 @@
tag, firstGlyph, nGlyphs ));
gxv_glyphid_validate( firstGlyph, valid );
gxv_glyphid_validate( firstGlyph + nGlyphs - 1, valid );
gxv_glyphid_validate( (FT_UShort)(firstGlyph + nGlyphs - 1), valid );
gxv_array_getlimits_ushort( p, p + ( 2 * nGlyphs ),
&( GXV_KERN_FMT2_DATA( offset_min[spec] ) ),
......@@ -517,10 +517,10 @@
if ( coverage & 0x1FFC )
return 0;
kernVertical = ( coverage >> 15 ) & 1;
kernCrossStream = ( coverage >> 14 ) & 1;
kernVariation = ( coverage >> 13 ) & 1;
*format = coverage & 0x0003;
kernVertical = FT_BOOL(( coverage >> 15 ) & 1);
kernCrossStream = FT_BOOL(( coverage >> 14 ) & 1);
kernVariation = FT_BOOL(( coverage >> 13 ) & 1);
*format = (FT_UShort)( coverage & 0x0003 );
GXV_TRACE(( "new Apple-dialect: "
"horizontal=%d, cross-stream=%d, variation=%d, format=%d\n",
......@@ -528,6 +528,8 @@
GXV_TRACE(( "kerning values in Apple format subtable are ignored\n" ));
FT_UNUSED( valid );
return 1;
}
......@@ -550,9 +552,9 @@
if ( coverage & 0x02FC )
return 0;
horizontal = ( coverage >> 15 ) & 1;
cross_stream = ( coverage >> 13 ) & 1;
*format = coverage & 0x0003;
horizontal = FT_BOOL(( coverage >> 15 ) & 1);
cross_stream = FT_BOOL(( coverage >> 13 ) & 1);
*format = (FT_UShort)( coverage & 0x0003 );
GXV_TRACE(( "classic Apple-dialect: "
"horizontal=%d, cross-stream=%d, format=%d\n",
......@@ -579,16 +581,17 @@
FT_Bool cross_stream;
FT_Bool override;
FT_UNUSED( valid );
/* reserved bits = 0 */
if ( coverage & 0xFDF0 )
return 0;
horizontal = coverage & 1;
minimum = ( coverage >> 1 ) & 1;
cross_stream = ( coverage >> 2 ) & 1;
override = ( coverage >> 3 ) & 1;
*format = ( coverage >> 8 ) & 0x0003;
horizontal = FT_BOOL( coverage & 1 );
minimum = FT_BOOL(( coverage >> 1 ) & 1);
cross_stream = FT_BOOL(( coverage >> 2 ) & 1);
override = FT_BOOL(( coverage >> 3 ) & 1);
*format = (FT_UShort)(( coverage >> 8 ) & 0x0003);
GXV_TRACE(( "classic Microsoft-dialect: "
"horizontal=%d, minimum=%d, cross-stream=%d, "
......
......@@ -157,8 +157,8 @@
FT_UNUSED( lookuptbl_limit );
offset = base_value.u + relative_gindex * sizeof ( FT_UShort );
/* XXX: check range ? */
offset = (FT_UShort)(base_value.u + relative_gindex * sizeof ( FT_UShort ));
p = valid->root->base + offset;
limit = valid->root->limit;
......
......@@ -64,10 +64,9 @@
/* nSettings in gxvfeat.c is halved for exclusive on/off settings */
nSettings_max = gxv_feat_registry[f->featureType].nSettings;
if ( gxv_feat_registry[f->featureType].exclusive )
nSettings_max = 2 * gxv_feat_registry[f->featureType].nSettings;
else
nSettings_max = gxv_feat_registry[f->featureType].nSettings;
nSettings_max = (FT_Byte)(2*nSettings_max);
GXV_TRACE(( "featureType %d is registered", f->featureType ));
GXV_TRACE(( "setting %d", f->featureSetting ));
......@@ -125,6 +124,8 @@
gxv_mort_coverage_validate( FT_UShort coverage,
GXV_Validator valid )
{
FT_UNUSED( valid );
if ( coverage & 0x8000U )
GXV_TRACE(( " this subtable is for vertical text only\n" ));
else
......
......@@ -80,13 +80,14 @@
FT_UNUSED( limit );
markFirst = flags / 0x8000U;
dontAdvance = ( flags & 0x4000 ) / 0x4000;
markLast = ( flags & 0x2000 ) / 0x2000;
reserved = flags & 0x1FF0;
verb = flags & 0x000F;
markFirst = (FT_UShort)( (flags >> 15) & 1 );
dontAdvance = (FT_UShort)( (flags >> 14) & 1 );
markLast = (FT_UShort)( (flags >> 13) & 1 );
reserved = (FT_UShort)( flags & 0x1FF0 );
verb = (FT_UShort)( flags & 0x000F );
FT_UNUSED( GXV_Mort_IndicScript_Msg[verb] );
FT_UNUSED( glyphOffset );
GXV_TRACE(( " IndicScript MorphRule for glyphOffset 0x%04x",
glyphOffset.u ));
......@@ -96,6 +97,8 @@
GXV_TRACE(( " %02d", verb ));
GXV_TRACE(( " %s\n", GXV_Mort_IndicScript_Msg[verb] ));
if ( 0 < reserved )
{
GXV_TRACE(( " non-zero bits found in reserved range\n" ));
......
......@@ -115,13 +115,14 @@
substTable = ((GXV_mort_subtable_type1_StateOptRec *)
(valid->statetable.optdata))->substitutionTable;
substTable_limit = substTable +
substTable_limit = (FT_UShort)(substTable +
((GXV_mort_subtable_type1_StateOptRec *)
(valid->statetable.optdata))->substitutionTable_length;
(valid->statetable.optdata))->substitutionTable_length);
min_gid = ( substTable - wordOffset * 2 ) / 2;
max_gid = ( substTable_limit - wordOffset * 2 ) / 2;
max_gid = FT_MAX( max_gid, valid->face->num_glyphs );
min_gid = (FT_UShort)(( substTable - wordOffset * 2 ) / 2);
max_gid = (FT_UShort)(( substTable_limit - wordOffset * 2 ) / 2);
max_gid = (FT_UShort)(FT_MAX( max_gid, valid->face->num_glyphs ));
/* XXX: check range ? */
/* TODO: min_gid & max_gid comparison with ClassTable contents */
}
......@@ -146,11 +147,11 @@
FT_UNUSED( limit );
setMark = flags / 0x8000U;
dontAdvance = ( flags & 0x4000 ) / 0x4000;
reserved = flags & 0x3FFF;
markOffset = GXV_USHORT_TO_SHORT( glyphOffset.ul / 0x00010000UL );
currentOffset = GXV_USHORT_TO_SHORT( glyphOffset.ul & 0x0000FFFFUL );
setMark = (FT_UShort)( flags >> 15);
dontAdvance = (FT_UShort)((flags >> 14) & 1);
reserved = (FT_Short)( flags & 0x3FFF );
markOffset = (FT_Short)( glyphOffset.ul >> 16 );
currentOffset = (FT_Short)( glyphOffset.ul );
if ( 0 < reserved )
{
......@@ -177,9 +178,9 @@
GXV_Validator valid )
{
FT_Bytes p = table;
FT_UShort num_gids =
FT_UShort num_gids = (FT_UShort)(
((GXV_mort_subtable_type1_StateOptRec *)
(valid->statetable.optdata))->substitutionTable_length / 2;
(valid->statetable.optdata))->substitutionTable_length / 2);
FT_UShort i;
......
......@@ -177,9 +177,9 @@
lig_action = FT_NEXT_ULONG( p );
last = (lig_action & 0x80000000UL) / 0x80000000UL;
store = (lig_action & 0x40000000UL) / 0x40000000UL;
offset = lig_action & 0x3FFFFFFFUL;
last = (FT_UShort)( (lig_action >> 31) & 1 );
store = (FT_UShort)( (lig_action >> 30) & 1 );
offset = lig_action & 0x3FFFFFFFUL;
}
}
......@@ -202,9 +202,9 @@
FT_UNUSED( limit );
setComponent = ( flags & 0x8000U ) / 0x8000U;
dontAdvance = ( flags & 0x4000 ) / 0x4000;
offset = flags & 0x3FFF;
setComponent = (FT_UShort)( (flags >> 15) & 1 );
dontAdvance = (FT_UShort)( (flags >> 14) & 1 );
offset = (FT_UShort)( flags & 0x3FFFU );
if ( 0 < offset )
gxv_mort_subtable_type2_ligActionOffset_validate( table, offset,
......
......@@ -87,8 +87,8 @@
FT_UShort offset;
GXV_LookupValueDesc value;
offset = base_value.u + relative_gindex * sizeof ( FT_UShort );
/* XXX: check range */
offset = (FT_UShort)(base_value.u + relative_gindex * sizeof ( FT_UShort ));
p = valid->lookuptbl_head + offset;
limit = lookuptbl_limit;
......
......@@ -158,16 +158,16 @@
FT_UNUSED( state );
setMark = ( flags >> 15 ) & 1;
dontAdvance = ( flags >> 14 ) & 1;
currentIsKashidaLike = ( flags >> 13 ) & 1;
markedIsKashidaLike = ( flags >> 12 ) & 1;
currentInsertBefore = ( flags >> 11 ) & 1;
markedInsertBefore = ( flags >> 10 ) & 1;
currentInsertCount = ( flags & 0x03E0 ) / 0x0020;
markedInsertCount = ( flags & 0x001F );
currentInsertList = glyphOffset.ul / 0x00010000UL;
markedInsertList = glyphOffset.ul & 0x0000FFFFUL;
setMark = FT_BOOL(( flags >> 15 ) & 1);
dontAdvance = FT_BOOL(( flags >> 14 ) & 1);
currentIsKashidaLike = FT_BOOL(( flags >> 13 ) & 1);
markedIsKashidaLike = FT_BOOL(( flags >> 12 ) & 1);
currentInsertBefore = FT_BOOL(( flags >> 11 ) & 1);
markedInsertBefore = FT_BOOL(( flags >> 10 ) & 1);
currentInsertCount = (FT_Byte)( (flags >> 5) & 0x1F );