[pshinter] Signedness fixes.

* src/pshinter/pshalgo.c, src/pshinter/pshglob.c,
src/pshinter/pshrec.c: Apply.
This commit is contained in:
Werner Lemberg 2015-02-22 15:59:02 +01:00
parent 41c2ed8143
commit 452066cdb9
4 changed files with 62 additions and 40 deletions

View File

@ -1,3 +1,10 @@
2015-02-22 Werner Lemberg <wl@gnu.org>
[pshinter] Signedness fixes.
* src/pshinter/pshalgo.c, src/pshinter/pshglob.c,
src/pshinter/pshrec.c: Apply.
2015-02-22 Werner Lemberg <wl@gnu.org>
[pshinter] Use macros for (unsigned) flags, not enumerations.

View File

@ -1274,8 +1274,8 @@
FT_NEW_ARRAY( glyph->contours, outline->n_contours ) )
goto Exit;
glyph->num_points = outline->n_points;
glyph->num_contours = outline->n_contours;
glyph->num_points = (FT_UInt)outline->n_points;
glyph->num_contours = (FT_UInt)outline->n_contours;
{
FT_UInt first = 0, next, n;
@ -1285,15 +1285,15 @@
for ( n = 0; n < glyph->num_contours; n++ )
{
FT_Int count;
FT_UInt count;
PSH_Point point;
next = outline->contours[n] + 1;
next = (FT_UInt)outline->contours[n] + 1;
count = next - first;
contour->start = points + first;
contour->count = (FT_UInt)count;
contour->count = count;
if ( count > 0 )
{
@ -1697,12 +1697,10 @@
for ( ; num_masks > 1; num_masks--, mask++ )
{
FT_UInt next;
FT_Int count;
FT_UInt count;
next = mask->end_point > glyph->num_points
? glyph->num_points
: mask->end_point;
next = FT_MIN( mask->end_point, glyph->num_points );
count = next - first;
if ( count > 0 )
{

View File

@ -240,7 +240,7 @@
FT_Int family )
{
PSH_Blue_Table top_table, bot_table;
FT_Int count_top, count_bot;
FT_UInt count_top, count_bot;
if ( family )

View File

@ -167,12 +167,12 @@
/* clear a given bit */
static void
ps_mask_clear_bit( PS_Mask mask,
FT_Int idx )
FT_UInt idx )
{
FT_Byte* p;
if ( (FT_UInt)idx >= mask->num_bits )
if ( idx >= mask->num_bits )
return;
p = mask->bytes + ( idx >> 3 );
@ -183,17 +183,14 @@
/* set a given bit, possibly grow the mask */
static FT_Error
ps_mask_set_bit( PS_Mask mask,
FT_Int idx,
FT_UInt idx,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_Byte* p;
if ( idx < 0 )
goto Exit;
if ( (FT_UInt)idx >= mask->num_bits )
if ( idx >= mask->num_bits )
{
error = ps_mask_ensure( mask, idx + 1, memory );
if ( error )
@ -372,8 +369,8 @@
/* test whether two masks in a table intersect */
static FT_Int
ps_mask_table_test_intersect( PS_Mask_Table table,
FT_Int index1,
FT_Int index2 )
FT_UInt index1,
FT_UInt index2 )
{
PS_Mask mask1 = table->masks + index1;
PS_Mask mask2 = table->masks + index2;
@ -404,23 +401,25 @@
/* merge two masks, used by ps_mask_table_merge_all */
static FT_Error
ps_mask_table_merge( PS_Mask_Table table,
FT_Int index1,
FT_Int index2,
FT_UInt index1,
FT_UInt index2,
FT_Memory memory )
{
FT_UInt temp;
FT_Error error = FT_Err_Ok;
/* swap index1 and index2 so that index1 < index2 */
if ( index1 > index2 )
{
FT_UInt temp;
temp = index1;
index1 = index2;
index2 = temp;
}
if ( index1 < index2 && index1 >= 0 && index2 < (FT_Int)table->num_masks )
if ( index1 < index2 && index2 < table->num_masks )
{
/* we need to merge the bitsets of index1 and index2 with a */
/* simple union */
@ -453,7 +452,7 @@
/* merge (unite) the bitsets */
read = mask2->bytes;
write = mask1->bytes;
pos = (FT_UInt)( ( count2 + 7 ) >> 3 );
pos = ( count2 + 7 ) >> 3;
for ( ; pos > 0; pos-- )
{
@ -468,14 +467,17 @@
mask2->num_bits = 0;
mask2->end_point = 0;
delta = table->num_masks - 1 - index2; /* number of masks to move */
/* number of masks to move */
delta = (FT_Int)( table->num_masks - 1 - index2 );
if ( delta > 0 )
{
/* move to end of table for reuse */
PS_MaskRec dummy = *mask2;
ft_memmove( mask2, mask2 + 1, delta * sizeof ( PS_MaskRec ) );
ft_memmove( mask2,
mask2 + 1,
(FT_UInt)delta * sizeof ( PS_MaskRec ) );
mask2[delta] = dummy;
}
@ -502,13 +504,19 @@
FT_Error error = FT_Err_Ok;
for ( index1 = table->num_masks - 1; index1 > 0; index1-- )
/* both loops go down to 0, thus FT_Int for index1 and index2 */
for ( index1 = (FT_Int)table->num_masks - 1; index1 > 0; index1-- )
{
for ( index2 = index1 - 1; index2 >= 0; index2-- )
{
if ( ps_mask_table_test_intersect( table, index1, index2 ) )
if ( ps_mask_table_test_intersect( table,
(FT_UInt)index1,
(FT_UInt)index2 ) )
{
error = ps_mask_table_merge( table, index2, index1, memory );
error = ps_mask_table_merge( table,
(FT_UInt)index2,
(FT_UInt)index1,
memory );
if ( error )
goto Exit;
@ -670,8 +678,8 @@
{
PS_Mask mask;
FT_UInt idx;
FT_UInt max = dim->hints.num_hints;
PS_Hint hint = dim->hints.hints;
FT_UInt max = dim->hints.num_hints;
PS_Hint hint = dim->hints.hints;
for ( idx = 0; idx < max; idx++, hint++ )
@ -742,17 +750,26 @@
}
/* now, set the bits for our hints in the counter mask */
error = ps_mask_set_bit( counter, hint1, memory );
if ( error )
goto Exit;
if ( hint1 >= 0 )
{
error = ps_mask_set_bit( counter, (FT_UInt)hint1, memory );
if ( error )
goto Exit;
}
error = ps_mask_set_bit( counter, hint2, memory );
if ( error )
goto Exit;
if ( hint2 >= 0 )
{
error = ps_mask_set_bit( counter, (FT_UInt)hint2, memory );
if ( error )
goto Exit;
}
error = ps_mask_set_bit( counter, hint3, memory );
if ( error )
goto Exit;
if ( hint3 >= 0 )
{
error = ps_mask_set_bit( counter, (FT_UInt)hint3, memory );
if ( error )
goto Exit;
}
Exit:
return error;