[pcf] Use unsigned types. * src/pcf/pcf.h (PCF_Encoding): Use unsigned `enc'. * src/pcf/pcfdrivr.c (pcf_cmap_char_{index,next}): Ditto. * src/pcf/pcfread.c (pcf_get_encodings): Use unsigned types.
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
diff --git a/ChangeLog b/ChangeLog
index 7f0793d..e0a6e20 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2018-08-06 Alexei Podtelezhnikov <apodtele@gmail.com>
+
+ [pcf] Use unsigned types.
+
+ * src/pcf/pcf.h (PCF_Encoding): Use unsigned `enc'.
+ * src/pcf/pcfdrivr.c (pcf_cmap_char_{index,next}): Ditto.
+ * src/pcf/pcfread.c (pcf_get_encodings): Use unsigned types.
+
2018-08-05 Werner Lemberg <wl@gnu.org>
* src/truetype/ttgload.c (compute_glyph_metrics): Fix overflow.
diff --git a/src/pcf/pcf.h b/src/pcf/pcf.h
index cb98cc7..3c4eb6a 100644
--- a/src/pcf/pcf.h
+++ b/src/pcf/pcf.h
@@ -130,7 +130,7 @@ FT_BEGIN_HEADER
*/
typedef struct PCF_EncodingRec_
{
- FT_Long enc;
+ FT_ULong enc;
FT_UShort glyph; /* an index into PCF_Face's `metrics' array */
} PCF_EncodingRec, *PCF_Encoding;
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 1a4f453..e2f7e7c 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -123,7 +123,7 @@ THE SOFTWARE.
mid = ( min + max ) >> 1;
- code = (FT_ULong)encodings[mid].enc;
+ code = encodings[mid].enc;
if ( charcode == code )
{
@@ -161,7 +161,7 @@ THE SOFTWARE.
mid = ( min + max ) >> 1;
- code = (FT_ULong)encodings[mid].enc;
+ code = encodings[mid].enc;
if ( charcode == code )
{
@@ -178,7 +178,7 @@ THE SOFTWARE.
charcode = 0;
if ( min < cmap->num_encodings )
{
- charcode = (FT_ULong)encodings[min].enc;
+ charcode = encodings[min].enc;
result = encodings[min].glyph;
}
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 9893644..266588c 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -944,12 +944,12 @@ THE SOFTWARE.
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
- FT_Short firstCol, lastCol;
- FT_Short firstRow, lastRow;
+ FT_UShort firstCol, lastCol;
+ FT_UShort firstRow, lastRow;
FT_ULong nencoding;
FT_UShort defaultCharRow, defaultCharCol;
FT_UShort encodingOffset, defaultCharEncodingOffset;
- FT_Short i, j;
+ FT_UShort i, j;
FT_Byte* pos;
FT_ULong k;
PCF_Encoding encoding = NULL;
@@ -975,18 +975,18 @@ THE SOFTWARE.
/* make sense for most encodings. */
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
{
- firstCol = FT_GET_SHORT();
- lastCol = FT_GET_SHORT();
- firstRow = FT_GET_SHORT();
- lastRow = FT_GET_SHORT();
+ firstCol = FT_GET_USHORT();
+ lastCol = FT_GET_USHORT();
+ firstRow = FT_GET_USHORT();
+ lastRow = FT_GET_USHORT();
face->defaultChar = FT_GET_USHORT();
}
else
{
- firstCol = FT_GET_SHORT_LE();
- lastCol = FT_GET_SHORT_LE();
- firstRow = FT_GET_SHORT_LE();
- lastRow = FT_GET_SHORT_LE();
+ firstCol = FT_GET_USHORT_LE();
+ lastCol = FT_GET_USHORT_LE();
+ firstRow = FT_GET_USHORT_LE();
+ lastRow = FT_GET_USHORT_LE();
face->defaultChar = FT_GET_USHORT_LE();
}
@@ -1008,10 +1008,8 @@ THE SOFTWARE.
face->defaultChar ));
/* sanity checks; we limit numbers of rows and columns to 256 */
- if ( firstCol < 0 ||
- firstCol > lastCol ||
+ if ( firstCol > lastCol ||
lastCol > 0xFF ||
- firstRow < 0 ||
firstRow > lastRow ||
lastRow > 0xFF )
return FT_THROW( Invalid_Table );
@@ -1032,14 +1030,14 @@ THE SOFTWARE.
defaultCharCol = face->defaultChar & 0xFF;
/* validate default character */
- if ( defaultCharRow < (FT_UShort)firstRow ||
- defaultCharRow > (FT_UShort)lastRow ||
- defaultCharCol < (FT_UShort)firstCol ||
- defaultCharCol > (FT_UShort)lastCol )
+ if ( defaultCharRow < firstRow ||
+ defaultCharRow > lastRow ||
+ defaultCharCol < firstCol ||
+ defaultCharCol > lastCol )
{
- face->defaultChar = (FT_UShort)firstRow * 256U + (FT_UShort)firstCol;
+ face->defaultChar = firstRow * 256U + firstCol;
FT_TRACE0(( "pcf_get_encodings:"
- " Invalid default character set to %d\n",
+ " Invalid default character set to %u\n",
face->defaultChar ));
defaultCharRow = face->defaultChar >> 8;
@@ -1054,9 +1052,8 @@ THE SOFTWARE.
/* `stream->cursor' still points at the beginning of the frame; */
/* we can thus easily get the offset to the default character */
pos = stream->cursor +
- 2 * ( ( defaultCharRow - (FT_UShort)firstRow ) *
- ( lastCol - firstCol + 1 ) +
- defaultCharCol - (FT_UShort)firstCol );
+ 2 * ( ( defaultCharRow - firstRow ) * ( lastCol - firstCol + 1 ) +
+ defaultCharCol - firstCol );
if ( PCF_BYTE_ORDER( format ) == MSBFirst )
defaultCharEncodingOffset = FT_PEEK_USHORT( pos );
@@ -1102,10 +1099,10 @@ THE SOFTWARE.
else if ( encodingOffset == 0 )
encodingOffset = defaultCharEncodingOffset;
- encoding[k].enc = i * 256 + j;
+ encoding[k].enc = i * 256U + j;
encoding[k].glyph = encodingOffset;
- FT_TRACE5(( " code %d (0x%04X): idx %d\n",
+ FT_TRACE5(( " code %u (0x%04X): idx %u\n",
encoding[k].enc, encoding[k].enc, encoding[k].glyph ));
k++;