shithub: freetype+ttf2subf

Download patch

ref: 6b83a3674c3a0a30a2f2d685ba8a3d15de139480
parent: 09dbb059e1d5397ec468b1539d0fabaa6ecd066d
author: Alexei Podtelezhnikov <[email protected]>
date: Tue Jan 8 19:25:32 EST 2013

[base, pshinter] Use FT_ABS, FT_MIN, and FT_MAX for readability.

* src/base/ftbbox.c: Updated.
* src/base/ftobjs.c: Updated.
* src/base/fttrigon.c: Updated.
* src/pshinter/pshalgo.c: Updated.
* src/pshinter/pshrec.c: Updated.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-09  Alexei Podtelezhnikov  <[email protected]>
+
+	[base, pshinter] Use FT_ABS, FT_MIN, and FT_MAX for readability.
+
+	* src/base/ftbbox.c: Updated.
+	* src/base/ftobjs.c: Updated.
+	* src/base/fttrigon.c: Updated.
+	* src/pshinter/pshalgo.c: Updated.
+	* src/pshinter/pshrec.c: Updated.
+
 2013-01-08  Alexei Podtelezhnikov  <[email protected]>
 
 	[base] Clean up trigonometric core.
--- a/src/base/ftbbox.c
+++ b/src/base/ftbbox.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType bbox computation (body).                                    */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2004, 2006, 2010 by                         */
+/*  Copyright 1996-2002, 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        */
@@ -400,10 +400,10 @@
         /* We begin by computing `t1' as the bitwise `OR' of the     */
         /* absolute values of `a', `b', `c'.                         */
 
-        t1  = (FT_ULong)( ( a >= 0 ) ? a : -a );
-        t2  = (FT_ULong)( ( b >= 0 ) ? b : -b );
+        t1  = (FT_ULong)FT_ABS( a );
+        t2  = (FT_ULong)FT_ABS( b );
         t1 |= t2;
-        t2  = (FT_ULong)( ( c >= 0 ) ? c : -c );
+        t2  = (FT_ULong)FT_ABS( c );
         t1 |= t2;
 
         /* Now we can be sure that the most significant bit of `t1'  */
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    The FreeType private base classes (body).                            */
 /*                                                                         */
-/*  Copyright 1996-2012 by                                                 */
+/*  Copyright 1996-2013 by                                                 */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -1505,7 +1505,7 @@
     error = open_face_from_buffer( library,
                                    sfnt_ps,
                                    length,
-                                   face_index < 0 ? face_index : 0,
+                                   FT_MIN( face_index, 0 ),
                                    is_sfnt_cid ? "cid" : "type1",
                                    aface );
   Exit:
--- a/src/base/fttrigon.c
+++ b/src/base/fttrigon.c
@@ -65,7 +65,7 @@
 
 
     s   = val;
-    val = ( val >= 0 ) ? val : -val;
+    val = FT_ABS( val );
 
     v   = ( val * (FT_Int64)FT_TRIG_SCALE ) + 0x100000000UL;
     val = (FT_Fixed)( v >> 32 );
@@ -84,7 +84,7 @@
 
 
     s   = val;
-    val = ( val >= 0 ) ? val : -val;
+    val = FT_ABS( val );
 
     v1 = (FT_UInt32)val >> 16;
     v2 = (FT_UInt32)( val & 0xFFFFL );
@@ -96,7 +96,7 @@
     lo1  = k1 * v2 + k2 * v1;       /* can't overflow */
 
     lo2  = ( k2 * v2 ) >> 16;
-    lo3  = ( lo1 >= lo2 ) ? lo1 : lo2;
+    lo3  = FT_MAX( lo1, lo2 );
     lo1 += lo2;
 
     hi  += lo1 >> 16;
@@ -121,7 +121,7 @@
     x = vec->x;
     y = vec->y;
 
-    z     = ( ( x >= 0 ) ? x : - x ) | ( (y >= 0) ? y : -y );
+    z     = FT_ABS( x ) | FT_ABS( y );
     shift = 0;
 
 #if 1
@@ -464,11 +464,11 @@
     /* handle trivial cases */
     if ( v.x == 0 )
     {
-      return ( v.y >= 0 ) ? v.y : -v.y;
+      return FT_ABS( v.y );
     }
     else if ( v.y == 0 )
     {
-      return ( v.x >= 0 ) ? v.x : -v.x;
+      return FT_ABS( v.x );
     }
 
     /* general case */
--- a/src/pshinter/pshalgo.c
+++ b/src/pshinter/pshalgo.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    PostScript hinting algorithm (body).                                 */
 /*                                                                         */
-/*  Copyright 2001-2010, 2012 by                                           */
+/*  Copyright 2001-2010, 2012, 2013 by                                     */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used        */
@@ -1161,8 +1161,8 @@
     int     result = PSH_DIR_NONE;
 
 
-    ax = ( dx >= 0 ) ? dx : -dx;
-    ay = ( dy >= 0 ) ? dy : -dy;
+    ax = FT_ABS( dx );
+    ay = FT_ABS( dy );
 
     if ( ay * 12 < ax )
     {
--- a/src/pshinter/pshrec.c
+++ b/src/pshinter/pshrec.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    FreeType PostScript hints recorder (body).                           */
 /*                                                                         */
-/*  Copyright 2001, 2002, 2003, 2004, 2007, 2009 by                        */
+/*  Copyright 2001-2004, 2007, 2009, 2013 by                               */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -384,7 +384,7 @@
     FT_UInt   count;
 
 
-    count = ( count1 <= count2 ) ? count1 : count2;
+    count = FT_MIN( count1, count2 );
     for ( ; count >= 8; count -= 8 )
     {
       if ( p1[0] & p2[0] )