shithub: freetype+ttf2subf

Download patch

ref: badf317840acc5c6224318e447d1d3d30a1f4460
parent: c378249e58ce329f9a79522b7a272c6327894f89
author: Werner Lemberg <[email protected]>
date: Thu Jun 6 05:16:38 EDT 2013

Next round of compiler fixes.

* builds/win32/ftdebug.c, builds/wince/ftdebug.c (ft_debug_init):
Add proper cast.

* include/freetype/internal/ftserv.h (FT_SERVICE_UNAVAILABLE): Fix
cast.
* include/freetype/internal/ftstream.h: Decorate stream and frame
macros with `FT_Long' and `FT_ULong' as appropriate.

* src/base/ftrfork.c (raccess_guess_darwin_hfsplus,
raccess_guess_darwin_newvfs): Use cast.

* src/bdf/bdflib.c (_bdf_set_default_spacing): Use cast.

* src/cache/ftcmanag.c (FTC_Manager_Check): Fix cast.
* src/cache/ftcmanag.h (FTC_ManagerRec): Ditto.

* src/cff/cf2arrst.c (cf2_arrstack_setNum_Elements): Use cast.
* src/cff/cf2ft.c (cf2_freeSeacComponent): Ditto.
* src/cff/cffobjs.c (remove_subset_prefix, remove_style): Ditto.

* src/cid/cidparse.c (cid_parser_new): Use cast.

* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Use cast.

* src/psaux/psobjs.c (reallocate_t1_table): Fix argument type.

* src/raster/ftraster.c (ft_black_reset): Use cast.

* src/truetype/ttgxvar.c (FT_Stream_FTell): Use cast.
(ALL_POINTS): Fix cast.

* src/type1/t1driver.c (t1_ps_get_font_value): Add casts.
* src/type1/t1parse.c (T1_Get_Private_Dict): Add cast.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,41 @@
+2013-06-06  Werner Lemberg  <[email protected]>
+
+	Next round of compiler fixes.
+
+	* builds/win32/ftdebug.c, builds/wince/ftdebug.c (ft_debug_init):
+	Add proper cast.
+
+	* include/freetype/internal/ftserv.h (FT_SERVICE_UNAVAILABLE): Fix
+	cast.
+	* include/freetype/internal/ftstream.h: Decorate stream and frame
+	macros with `FT_Long' and `FT_ULong' as appropriate.
+
+	* src/base/ftrfork.c (raccess_guess_darwin_hfsplus,
+	raccess_guess_darwin_newvfs): Use cast.
+
+	* src/bdf/bdflib.c (_bdf_set_default_spacing): Use cast.
+
+	* src/cache/ftcmanag.c (FTC_Manager_Check): Fix cast.
+	* src/cache/ftcmanag.h (FTC_ManagerRec): Ditto.
+
+	* src/cff/cf2arrst.c (cf2_arrstack_setNum_Elements): Use cast.
+	* src/cff/cf2ft.c (cf2_freeSeacComponent): Ditto.
+	* src/cff/cffobjs.c (remove_subset_prefix, remove_style): Ditto.
+
+	* src/cid/cidparse.c (cid_parser_new): Use cast.
+
+	* src/pcf/pcfdrivr.c (PCF_Glyph_Load): Use cast.
+
+	* src/psaux/psobjs.c (reallocate_t1_table): Fix argument type.
+
+	* src/raster/ftraster.c (ft_black_reset): Use cast.
+
+	* src/truetype/ttgxvar.c (FT_Stream_FTell): Use cast.
+	(ALL_POINTS): Fix cast.
+
+	* src/type1/t1driver.c (t1_ps_get_font_value): Add casts.
+	* src/type1/t1parse.c (T1_Get_Private_Dict): Add cast.
+
 2013-06-05  Dave Arnold  <[email protected]>
 
 	Fix more MSVC Win32 compiler warnings.
--- a/builds/win32/ftdebug.c
+++ b/builds/win32/ftdebug.c
@@ -171,7 +171,7 @@
 
         if ( *p == ':' && p > q )
         {
-          int  n, i, len = p - q;
+          int  n, i, len = (int)( p - q );
           int  level = -1, found = -1;
 
 
--- a/builds/wince/ftdebug.c
+++ b/builds/wince/ftdebug.c
@@ -189,7 +189,7 @@
 
         if ( *p == ':' && p > q )
         {
-          int  n, i, len = p - q;
+          int  n, i, len = (int)( p - q );
           int  level = -1, found = -1;
 
 
--- a/include/freetype/internal/ftserv.h
+++ b/include/freetype/internal/ftserv.h
@@ -653,7 +653,9 @@
   /*
    *  A magic number used within the services cache.
    */
-#define FT_SERVICE_UNAVAILABLE  ((FT_Pointer)~1)  /* magic number */
+
+  /* ensure that value `1' has the same width as a pointer */
+#define FT_SERVICE_UNAVAILABLE  ((FT_Pointer)~(FT_PtrDist)1)
 
 
   /*
--- a/include/freetype/internal/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -486,37 +486,41 @@
 #define FT_STREAM_POS()           \
           FT_Stream_Pos( stream )
 
-#define FT_STREAM_SEEK( position )                           \
-          FT_SET_ERROR( FT_Stream_Seek( stream, position ) )
+#define FT_STREAM_SEEK( position )                               \
+          FT_SET_ERROR( FT_Stream_Seek( stream,                  \
+                                        (FT_ULong)(position) ) )
 
-#define FT_STREAM_SKIP( distance )                           \
-          FT_SET_ERROR( FT_Stream_Skip( stream, distance ) )
+#define FT_STREAM_SKIP( distance )                              \
+          FT_SET_ERROR( FT_Stream_Skip( stream,                 \
+                                        (FT_Long)(distance) ) )
 
-#define FT_STREAM_READ( buffer, count )                   \
-          FT_SET_ERROR( FT_Stream_Read( stream,           \
-                                        (FT_Byte*)buffer, \
-                                        count ) )
+#define FT_STREAM_READ( buffer, count )                       \
+          FT_SET_ERROR( FT_Stream_Read( stream,               \
+                                        (FT_Byte*)(buffer),   \
+                                        (FT_ULong)(count) ) )
 
-#define FT_STREAM_READ_AT( position, buffer, count )         \
-          FT_SET_ERROR( FT_Stream_ReadAt( stream,            \
-                                           position,         \
-                                           (FT_Byte*)buffer, \
-                                           count ) )
+#define FT_STREAM_READ_AT( position, buffer, count )            \
+          FT_SET_ERROR( FT_Stream_ReadAt( stream,               \
+                                          (FT_ULong)(position), \
+                                          (FT_Byte*)buffer,     \
+                                          (FT_ULong)(count) ) )
 
 #define FT_STREAM_READ_FIELDS( fields, object )                          \
           FT_SET_ERROR( FT_Stream_ReadFields( stream, fields, object ) )
 
 
-#define FT_FRAME_ENTER( size )                                       \
-          FT_SET_ERROR(                                              \
-            FT_DEBUG_INNER( FT_Stream_EnterFrame( stream, size ) ) )
+#define FT_FRAME_ENTER( size )                                           \
+          FT_SET_ERROR(                                                  \
+            FT_DEBUG_INNER( FT_Stream_EnterFrame( stream,                \
+                                                  (FT_ULong)(size) ) ) )
 
-#define FT_FRAME_EXIT()                 \
+#define FT_FRAME_EXIT()                                   \
           FT_DEBUG_INNER( FT_Stream_ExitFrame( stream ) )
 
 #define FT_FRAME_EXTRACT( size, bytes )                                       \
           FT_SET_ERROR(                                                       \
-            FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream, size,             \
+            FT_DEBUG_INNER( FT_Stream_ExtractFrame( stream,                   \
+                                                    (FT_ULong)(size),         \
                                                     (FT_Byte**)&(bytes) ) ) )
 
 #define FT_FRAME_RELEASE( bytes )                                         \
--- a/src/base/ftrfork.c
+++ b/src/base/ftrfork.c
@@ -507,7 +507,7 @@
     FT_Error   error;
     char*      newpath = NULL;
     FT_Memory  memory;
-    FT_Long    base_file_len = ft_strlen( base_file_name );
+    FT_Long    base_file_len = (FT_Long)ft_strlen( base_file_name );
 
     FT_UNUSED( stream );
 
@@ -543,7 +543,7 @@
     FT_Error   error;
     char*      newpath = NULL;
     FT_Memory  memory;
-    FT_Long    base_file_len = ft_strlen( base_file_name );
+    FT_Long    base_file_len = (FT_Long)ft_strlen( base_file_name );
 
     FT_UNUSED( stream );
 
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -1196,7 +1196,7 @@
 
     FT_MEM_COPY( name, font->name, len );
 
-    error = _bdf_list_split( &list, (char *)"-", name, len );
+    error = _bdf_list_split( &list, (char *)"-", name, (unsigned long)len );
     if ( error )
       goto Fail;
 
--- a/src/cache/ftcmanag.c
+++ b/src/cache/ftcmanag.c
@@ -473,7 +473,7 @@
     /* check node weights */
     if ( first )
     {
-      FT_ULong  weight = 0;
+      FT_Offset  weight = 0;
 
 
       node = first;
--- a/src/cache/ftcmanag.h
+++ b/src/cache/ftcmanag.h
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType Cache Manager (specification).                              */
 /*                                                                         */
-/*  Copyright 2000-2001, 2003, 2004, 2006, 2010 by                         */
+/*  Copyright 2000-2001, 2003, 2004, 2006, 2010, 2013 by                   */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -94,8 +94,8 @@
     FT_Memory           memory;
 
     FTC_Node            nodes_list;
-    FT_ULong            max_weight;
-    FT_ULong            cur_weight;
+    FT_Offset           max_weight;
+    FT_Offset           cur_weight;
     FT_UInt             num_nodes;
 
     FTC_Cache           caches[FTC_MAX_CACHES];
--- a/src/cff/cf2arrst.c
+++ b/src/cff/cf2arrst.c
@@ -101,7 +101,7 @@
       FT_Error   error  = FT_Err_Ok;        /* for FT_REALLOC */
       FT_Memory  memory = arrstack->memory; /* for FT_REALLOC */
 
-      FT_Long  newSize = numElements * arrstack->sizeItem;
+      FT_Long  newSize = (FT_Long)( numElements * arrstack->sizeItem );
 
 
       if ( numElements > LONG_MAX / arrstack->sizeItem )
--- a/src/cff/cf2ft.c
+++ b/src/cff/cf2ft.c
@@ -563,7 +563,7 @@
 
     cff_free_glyph_data( decoder->builder.face,
                          (FT_Byte**)&buf->start,
-                         buf->end - buf->start );
+                         (FT_ULong)( buf->end - buf->start ) );
   }
 
 
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -405,7 +405,7 @@
   remove_subset_prefix( FT_String*  name )
   {
     FT_Int32  idx             = 0;
-    FT_Int32  length          = strlen( name ) + 1;
+    FT_Int32  length          = (FT_Int32)strlen( name ) + 1;
     FT_Bool   continue_search = 1;
 
 
@@ -442,8 +442,8 @@
     FT_Int32  family_name_length, style_name_length;
 
 
-    family_name_length = strlen( family_name );
-    style_name_length  = strlen( style_name );
+    family_name_length = (FT_Int32)strlen( family_name );
+    style_name_length  = (FT_Int32)strlen( style_name );
 
     if ( family_name_length > style_name_length )
     {
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -117,12 +117,12 @@
           if ( p[0] == 'S' && ft_strncmp( (char*)p, "StartData", 9 ) == 0 )
           {
             /* save offset of binary data after `StartData' */
-            offset += p - buffer + 10;
+            offset += (FT_ULong)( p - buffer + 10 );
             goto Found;
           }
           else if ( p[1] == 's' && ft_strncmp( (char*)p, "/sfnts", 6 ) == 0 )
           {
-            offset += p - buffer + 7;
+            offset += (FT_ULong)( p - buffer + 7 );
             goto Found;
           }
         }
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -532,7 +532,7 @@
     /* XXX: to do: are there cases that need repadding the bitmap? */
     bytes = bitmap->pitch * bitmap->rows;
 
-    error = ft_glyphslot_alloc_bitmap( slot, bytes );
+    error = ft_glyphslot_alloc_bitmap( slot, (FT_ULong)bytes );
     if ( error )
       goto Exit;
 
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -113,8 +113,8 @@
 
 
   static FT_Error
-  reallocate_t1_table( PS_Table  table,
-                       FT_Long   new_size )
+  reallocate_t1_table( PS_Table   table,
+                       FT_Offset  new_size )
   {
     FT_Memory  memory   = table->memory;
     FT_Byte*   old_base = table->block;
--- a/src/raster/ftraster.c
+++ b/src/raster/ftraster.c
@@ -3523,7 +3523,8 @@
 
 
         raster->buffer      = pool_base + ( ( sizeof ( *worker ) + 7 ) & ~7 );
-        raster->buffer_size = pool_base + pool_size - (char*)raster->buffer;
+        raster->buffer_size = (long)( pool_base + pool_size -
+                                        (char*)raster->buffer );
         raster->worker      = worker;
       }
       else
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -61,9 +61,9 @@
 
 
 #define FT_Stream_FTell( stream )  \
-          ( (stream)->cursor - (stream)->base )
+          (FT_ULong)( (stream)->cursor - (stream)->base )
 #define FT_Stream_SeekSet( stream, off ) \
-              ( (stream)->cursor = (stream)->base+(off) )
+          ( (stream)->cursor = (stream)->base + (off) )
 
 
   /*************************************************************************/
@@ -91,7 +91,9 @@
   /* indicates that there is a delta for every point without needing to    */
   /* enumerate all of them.                                                */
   /*                                                                       */
-#define ALL_POINTS  (FT_UShort*)( ~0 )
+
+  /* ensure that value `0' has the same width as a pointer */
+#define ALL_POINTS  (FT_UShort*)~(FT_PtrDist)0
 
 
 #define GX_PT_POINTS_ARE_WORDS      0x80
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -258,7 +258,7 @@
       break;
 
     case PS_DICT_FONT_NAME:
-      retval = ft_strlen( type1->font_name ) + 1;
+      retval = (FT_Long)( ft_strlen( type1->font_name ) + 1 );
       if ( value && value_len >= retval )
         ft_memcpy( value, (void *)( type1->font_name ), retval );
       break;
@@ -278,7 +278,7 @@
     case PS_DICT_CHAR_STRING_KEY:
       if ( idx < (FT_UInt)type1->num_glyphs )
       {
-        retval = ft_strlen( type1->glyph_names[idx] ) + 1;
+        retval = (FT_Long)( ft_strlen( type1->glyph_names[idx] ) + 1 );
         if ( value && value_len >= retval )
         {
           ft_memcpy( value, (void *)( type1->glyph_names[idx] ), retval );
@@ -290,7 +290,7 @@
     case PS_DICT_CHAR_STRING:
       if ( idx < (FT_UInt)type1->num_glyphs )
       {
-        retval = type1->charstrings_len[idx] + 1;
+        retval = (FT_Long)( type1->charstrings_len[idx] + 1 );
         if ( value && value_len >= retval )
         {
           ft_memcpy( value, (void *)( type1->charstrings[idx] ),
@@ -310,7 +310,7 @@
       if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY &&
            idx < (FT_UInt)type1->encoding.num_chars       )
       {
-        retval = ft_strlen( type1->encoding.char_name[idx] ) + 1;
+        retval = (FT_Long)( ft_strlen( type1->encoding.char_name[idx] ) + 1 );
         if ( value && value_len >= retval )
         {
           ft_memcpy( value, (void *)( type1->encoding.char_name[idx] ),
@@ -329,7 +329,7 @@
     case PS_DICT_SUBR:
       if ( idx < (FT_UInt)type1->num_subrs )
       {
-        retval = type1->subrs_len[idx] + 1;
+        retval = (FT_Long)( type1->subrs_len[idx] + 1 );
         if ( value && value_len >= retval )
         {
           ft_memcpy( value, (void *)( type1->subrs[idx] ), retval - 1 );
@@ -523,31 +523,31 @@
       break;
 
     case PS_DICT_VERSION:
-      retval = ft_strlen( type1->font_info.version ) + 1;
+      retval = (FT_Long)( ft_strlen( type1->font_info.version ) + 1 );
       if ( value && value_len >= retval )
         ft_memcpy( value, (void *)( type1->font_info.version ), retval );
       break;
 
     case PS_DICT_NOTICE:
-      retval = ft_strlen( type1->font_info.notice ) + 1;
+      retval = (FT_Long)( ft_strlen( type1->font_info.notice ) + 1 );
       if ( value && value_len >= retval )
         ft_memcpy( value, (void *)( type1->font_info.notice ), retval );
       break;
 
     case PS_DICT_FULL_NAME:
-      retval = ft_strlen( type1->font_info.full_name ) + 1;
+      retval = (FT_Long)( ft_strlen( type1->font_info.full_name ) + 1 );
       if ( value && value_len >= retval )
         ft_memcpy( value, (void *)( type1->font_info.full_name ), retval );
       break;
 
     case PS_DICT_FAMILY_NAME:
-      retval = ft_strlen( type1->font_info.family_name ) + 1;
+      retval = (FT_Long)( ft_strlen( type1->font_info.family_name ) + 1 );
       if ( value && value_len >= retval )
         ft_memcpy( value, (void *)( type1->font_info.family_name ), retval );
       break;
 
     case PS_DICT_WEIGHT:
-      retval = ft_strlen( type1->font_info.weight ) + 1;
+      retval = (FT_Long)( ft_strlen( type1->font_info.weight ) + 1 );
       if ( value && value_len >= retval )
         ft_memcpy( value, (void *)( type1->font_info.weight ), retval );
       break;
--- a/src/type1/t1parse.c
+++ b/src/type1/t1parse.c
@@ -418,7 +418,7 @@
         goto Exit;
       }
 
-      size = parser->base_len - ( cur - parser->base_dict );
+      size = (FT_ULong)( parser->base_len - ( cur - parser->base_dict ) );
 
       if ( parser->in_memory )
       {