[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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
diff --git a/ChangeLog b/ChangeLog
index baab84f..6d2a672 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2013-01-09 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [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 <apodtele@gmail.com>
[base] Clean up trigonometric core.
diff --git a/src/base/ftbbox.c b/src/base/ftbbox.c
index 4b8e911..aaf9042 100644
--- 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' */
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 76ccf0a..9881985 100644
--- 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:
diff --git a/src/base/fttrigon.c b/src/base/fttrigon.c
index 48a0155..73fd195 100644
--- 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 */
diff --git a/src/pshinter/pshalgo.c b/src/pshinter/pshalgo.c
index f4fbb4d..47fc3e4 100644
--- 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 )
{
diff --git a/src/pshinter/pshrec.c b/src/pshinter/pshrec.c
index 0910cc5..b6ddc45 100644
--- 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] )