* include/internal/ftstream.h: modified the definitions of the FT_GET_XXXX and NEXT_XXXX macros for 16-bit correctness
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
diff --git a/ChangeLog b/ChangeLog
index 2e87d72..44b7014 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -8,6 +8,11 @@
* src/psaux/psobjs.c (T1_Decrypt): Ditto.
* src/type1/t1parse.c (T1_Get_Private_Dict): Ditto.
+2001-06-28 David Turner <david@freetype.org>
+
+ * include/internal/ftstream.h: modified the definitions
+ of the FT_GET_XXXX and NEXT_XXXX macros for 16-bit correctness
+
2001-06-26 Werner Lemberg <wl@gnu.org>
* src/cid/cidload.c, src/cid/cidload.h (cid_decrypt): Use FT_Offset
diff --git a/include/freetype/internal/ftstream.h b/include/freetype/internal/ftstream.h
index c7b536d..3512f4a 100644
--- a/include/freetype/internal/ftstream.h
+++ b/include/freetype/internal/ftstream.h
@@ -144,35 +144,66 @@ FT_BEGIN_HEADER
/* type `char*' or equivalent (1-byte elements). */
/* */
-#define FT_GET_SHORT_BE( p ) \
- ( (short)( ( (signed char)(p)[0] << 8 ) | \
- (p)[1] ) )
-
-#define FT_GET_OFF3_BE( p ) \
- ( (long) ( ( (signed char)(p)[0] << 16 ) | \
- ( (p)[1] << 8 ) | \
- (p)[2] ) )
-
-#define FT_GET_LONG_BE( p ) \
- ( (long) ( ( (signed char)(p)[0] << 24 ) | \
- ( (p)[1] << 16 ) | \
- ( (p)[2] << 8 ) | \
- (p)[3] ) )
-
-#define FT_GET_SHORT_LE( p ) \
- ( (short)( ( (signed char)(p)[1] << 8 ) | \
- (p)[0] ) )
-
-#define FT_GET_OFF3_LE( p ) \
- ( (long) ( ( (signed char)(p)[2] << 16 ) | \
- ( (p)[1] << 8 ) | \
- (p)[0] ) )
-
-#define FT_GET_LONG_LE( p ) \
- ( (long) ( ( (signed char)(p)[3] << 24 ) | \
- ( (p)[2] << 16 ) | \
- ( (p)[1] << 8 ) | \
- (p)[0] ) )
+#define FT_GET_SHORT_BE( p ) \
+ ((FT_Int16)( ( (FT_Int16)(FT_Char)(p)[0] << 8 ) | \
+ (FT_Int16)(FT_Byte)(p)[1] ) )
+
+#define FT_GET_USHORT_BE( p ) \
+ ((FT_Int16)( ( (FT_UInt16)(FT_Byte)(p)[0] << 8 ) | \
+ (FT_UInt16)(FT_Byte)(p)[1] ) )
+
+#define FT_GET_OFF3_BE( p ) \
+ ( (FT_Int32) ( ( (FT_Int32)(FT_Char)(p)[0] << 16 ) | \
+ ( (FT_Int32)(FT_Byte)(p)[1] << 8 ) | \
+ (FT_Int32)(FT_Byte)(p)[2] ) )
+
+#define FT_GET_UOFF3_BE( p ) \
+ ( (FT_Int32) ( ( (FT_UInt32)(FT_Byte)(p)[0] << 16 ) | \
+ ( (FT_UInt32)(FT_Byte)(p)[1] << 8 ) | \
+ (FT_UInt32)(FT_Byte)(p)[2] ) )
+
+#define FT_GET_LONG_BE( p ) \
+ ( (FT_Int32) ( ( (FT_Int32)(FT_Char)(p)[0] << 24 ) | \
+ ( (FT_Int32)(FT_Byte)(p)[1] << 16 ) | \
+ ( (FT_Int32)(FT_Byte)(p)[2] << 8 ) | \
+ (FT_Int32)(FT_Byte)(p)[3] ) )
+
+#define FT_GET_ULONG_BE( p ) \
+ ( (FT_Int32) ( ( (FT_UInt32)(FT_Byte)(p)[0] << 24 ) | \
+ ( (FT_UInt32)(FT_Byte)(p)[1] << 16 ) | \
+ ( (FT_UInt32)(FT_Byte)(p)[2] << 8 ) | \
+ (FT_UInt32)(FT_Byte)(p)[3] ) )
+
+#define FT_GET_SHORT_LE( p ) \
+ ((FT_Int16)( ( (FT_Int16)(FT_Char)(p)[1] << 8 ) | \
+ (FT_Int16)(FT_Byte)(p)[0] ) )
+
+#define FT_GET_USHORT_LE( p ) \
+ ((FT_Int16)( ( (FT_UInt16)(FT_Byte)(p)[1] << 8 ) | \
+ (FT_UInt16)(FT_Byte)(p)[0] ) )
+
+#define FT_GET_OFF3_LE( p ) \
+ ( (FT_Int32) ( ( (FT_Int32)(FT_Char)(p)[2] << 16 ) | \
+ ( (FT_Int32)(FT_Byte)(p)[1] << 8 ) | \
+ (FT_Int32)(FT_Byte)(p)[0] ) )
+
+#define FT_GET_UOFF3_LE( p ) \
+ ( (FT_Int32) ( ( (FT_UInt32)(FT_Byte)(p)[2] << 16 ) | \
+ ( (FT_UInt32)(FT_Byte)(p)[1] << 8 ) | \
+ (FT_UInt32)(FT_Byte)(p)[0] ) )
+
+#define FT_GET_LONG_LE( p ) \
+ ( (FT_Int32) ( ( (FT_Int32)(FT_Char)(p)[3] << 24 ) | \
+ ( (FT_Int32)(FT_Byte)(p)[2] << 16 ) | \
+ ( (FT_Int32)(FT_Byte)(p)[1] << 8 ) | \
+ (FT_Int32)(FT_Byte)(p)[0] ) )
+
+#define FT_GET_ULONG_LE( p ) \
+ ( (FT_Int32) ( ( (FT_UInt32)(FT_Byte)(p)[3] << 24 ) | \
+ ( (FT_UInt32)(FT_Byte)(p)[2] << 16 ) | \
+ ( (FT_UInt32)(FT_Byte)(p)[1] << 8 ) | \
+ (FT_UInt32)(FT_Byte)(p)[0] ) )
+
#define NEXT_Char( buffer ) \
( (signed char)*buffer++ )
@@ -184,39 +215,39 @@ FT_BEGIN_HEADER
( (short)( buffer += 2, FT_GET_SHORT_BE( buffer - 2 ) ) )
#define NEXT_UShort( buffer ) \
- ( (unsigned short)NEXT_Short( buffer ) )
+ ( (unsigned short)( buffer += 2, FT_GET_USHORT_BE( buffer - 2 ) ) )
#define NEXT_Offset( buffer ) \
( (long)( buffer += 3, FT_GET_OFF3_BE( buffer - 3 ) ) )
#define NEXT_UOffset( buffer ) \
- ( (unsigned long)NEXT_Offset( buffer ) )
+ ( (unsigned long)( buffer += 3, FT_GET_UOFF3_BE( buffer - 3 ) ) )
#define NEXT_Long( buffer ) \
( (long)( buffer += 4, FT_GET_LONG_BE( buffer - 4 ) ) )
#define NEXT_ULong( buffer ) \
- ( (unsigned long)NEXT_Long( buffer ) )
+ ( (unsigned long)( buffer += 4, FT_GET_ULONG_BE( buffer - 4 ) ) )
#define NEXT_ShortLE( buffer ) \
( (short)( buffer += 2, FT_GET_SHORT_LE( buffer - 2 ) ) )
#define NEXT_UShortLE( buffer ) \
- ( (unsigned short)NEXT_ShortLE( buffer ) )
+ ( (unsigned short)( buffer += 2, FT_GET_USHORT_LE( buffer - 2 ) ) )
#define NEXT_OffsetLE( buffer ) \
( (long)( buffer += 3, FT_GET_OFF3_LE( buffer - 3 ) ) )
#define NEXT_UOffsetLE( buffer ) \
- ( (unsigned long)NEXT_OffsetLE( buffer ) )
+ ( (unsigned long)( buffer += 3, FT_GET_UOFF3_LE( buffer - 3 ) ) )
#define NEXT_LongLE( buffer ) \
( (long)( buffer += 4, FT_GET_LONG_LE( buffer - 4 ) ) )
#define NEXT_ULongLE( buffer ) \
- ( (unsigned long)NEXT_LongLE( buffer ) )
+ ( (unsigned long)( buffer += 4, FT_GET_ULONG_LE( buffer - 4 ) ) )
/*************************************************************************/