[cff, pshinter] Clean up unsigned counters.
Loops with unsigned decrement can be reliably stopped when the counter wraps around after reaching zero. * src/cff/cffload.c (cff_charset_compute_cids): Use unsigned counter. * src/pshinter/pshalgo.c (psh_hint_table_activate_mask): Ditto. * src/pshinter/pshrec.c (ps_mask_table_merge): Ditto.
This commit is contained in:
parent
058f3f2d7d
commit
731d0b6856
|
@ -835,7 +835,6 @@
|
||||||
{
|
{
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
FT_UInt i;
|
FT_UInt i;
|
||||||
FT_Long j;
|
|
||||||
FT_UShort max_cid = 0;
|
FT_UShort max_cid = 0;
|
||||||
|
|
||||||
|
|
||||||
|
@ -853,9 +852,10 @@
|
||||||
|
|
||||||
/* When multiple GIDs map to the same CID, we choose the lowest */
|
/* When multiple GIDs map to the same CID, we choose the lowest */
|
||||||
/* GID. This is not described in any spec, but it matches the */
|
/* GID. This is not described in any spec, but it matches the */
|
||||||
/* behaviour of recent Acroread versions. */
|
/* behaviour of recent Acroread versions. The loop stops when */
|
||||||
for ( j = (FT_Long)num_glyphs - 1; j >= 0; j-- )
|
/* the unsigned index wraps around after reaching zero. */
|
||||||
charset->cids[charset->sids[j]] = (FT_UShort)j;
|
for ( i = num_glyphs - 1; i < num_glyphs; i-- )
|
||||||
|
charset->cids[charset->sids[i]] = (FT_UShort)i;
|
||||||
|
|
||||||
charset->max_cid = max_cid;
|
charset->max_cid = max_cid;
|
||||||
charset->num_glyphs = num_glyphs;
|
charset->num_glyphs = num_glyphs;
|
||||||
|
|
|
@ -305,17 +305,18 @@
|
||||||
/* now, sort the hints; they are guaranteed to not overlap */
|
/* now, sort the hints; they are guaranteed to not overlap */
|
||||||
/* so we can compare their "org_pos" field directly */
|
/* so we can compare their "org_pos" field directly */
|
||||||
{
|
{
|
||||||
FT_Int i1, i2;
|
FT_UInt i1, i2;
|
||||||
PSH_Hint hint1, hint2;
|
PSH_Hint hint1, hint2;
|
||||||
PSH_Hint* sort = table->sort;
|
PSH_Hint* sort = table->sort;
|
||||||
|
|
||||||
|
|
||||||
/* a simple bubble sort will do, since in 99% of cases, the hints */
|
/* a simple bubble sort will do, since in 99% of cases, the hints */
|
||||||
/* will be already sorted -- and the sort will be linear */
|
/* will be already sorted -- and the sort will be linear */
|
||||||
for ( i1 = 1; i1 < (FT_Int)count; i1++ )
|
for ( i1 = 1; i1 < count; i1++ )
|
||||||
{
|
{
|
||||||
hint1 = sort[i1];
|
hint1 = sort[i1];
|
||||||
for ( i2 = i1 - 1; i2 >= 0; i2-- )
|
/* this loop stops when i2 wraps around after reaching 0 */
|
||||||
|
for ( i2 = i1 - 1; i2 < i1; i2-- )
|
||||||
{
|
{
|
||||||
hint2 = sort[i2];
|
hint2 = sort[i2];
|
||||||
|
|
||||||
|
|
|
@ -499,23 +499,19 @@
|
||||||
ps_mask_table_merge_all( PS_Mask_Table table,
|
ps_mask_table_merge_all( PS_Mask_Table table,
|
||||||
FT_Memory memory )
|
FT_Memory memory )
|
||||||
{
|
{
|
||||||
FT_Int index1, index2;
|
FT_UInt index1, index2;
|
||||||
FT_Error error = FT_Err_Ok;
|
FT_Error error = FT_Err_Ok;
|
||||||
|
|
||||||
|
|
||||||
/* both loops go down to 0, thus FT_Int for index1 and index2 */
|
/* the inner loop stops when the unsigned index wraps around */
|
||||||
for ( index1 = (FT_Int)table->num_masks - 1; index1 > 0; index1-- )
|
/* after reaching 0. */
|
||||||
|
for ( index1 = table->num_masks - 1; index1 > 0; index1-- )
|
||||||
{
|
{
|
||||||
for ( index2 = index1 - 1; index2 >= 0; index2-- )
|
for ( index2 = index1 - 1; index2 < index1; index2-- )
|
||||||
{
|
{
|
||||||
if ( ps_mask_table_test_intersect( table,
|
if ( ps_mask_table_test_intersect( table, index1, index2 ) )
|
||||||
(FT_UInt)index1,
|
|
||||||
(FT_UInt)index2 ) )
|
|
||||||
{
|
{
|
||||||
error = ps_mask_table_merge( table,
|
error = ps_mask_table_merge( table, index2, index1, memory );
|
||||||
(FT_UInt)index2,
|
|
||||||
(FT_UInt)index1,
|
|
||||||
memory );
|
|
||||||
if ( error )
|
if ( error )
|
||||||
goto Exit;
|
goto Exit;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue