[cid] Signedness revisions. Unsigned checks are simpler. * include/freetype/t1tables.h (CID_FaceInfoRec): Change to unsignd `num_dicts`. * src/cid/cidparse.h (CID_Parser): Change to unsigned `num_dict`. * src/cid/cidgload.c (cid_load_glyph): Updated. * src/cid/cidload.c (cid_load_keyword, parse_fd_array, parse_expansion_factor, parse_font_name, cid_read_subrs, cid_face_open): Updated. * src/cid/cidobjs.c (cid_face_done): Updated. * src/cid/cidparse.c (cid_parser_new): 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 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
diff --git a/include/freetype/t1tables.h b/include/freetype/t1tables.h
index 1f5bc15..a5f6ae7 100644
--- a/include/freetype/t1tables.h
+++ b/include/freetype/t1tables.h
@@ -419,7 +419,7 @@ FT_BEGIN_HEADER
FT_UInt gd_bytes;
FT_ULong cid_count;
- FT_Int num_dicts;
+ FT_UInt num_dicts;
CID_FaceDict font_dicts;
FT_ULong data_offset;
diff --git a/src/cid/cidgload.c b/src/cid/cidgload.c
index bf78957..a46d063 100644
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -117,9 +117,9 @@
off2 = cid_get_offset( &p, cid->gd_bytes );
FT_FRAME_EXIT();
- if ( fd_select >= (FT_ULong)cid->num_dicts ||
- off2 > stream->size ||
- off1 > off2 )
+ if ( fd_select >= cid->num_dicts ||
+ off2 > stream->size ||
+ off1 > off2 )
{
FT_TRACE0(( "cid_load_glyph: invalid glyph stream offsets\n" ));
error = FT_THROW( Invalid_Offset );
diff --git a/src/cid/cidload.c b/src/cid/cidload.c
index 1f3f6d7..2f38485 100644
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -113,7 +113,7 @@
CID_FaceDict dict;
- if ( parser->num_dict < 0 || parser->num_dict >= cid->num_dicts )
+ if ( parser->num_dict >= cid->num_dicts )
{
FT_ERROR(( "cid_load_keyword: invalid use of `%s'\n",
keyword->ident ));
@@ -164,7 +164,7 @@
FT_Fixed temp_scale;
- if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
+ if ( parser->num_dict < face->cid.num_dicts )
{
FT_Matrix* matrix;
FT_Vector* offset;
@@ -244,17 +244,12 @@
FT_Memory memory = face->root.memory;
FT_Stream stream = parser->stream;
FT_Error error = FT_Err_Ok;
- FT_Long num_dicts;
+ FT_UInt num_dicts, max_dicts;
- num_dicts = cid_parser_to_int( parser );
- if ( num_dicts < 0 )
- {
- FT_ERROR(( "parse_fd_array: invalid number of dictionaries\n" ));
- goto Exit;
- }
+ num_dicts = (FT_UInt)cid_parser_to_int( parser );
- FT_TRACE4(( " %ld\n", num_dicts ));
+ FT_TRACE4(( " %u\n", num_dicts ));
/*
* A single entry in the FDArray must (at least) contain the following
@@ -272,18 +267,18 @@
* need a `dup X' at the very beginning and a `put' at the end, so a
* rough guess using 100 bytes as the minimum is justified.
*/
- if ( (FT_ULong)num_dicts > stream->size / 100 )
+ max_dicts = (FT_UInt)( stream->size / 100 );
+ if ( num_dicts > max_dicts )
{
FT_TRACE0(( "parse_fd_array: adjusting FDArray size"
- " (from %ld to %lu)\n",
- num_dicts,
- stream->size / 100 ));
- num_dicts = (FT_Long)( stream->size / 100 );
+ " (from %u to %u)\n",
+ num_dicts, max_dicts ));
+ num_dicts = max_dicts;
}
if ( !cid->font_dicts )
{
- FT_Int n;
+ FT_UInt n;
if ( FT_NEW_ARRAY( cid->font_dicts, num_dicts ) )
@@ -322,7 +317,7 @@
CID_FaceDict dict;
- if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
+ if ( parser->num_dict < face->cid.num_dicts )
{
dict = face->cid.font_dicts + parser->num_dict;
@@ -345,7 +340,7 @@
CID_Parser* parser )
{
#ifdef FT_DEBUG_LEVEL_TRACE
- if ( parser->num_dict >= 0 && parser->num_dict < face->cid.num_dicts )
+ if ( parser->num_dict < face->cid.num_dicts )
{
T1_TokenRec token;
FT_UInt len;
@@ -427,7 +422,7 @@
parser->num_dict++;
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE4(( " FontDict %d", parser->num_dict ));
+ FT_TRACE4(( " FontDict %u", parser->num_dict ));
if ( parser->num_dict > face->cid.num_dicts )
FT_TRACE4(( " (ignored)" ));
FT_TRACE4(( "\n" ));
@@ -517,7 +512,7 @@
FT_Memory memory = face->root.memory;
FT_Stream stream = face->cid_stream;
FT_Error error;
- FT_Int n;
+ FT_UInt n;
CID_Subrs subr;
FT_UInt max_offsets = 0;
FT_ULong* offsets = NULL;
@@ -771,7 +766,7 @@
CID_Parser* parser;
FT_Memory memory = face->root.memory;
FT_Error error;
- FT_Int n;
+ FT_UInt n;
CID_FaceInfo cid = &face->cid;
diff --git a/src/cid/cidobjs.c b/src/cid/cidobjs.c
index 68ec84b..e3c29c2 100644
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -216,7 +216,7 @@
/* release subrs */
if ( face->subrs )
{
- FT_Int n;
+ FT_UInt n;
for ( n = 0; n < cid->num_dicts; n++ )
diff --git a/src/cid/cidparse.c b/src/cid/cidparse.c
index a28f8ee..96ca1c3 100644
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -181,7 +181,7 @@
parser->root.base = parser->postscript;
parser->root.cursor = parser->postscript;
parser->root.limit = parser->root.cursor + ps_len;
- parser->num_dict = -1;
+ parser->num_dict = FT_UINT_MAX;
/* Finally, we check whether `StartData' or `/sfnts' was real -- */
/* it could be in a comment or string. We also get the arguments */
diff --git a/src/cid/cidparse.h b/src/cid/cidparse.h
index 6a00c6c..fbc437b 100644
--- a/src/cid/cidparse.h
+++ b/src/cid/cidparse.h
@@ -78,7 +78,7 @@ FT_BEGIN_HEADER
FT_ULong binary_length;
CID_FaceInfo cid;
- FT_Int num_dict;
+ FT_UInt num_dict;
} CID_Parser;