freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2-demos] master 105a51e: [ttdebug] Fix compiler warnings and ru


From: Werner LEMBERG
Subject: [freetype2-demos] master 105a51e: [ttdebug] Fix compiler warnings and run-time errors.
Date: Sun, 31 Dec 2017 03:44:19 -0500 (EST)

branch: master
commit 105a51e4e1205aa68e8d4743fa833a5aae9caffc
Author: Werner Lemberg <address@hidden>
Commit: Werner Lemberg <address@hidden>

    [ttdebug] Fix compiler warnings and run-time errors.
    
    * src/ttdebug.c (Cur_U_Line): Remove useless casts to `unsigned' and fix
    the necessary ones.
    (RunIns): Protect `FT_MEM_COPY' calls.
---
 ChangeLog     | 12 +++++++--
 src/ttdebug.c | 82 ++++++++++++++++++++++++++++++++---------------------------
 2 files changed, 55 insertions(+), 39 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 1d801dd..3f3fd11 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,13 +1,21 @@
+2017-12-31  Werner Lemberg  <address@hidden>
+
+       [ttdebug] Fix compiler warnings and run-time errors.
+
+       * src/ttdebug.c (Cur_U_Line): Remove useless casts to `unsigned' and fix
+       the necessary ones.
+       (RunIns): Protect `FT_MEM_COPY' calls.
+
 2017-12-30  Werner Lemberg  <address@hidden>
 
-       [ttdebug]: Key `K' shows full stack.
+       [ttdebug] Key `K' shows full stack.
 
        * src/ttdebug.c (RunIns): Update help display.
        Handle key `K'.
 
 2017-12-30  Werner Lemberg  <address@hidden>
 
-       [ttdebug]: Key `I' toggles hexadecimal/decimal numbers display.
+       [ttdebug] Key `I' toggles hexadecimal/decimal numbers display.
 
        * src/ttdebug.c (use_hex): New global variable.
        (Cur_U_Line): Use it.
diff --git a/src/ttdebug.c b/src/ttdebug.c
index 3b1f30e..8becfd0 100644
--- a/src/ttdebug.c
+++ b/src/ttdebug.c
@@ -841,7 +841,7 @@
 
 
         temp = use_hex ? " $%02x" : " %d";
-        sprintf( s, temp, (unsigned)CUR.code[CUR.IP + i + 2] );
+        sprintf( s, temp, CUR.code[CUR.IP + i + 2] );
         strncat( tempStr, s, 8 );
       }
     }
@@ -859,15 +859,15 @@
       {
         if ( use_hex )
           sprintf( s, " $%02x%02x",
-                      (unsigned)CUR.code[CUR.IP + i * 2 + 2],
-                      (unsigned)CUR.code[CUR.IP + i * 2 + 3] );
+                      CUR.code[CUR.IP + i * 2 + 2],
+                      CUR.code[CUR.IP + i * 2 + 3] );
         else
         {
           unsigned short  temp;
 
 
-          temp = ( (unsigned)CUR.code[CUR.IP + i * 2 + 2] << 8 ) +
-                   (unsigned)CUR.code[CUR.IP + i * 2 + 3];
+          temp = (unsigned short)( ( CUR.code[CUR.IP + i * 2 + 2] << 8 ) +
+                                     CUR.code[CUR.IP + i * 2 + 3]        );
           sprintf( s, " %d",
                       (signed short)temp );
         }
@@ -884,7 +884,7 @@
 
 
         temp = use_hex ? " $%02x" : " %d";
-        sprintf( s, temp, (unsigned)CUR.code[CUR.IP + i + 1] );
+        sprintf( s, temp, CUR.code[CUR.IP + i + 1] );
         strncat( tempStr, s, 8 );
       }
     }
@@ -896,15 +896,15 @@
       {
         if ( use_hex )
           sprintf( s, " $%02x%02x",
-                      (unsigned)CUR.code[CUR.IP + i * 2 + 1],
-                      (unsigned)CUR.code[CUR.IP + i * 2 + 2] );
+                      CUR.code[CUR.IP + i * 2 + 1],
+                      CUR.code[CUR.IP + i * 2 + 2] );
         else
         {
           unsigned short  temp;
 
 
-          temp = ( (unsigned)CUR.code[CUR.IP + i * 2 + 1] << 8 ) +
-                   (unsigned)CUR.code[CUR.IP + i * 2 + 2];
+          temp = (unsigned short)( ( CUR.code[CUR.IP + i * 2 + 1] << 8 ) +
+                                     CUR.code[CUR.IP + i * 2 + 2]        );
           sprintf( s, " %d",
                       (signed short)temp );
         }
@@ -1635,33 +1635,41 @@
         }
       } while ( !key );
 
-      FT_MEM_COPY( save_pts.org,
-                   pts.org,
-                   pts.n_points * sizeof ( FT_Vector ) );
-      FT_MEM_COPY( save_pts.cur,
-                   pts.cur,
-                   pts.n_points * sizeof ( FT_Vector ) );
-      FT_MEM_COPY( save_pts.tags,
-                   pts.tags,
-                   pts.n_points );
-
-      FT_MEM_COPY( save_twilight.org,
-                   twilight.org,
-                   twilight.n_points * sizeof ( FT_Vector ) );
-      FT_MEM_COPY( save_twilight.cur,
-                   twilight.cur,
-                   twilight.n_points * sizeof ( FT_Vector ) );
-      FT_MEM_COPY( save_twilight.tags,
-                   twilight.tags,
-                   twilight.n_points );
-
-      FT_MEM_COPY( save_cvt,
-                   CUR.cvt,
-                   CUR.cvtSize * sizeof ( FT_Long ) );
-
-      FT_MEM_COPY( save_storage,
-                   storage,
-                   CUR.storeSize * sizeof ( Storage ) );
+      if ( pts.n_points )
+      {
+        FT_MEM_COPY( save_pts.org,
+                     pts.org,
+                     pts.n_points * sizeof ( FT_Vector ) );
+        FT_MEM_COPY( save_pts.cur,
+                     pts.cur,
+                     pts.n_points * sizeof ( FT_Vector ) );
+        FT_MEM_COPY( save_pts.tags,
+                     pts.tags,
+                     pts.n_points );
+      }
+
+      if ( twilight.n_points )
+      {
+        FT_MEM_COPY( save_twilight.org,
+                     twilight.org,
+                     twilight.n_points * sizeof ( FT_Vector ) );
+        FT_MEM_COPY( save_twilight.cur,
+                     twilight.cur,
+                     twilight.n_points * sizeof ( FT_Vector ) );
+        FT_MEM_COPY( save_twilight.tags,
+                     twilight.tags,
+                     twilight.n_points );
+      }
+
+      if ( CUR.cvtSize )
+        FT_MEM_COPY( save_cvt,
+                     CUR.cvt,
+                     CUR.cvtSize * sizeof ( FT_Long ) );
+
+      if ( CUR.storeSize )
+        FT_MEM_COPY( save_storage,
+                     storage,
+                     CUR.storeSize * sizeof ( Storage ) );
 
       /* a return indicates the last command */
       if ( ch == '\r' || ch == '\n' )



reply via email to

[Prev in Thread] Current Thread [Next in Thread]