Commit 914b289f1623b1030b66537d3b3ce4b652e4606c

Werner Lemberg 2001-03-10T17:07:42

* src/*/*.c: Added many casts to make code more 64bit-safe.

diff --git a/ChangeLog b/ChangeLog
index caaf9ca..c80c152 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2001-03-10  Henrik Grubbström <grubba@roxen.com>
+
+	* src/*/*.c: Added many casts to make code more 64bit-safe.
+
 2001-03-07  Werner Lemberg  <wl@gnu.org>
 
 	* INSTALL, docs/BUILD: We need GNU make 3.78 or newer.
diff --git a/src/autohint/ahglobal.c b/src/autohint/ahglobal.c
index 63aab22..58c8122 100644
--- a/src/autohint/ahglobal.c
+++ b/src/autohint/ahglobal.c
@@ -157,7 +157,7 @@
         /* segment; we first need to find in which contour the extremum */
         /* lies, then see its previous and next points                  */
         {
-          FT_Int  index = extremum - points;
+          FT_Int  index = (FT_Int)( extremum - points );
           FT_Int  n;
           FT_Int  first, last, prev, next, end;
           FT_Pos  dist;
diff --git a/src/autohint/ahglyph.c b/src/autohint/ahglyph.c
index 9c6ebfd..1752dc7 100644
--- a/src/autohint/ahglyph.c
+++ b/src/autohint/ahglyph.c
@@ -1109,7 +1109,7 @@
         }
       }
 
-      *p_num_edges = edge_limit - edges;
+      *p_num_edges = (FT_Int)( edge_limit - edges );
 
 
       /*********************************************************************/
diff --git a/src/cache/ftcchunk.c b/src/cache/ftcchunk.c
index ec283b2..f7bb541 100644
--- a/src/cache/ftcchunk.c
+++ b/src/cache/ftcchunk.c
@@ -300,7 +300,7 @@
     if ( !error )
     {
       /* good, now set the set index within the set object */
-      cset->cset_index = node - lru->nodes;
+      cset->cset_index = (FT_UInt)( node - lru->nodes );
       node->root.data  = cset;
     }
 
diff --git a/src/cache/ftcglyph.c b/src/cache/ftcglyph.c
index cc9a6d8..40633e6 100644
--- a/src/cache/ftcglyph.c
+++ b/src/cache/ftcglyph.c
@@ -327,7 +327,7 @@
     if ( !error )
     {
       /* good, now set the gset index within the gset object */
-      gset->gset_index = node - lru->nodes;
+      gset->gset_index = (FT_UInt)( node - lru->nodes );
       node->root.data  = gset;
     }
 
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 77abcee..057bead 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -332,7 +332,7 @@
           while ( cur2 < limit && is_alpha( *cur2 ) )
             cur2++;
 
-          len = cur2 - cur;
+          len = (FT_Int)( cur2 - cur );
           if ( len > 0 && len < 22 )
           {
             /* now compare the immediate name to the keyword table */
diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c
index 31aeb87..c8cff5e 100644
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -109,7 +109,7 @@
         if ( p[0] == 'S' && strncmp( (char*)p, "StartData", 9 ) == 0 )
         {
           /* save offset of binary data after `StartData' */
-          offset = top_position - ( limit - p ) + 10;
+          offset = (FT_ULong)( top_position - ( limit - p ) + 10 );
           goto Found;
         }
       }
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index 3759d99..7546261 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -84,7 +84,7 @@
   void  shift_elements( PS_Table*  table,
                         FT_Byte*   old_base )
   {
-    FT_Long    delta  = table->block - old_base;
+    FT_Long    delta  = (FT_Long)( table->block - old_base );
     FT_Byte**  offset = table->elements;
     FT_Byte**  limit  = offset + table->max_elems;
 
@@ -412,7 +412,7 @@
         cur++;
       }
 
-      *pnum_tokens = cur - tokens;
+      *pnum_tokens = (FT_Int)( cur - tokens );
 
       parser->cursor = old_cursor;
       parser->limit  = old_limit;
@@ -847,7 +847,7 @@
       case t1_field_string:
         {
           FT_Memory  memory = parser->memory;
-          FT_UInt    len    = limit-cur;
+          FT_UInt    len    = (FT_UInt)( limit - cur );
 
 
           if ( *(FT_String**)q )
diff --git a/src/psnames/psmodule.c b/src/psnames/psmodule.c
index 1de46c6..2160c5d 100644
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -100,7 +100,7 @@
       while ( *p && *p != '.' )
         p++;
 
-      len = p - glyph_name;
+      len = (int)( p - glyph_name );
 
       if ( *p && len < 64 )
       {
@@ -181,7 +181,7 @@
       }
 
       /* now, compress the table a bit */
-      count = map - table->maps;
+      count = (FT_UInt)( map - table->maps );
 
       if ( count > 0 && REALLOC( table->maps,
                                  num_glyphs * sizeof ( PS_UniMap ),
diff --git a/src/raster/ftraster.c b/src/raster/ftraster.c
index 92e8b5b..993fd11 100644
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -620,7 +620,7 @@
     PProfile  oldProfile;
 
 
-    h = ras.top - ras.cProfile->offset;
+    h = (Long)( ras.top - ras.cProfile->offset );
 
     if ( h < 0 )
     {
@@ -1102,7 +1102,7 @@
     else
     {
       e  = CEILING( y1 );
-      f1 = FRAC( y1 );
+      f1 = (Short)( FRAC( y1 ) );
       e0 = e;
 
       if ( f1 == 0 )
@@ -2189,7 +2189,7 @@
           e1 = TRUNC( e1 );
 
           c1 = (Short)( e1 >> 3 );
-          f1 = e1 &  7;
+          f1 = (Short)( e1 &  7 );
 
           if ( e1 >= 0 && e1 < ras.bWidth                      &&
                ras.bTarget[ras.traceOfs + c1] & ( 0x80 >> f1 ) )
@@ -2215,7 +2215,7 @@
     if ( e1 >= 0 && e1 < ras.bWidth )
     {
       c1 = (Short)( e1 >> 3 );
-      f1 = e1 & 7;
+      f1 = (Short)( e1 & 7 );
 
       if ( ras.gray_min_x > c1 ) ras.gray_min_x = c1;
       if ( ras.gray_max_x < c1 ) ras.gray_max_x = c1;
@@ -2677,7 +2677,7 @@
       Q = P->link;
 
       bottom = (Short)P->start;
-      top    = (Short)P->start + P->height - 1;
+      top    = (Short)( P->start + P->height - 1 );
 
       if ( min_Y > bottom ) min_Y = bottom;
       if ( max_Y < top    ) max_Y = top;
@@ -2705,7 +2705,7 @@
 
     while ( P )
     {
-      P->countL = P->start - min_Y;
+      P->countL = (UShort)( P->start - min_Y );
       P = P->link;
     }
 
diff --git a/src/sfnt/sfdriver.c b/src/sfnt/sfdriver.c
index 203115d..de30fbb 100644
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -97,7 +97,7 @@
     error = TT_Get_PS_Name( face, glyph_index, &gname );
     if ( !error && buffer_max > 0 )
     {
-      FT_UInt  len = strlen( gname );
+      FT_UInt  len = (FT_UInt)( strlen( gname ) );
 
 
       if ( len >= buffer_max )
diff --git a/src/sfnt/ttcmap.c b/src/sfnt/ttcmap.c
index 9698a80..2f2a53a 100644
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -493,10 +493,10 @@
     else
     {
       /* otherwise, we must use the glyphIdArray to do it */
-      index1 = seg4->idRangeOffset / 2
-               + ( charCode - seg4->startCount )
-               + ( seg4 - cmap4->segments )
-               - segCount;
+      index1 = (FT_UInt)( seg4->idRangeOffset / 2
+                          + ( charCode - seg4->startCount )
+                          + ( seg4 - cmap4->segments )
+                          - segCount );
 
       if ( index1 < (FT_UInt)cmap4->numGlyphId       &&
            cmap4->glyphIdArray[index1] != 0 )
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 291e62e..83eb17e 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -1037,7 +1037,7 @@
 
     for (;;)
     {
-      int    len = limit - base;
+      int    len = (int)( limit - base );
       PCell  i, j, pivot;
 
 
diff --git a/src/truetype/ttgload.c b/src/truetype/ttgload.c
index 8e56030..1464a8a 100644
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -494,7 +494,8 @@
       /* composite instructions, if we find some.               */
       /* we will process them later...                          */
       /*                                                        */
-      loader->ins_pos = FILE_Pos() + stream->cursor - stream->limit;
+      loader->ins_pos = (FT_ULong)( FILE_Pos() +
+                                    stream->cursor - stream->limit );
     }
 #endif
 
diff --git a/src/type1/t1afm.c b/src/type1/t1afm.c
index 970bc64..5f0457d 100644
--- a/src/type1/t1afm.c
+++ b/src/type1/t1afm.c
@@ -74,7 +74,7 @@
     while ( IS_ALPHANUM( *p ) && p < limit )
       p++;
 
-    len = p - *start;
+    len = (FT_Int)( p - *start );
 
     if ( len > 0 && len < 64 )
     {
diff --git a/src/type1/t1driver.c b/src/type1/t1driver.c
index e933e88..b3a6c6c 100644
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -55,7 +55,7 @@
 
     if ( buffer_max > 0 )
     {
-      FT_UInt  len = strlen( gname );
+      FT_UInt  len = (FT_UInt)( strlen( gname ) );
 
 
       if (len >= buffer_max)
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index e4187c9..bf70557 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -420,7 +420,7 @@
       if (token->start[0] == '/')
         token->start++;
 
-      len = token->limit - token->start;
+      len = (FT_Int)( token->limit - token->start );
       if ( len <= 0 )
       {
         error = T1_Err_Invalid_File_Format;
@@ -838,7 +838,7 @@
     while ( cur2 < limit && is_alpha( *cur2 ) )
       cur2++;
 
-    len = cur2 - cur;
+    len = (FT_Int)( cur2 - cur );
     if ( len > 0 )
     {
       if ( ALLOC( face->type1.font_name, len + 1 ) )
@@ -1039,7 +1039,7 @@
             while ( cur2 < limit && is_alpha( *cur2 ) )
               cur2++;
 
-            len = cur2 - cur - 1;
+            len = (FT_Int)( cur2 - cur - 1 );
 
             parser->root.error = T1_Add_Table( char_table, charcode,
                                           cur + 1, len + 1 );
@@ -1244,7 +1244,7 @@
 
         while ( cur2 < limit && is_alpha( *cur2 ) )
           cur2++;
-        len = cur2 - cur - 1;
+        len = (FT_Int)( cur2 - cur - 1 );
 
         error = T1_Add_Table( name_table, n, cur + 1, len + 1 );
         if ( error )
@@ -1467,7 +1467,7 @@
           while ( cur2 < limit && is_alpha( *cur2 ) )
             cur2++;
 
-          len  = cur2 - cur;
+          len  = (FT_Int)( cur2 - cur );
           if ( len > 0 && len < 22 )
           {
             {
diff --git a/src/type1/t1parse.c b/src/type1/t1parse.c
index 39d305c..4d9a767 100644
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -377,7 +377,7 @@
       /* dictionary.  We overwrite the base dictionary for disk-based */
       /* resources and allocate a new block otherwise                 */
 
-      size = parser->base_len - ( cur - parser->base_dict);
+      size = (FT_Long)( parser->base_len - ( cur - parser->base_dict ) );
 
       if ( parser->in_memory )
       {
@@ -440,7 +440,7 @@
         }
 
         /* put a safeguard */
-        parser->private_len = write - parser->private_dict;
+        parser->private_len = (FT_Int)( write - parser->private_dict );
         *write++ = 0;
       }
     }
diff --git a/src/winfonts/winfnt.c b/src/winfonts/winfnt.c
index d1d5326..1097486 100644
--- a/src/winfonts/winfnt.c
+++ b/src/winfonts/winfnt.c
@@ -242,7 +242,8 @@
           if ( type_id == 0x8008 )
           {
             font_count  = count;
-            font_offset = FILE_Pos() + 4 + ( stream->cursor - stream->limit );
+            font_offset = (FT_ULong)( FILE_Pos() + 4 +
+                                      ( stream->cursor - stream->limit ) );
             break;
           }