Commit eb05bfbe09eafcf6e3c6e3ca2454290419d2cbce

Werner Lemberg 2015-02-20T08:37:35

[cff] Signedness fixes for new engine. * src/cff/cf2arrst.c, src/cff/cf2fixed.h, src/cff/cf2ft.c, src/cff/cf2ft.h, src/cff/cf2hints.c, src/cff/cf2intrp.c: Apply.

diff --git a/ChangeLog b/ChangeLog
index f064cad..4cab1b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2015-02-20  Werner Lemberg  <wl@gnu.org>
 
+	[cff] Signedness fixes for new engine.
+
+	* src/cff/cf2arrst.c, src/cff/cf2fixed.h, src/cff/cf2ft.c,
+	src/cff/cf2ft.h, src/cff/cf2hints.c, src/cff/cf2intrp.c: Apply.
+
+2015-02-20  Werner Lemberg  <wl@gnu.org>
+
 	[cff] Signedness fixes for basic infrastructure and old engine.
 
 	* include/internal/pshints.h, src/cff/cffdrivr.c,
diff --git a/src/cff/cf2arrst.c b/src/cff/cf2arrst.c
index c8d6f13..528b1fa 100644
--- 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 = (FT_Long)( numElements * arrstack->sizeItem );
+      size_t  newSize = numElements * arrstack->sizeItem;
 
 
       if ( numElements > LONG_MAX / arrstack->sizeItem )
diff --git a/src/cff/cf2fixed.h b/src/cff/cf2fixed.h
index ed1452a..d6d9faf 100644
--- a/src/cff/cf2fixed.h
+++ b/src/cff/cf2fixed.h
@@ -57,22 +57,22 @@ FT_BEGIN_HEADER
   /* in C 89, left and right shift of negative numbers is  */
   /* implementation specific behaviour in the general case */
 
-#define cf2_intToFixed( i )                                    \
+#define cf2_intToFixed( i )                                              \
           ( (CF2_Fixed)( (FT_UInt32)(i) << 16 ) )
-#define cf2_fixedToInt( x )                                    \
+#define cf2_fixedToInt( x )                                              \
           ( (FT_Short)( ( (FT_UInt32)(x) + 0x8000U ) >> 16 ) )
-#define cf2_fixedRound( x )                                    \
-          ( (CF2_Fixed)( ( (x) + 0x8000 ) & 0xFFFF0000L ) )
-#define cf2_floatToFixed( f )                                  \
+#define cf2_fixedRound( x )                                              \
+          ( (CF2_Fixed)( ( (FT_UInt32)(x) + 0x8000U ) & 0xFFFF0000UL ) )
+#define cf2_floatToFixed( f )                                            \
           ( (CF2_Fixed)( (f) * 65536.0 + 0.5 ) )
-#define cf2_fixedAbs( x )                                      \
+#define cf2_fixedAbs( x )                                                \
           ( (x) < 0 ? -(x) : (x) )
-#define cf2_fixedFloor( x )                                    \
-          ( (CF2_Fixed)( (x) & 0xFFFF0000L ) )
-#define cf2_fixedFraction( x )                                 \
+#define cf2_fixedFloor( x )                                              \
+          ( (CF2_Fixed)( (FT_UInt32)(x) & 0xFFFF0000UL ) )
+#define cf2_fixedFraction( x )                                           \
           ( (x) - cf2_fixedFloor( x ) )
-#define cf2_fracToFixed( x )                                   \
-          ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 )             \
+#define cf2_fracToFixed( x )                                             \
+          ( (x) < 0 ? -( ( -(x) + 0x2000 ) >> 14 )                       \
                     :  ( (  (x) + 0x2000 ) >> 14 ) )
 
 
diff --git a/src/cff/cf2ft.c b/src/cff/cf2ft.c
index ebba469..2c91394 100644
--- a/src/cff/cf2ft.c
+++ b/src/cff/cf2ft.c
@@ -569,7 +569,7 @@
   /* used for seac component                           */
   FT_LOCAL_DEF( FT_Error )
   cf2_getSeacComponent( CFF_Decoder*  decoder,
-                        CF2_UInt      code,
+                        CF2_Int       code,
                         CF2_Buffer    buf )
   {
     CF2_Int   gid;
@@ -587,7 +587,7 @@
       return FT_THROW( Invalid_Glyph_Format );
 
     error = cff_get_glyph_data( decoder->builder.face,
-                                gid,
+                                (CF2_UInt)gid,
                                 &charstring,
                                 &len );
     /* TODO: for now, just pass the FreeType error through */
diff --git a/src/cff/cf2ft.h b/src/cff/cf2ft.h
index 731da3c..3073df3 100644
--- a/src/cff/cf2ft.h
+++ b/src/cff/cf2ft.h
@@ -103,7 +103,7 @@ FT_BEGIN_HEADER
                               CF2_Buffer    buf );
   FT_LOCAL( FT_Error )
   cf2_getSeacComponent( CFF_Decoder*  decoder,
-                        CF2_UInt      code,
+                        CF2_Int       code,
                         CF2_Buffer    buf );
   FT_LOCAL( void )
   cf2_freeSeacComponent( CFF_Decoder*  decoder,
diff --git a/src/cff/cf2hints.c b/src/cff/cf2hints.c
index 040d193..0e27000 100644
--- a/src/cff/cf2hints.c
+++ b/src/cff/cf2hints.c
@@ -697,10 +697,10 @@
 
     /* make room to insert */
     {
-      CF2_Int  iSrc = hintmap->count - 1;
-      CF2_Int  iDst = isPair ? hintmap->count + 1 : hintmap->count;
+      CF2_UInt  iSrc = hintmap->count - 1;
+      CF2_UInt  iDst = isPair ? hintmap->count + 1 : hintmap->count;
 
-      CF2_Int  count = hintmap->count - indexInsert;
+      CF2_UInt  count = hintmap->count - indexInsert;
 
 
       if ( iDst >= CF2_MAX_HINT_EDGES )
diff --git a/src/cff/cf2intrp.c b/src/cff/cf2intrp.c
index a269606..462c5e7 100644
--- a/src/cff/cf2intrp.c
+++ b/src/cff/cf2intrp.c
@@ -760,11 +760,12 @@
 
           /* push our current CFF charstring region on subrStack */
           charstring = (CF2_Buffer)
-                         cf2_arrstack_getPointer( &subrStack,
-                                                  charstringIndex + 1 );
+                         cf2_arrstack_getPointer(
+                           &subrStack,
+                           (size_t)charstringIndex + 1 );
 
           /* set up the new CFF region and pointer */
-          subrIndex = cf2_stack_popInt( opStack );
+          subrIndex = (CF2_UInt)cf2_stack_popInt( opStack );
 
           switch ( op1 )
           {
@@ -809,8 +810,9 @@
 
         /* restore position in previous charstring */
         charstring = (CF2_Buffer)
-                       cf2_arrstack_getPointer( &subrStack,
-                                                --charstringIndex );
+                       cf2_arrstack_getPointer(
+                         &subrStack,
+                         (CF2_UInt)--charstringIndex );
         continue;     /* do not clear the stack */
 
       case cf2_cmdESC:
@@ -1088,8 +1090,8 @@
           /* must be either 4 or 5 --                       */
           /* this is a (deprecated) implied `seac' operator */
 
-          CF2_UInt       achar;
-          CF2_UInt       bchar;
+          CF2_Int        achar;
+          CF2_Int        bchar;
           CF2_BufferRec  component;
           CF2_Fixed      dummyWidth;   /* ignore component width */
           FT_Error       error2;