ref: 6bd7d28fc7ff083a4825fcca250bafd6d532b9d3
parent: 6a0ded7641bdf4be45df1b09334faa5ea3887e3f
author: Werner Lemberg <[email protected]>
date: Wed Feb 18 04:22:06 EST 2015
Don't use `FT_PtrDist' for lengths. Use FT_UInt instead. * include/internal/psaux.h (PS_Table_FuncsRec, PS_TableRec, T1_DecoderRec): Do it. * include/internal/t1types.h (T1_FontRec): Ditto. * src/cid/cidload.c (cid_parse_dict): Updated. * src/pfr/pfrload.c (pfr_extra_item_load_font_id): Ditto. * src/psaux/psobjs.c (ps_table_add), src/psaux/psobjs.h: Ditto. * src/type1/t1load.c (parse_blend_axis_types, parse_encoding, parse_chharstrings, parse_dict): Ditto. * src/type42/t42parse.c (t42_parse_encoding, t42_parse_charstrings, t42_parse_dict): Ditto.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,24 @@
2015-02-18 Werner Lemberg <[email protected]>
+ Don't use `FT_PtrDist' for lengths.
+
+ Use FT_UInt instead.
+
+ * include/internal/psaux.h (PS_Table_FuncsRec, PS_TableRec,
+ T1_DecoderRec): Do it.
+
+ * include/internal/t1types.h (T1_FontRec): Ditto.
+
+ * src/cid/cidload.c (cid_parse_dict): Updated.
+ * src/pfr/pfrload.c (pfr_extra_item_load_font_id): Ditto.
+ * src/psaux/psobjs.c (ps_table_add), src/psaux/psobjs.h: Ditto.
+ * src/type1/t1load.c (parse_blend_axis_types, parse_encoding,
+ parse_chharstrings, parse_dict): Ditto.
+ * src/type42/t42parse.c (t42_parse_encoding, t42_parse_charstrings,
+ t42_parse_dict): Ditto.
+
+2015-02-18 Werner Lemberg <[email protected]>
+
* src/type1/t1driver.c (t1_ps_get_font_value): Clean up.
This handles negative values better, avoiding many casts.
--- a/include/internal/psaux.h
+++ b/include/internal/psaux.h
@@ -71,10 +71,10 @@
(*done)( PS_Table table );
FT_Error
- (*add)( PS_Table table,
- FT_Int idx,
- void* object,
- FT_PtrDist length );
+ (*add)( PS_Table table,
+ FT_Int idx,
+ void* object,
+ FT_UInt length );
void
(*release)( PS_Table table );
@@ -127,7 +127,7 @@
FT_Int max_elems;
FT_Int num_elems;
FT_Byte** elements; /* addresses of table elements */
- FT_PtrDist* lengths; /* lengths of table elements */
+ FT_UInt* lengths; /* lengths of table elements */
FT_Memory memory;
PS_Table_FuncsRec funcs;
@@ -677,7 +677,7 @@
FT_Int lenIV; /* internal for sub routine calls */
FT_UInt num_subrs;
FT_Byte** subrs;
- FT_PtrDist* subrs_len; /* array of subrs length (optional) */
+ FT_UInt* subrs_len; /* array of subrs length (optional) */
FT_Matrix font_matrix;
FT_Vector font_offset;
--- a/include/internal/t1types.h
+++ b/include/internal/t1types.h
@@ -106,12 +106,12 @@
FT_Int num_subrs;
FT_Byte** subrs;
- FT_PtrDist* subrs_len;
+ FT_UInt* subrs_len;
FT_Int num_glyphs;
FT_String** glyph_names; /* array of glyph names */
FT_Byte** charstrings; /* array of glyph charstrings */
- FT_PtrDist* charstrings_len;
+ FT_UInt* charstrings_len;
FT_Byte paint_type;
FT_Byte font_type;
--- a/src/cid/cidload.c
+++ b/src/cid/cidload.c
@@ -342,11 +342,11 @@
/* look for immediates */
if ( *cur == '/' && cur + 2 < limit )
{
- FT_PtrDist len;
+ FT_UInt len;
cur++;
- len = parser->root.cursor - cur;
+ len = (FT_UInt)( parser->root.cursor - cur );
if ( len > 0 && len < 22 )
{
@@ -363,10 +363,10 @@
if ( !name )
break;
- if ( cur[0] == name[0] &&
- len == (FT_PtrDist)ft_strlen( (const char*)name ) )
+ if ( cur[0] == name[0] &&
+ len == ft_strlen( (const char*)name ) )
{
- FT_PtrDist n;
+ FT_UInt n;
for ( n = 1; n < len; n++ )
--- a/src/pfr/pfrload.c
+++ b/src/pfr/pfrload.c
@@ -449,9 +449,9 @@
FT_Byte* limit,
PFR_PhyFont phy_font )
{
- FT_Error error = FT_Err_Ok;
- FT_Memory memory = phy_font->memory;
- FT_PtrDist len = limit - p;
+ FT_Error error = FT_Err_Ok;
+ FT_Memory memory = phy_font->memory;
+ FT_UInt len = (FT_UInt)( limit - p );
if ( phy_font->font_id != NULL )
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -165,10 +165,10 @@
/* reallocation fails. */
/* */
FT_LOCAL_DEF( FT_Error )
- ps_table_add( PS_Table table,
- FT_Int idx,
- void* object,
- FT_PtrDist length )
+ ps_table_add( PS_Table table,
+ FT_Int idx,
+ void* object,
+ FT_UInt length )
{
if ( idx < 0 || idx >= table->max_elems )
{
@@ -176,12 +176,6 @@
return FT_THROW( Invalid_Argument );
}
- if ( length < 0 )
- {
- FT_ERROR(( "ps_table_add: invalid length\n" ));
- return FT_THROW( Invalid_Argument );
- }
-
/* grow the base block if needed */
if ( table->cursor + length > table->capacity )
{
@@ -932,7 +926,7 @@
FT_Memory memory )
{
FT_Byte* cur = *cursor;
- FT_PtrDist len = 0;
+ FT_UInt len = 0;
FT_Int count;
FT_String* result;
FT_Error error;
@@ -972,7 +966,7 @@
}
}
- len = cur - *cursor;
+ len = (FT_UInt)( cur - *cursor );
if ( cur >= limit || FT_ALLOC( result, len + 1 ) )
return 0;
--- a/src/psaux/psobjs.h
+++ b/src/psaux/psobjs.h
@@ -52,10 +52,10 @@
FT_Memory memory );
FT_LOCAL( FT_Error )
- ps_table_add( PS_Table table,
- FT_Int idx,
- void* object,
- FT_PtrDist length );
+ ps_table_add( PS_Table table,
+ FT_Int idx,
+ void* object,
+ FT_UInt length );
FT_LOCAL( void )
ps_table_done( PS_Table table );
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -599,9 +599,9 @@
/* each token is an immediate containing the name of the axis */
for ( n = 0; n < num_axis; n++ )
{
- T1_Token token = axis_tokens + n;
- FT_Byte* name;
- FT_PtrDist len;
+ T1_Token token = axis_tokens + n;
+ FT_Byte* name;
+ FT_UInt len;
/* skip first slash, if any */
@@ -608,7 +608,7 @@
if ( token->start[0] == '/' )
token->start++;
- len = token->limit - token->start;
+ len = (FT_UInt)( token->limit - token->start );
if ( len == 0 )
{
error = FT_THROW( Invalid_File_Format );
@@ -615,7 +615,7 @@
goto Exit;
}
- if ( FT_ALLOC( blend->axis_names[n], (FT_Long)( len + 1 ) ) )
+ if ( FT_ALLOC( blend->axis_names[n], len + 1 ) )
goto Exit;
name = (FT_Byte*)blend->axis_names[n];
@@ -1285,7 +1285,7 @@
if ( cur + 2 < limit && *cur == '/' && n < count )
{
- FT_PtrDist len;
+ FT_UInt len;
cur++;
@@ -1297,7 +1297,7 @@
if ( parser->root.error )
return;
- len = parser->root.cursor - cur;
+ len = (FT_UInt)( parser->root.cursor - cur );
parser->root.error = T1_Add_Table( char_table, charcode,
cur, len + 1 );
@@ -1606,7 +1606,7 @@
if ( *cur == '/' )
{
- FT_PtrDist len;
+ FT_UInt len;
if ( cur + 2 >= limit )
@@ -1616,7 +1616,7 @@
}
cur++; /* skip `/' */
- len = parser->root.cursor - cur;
+ len = (FT_UInt)( parser->root.cursor - cur );
if ( !read_binary_data( parser, &size, &base, IS_INCREMENTAL ) )
return;
@@ -1928,7 +1928,7 @@
/* look for immediates */
else if ( *cur == '/' && cur + 2 < limit )
{
- FT_PtrDist len;
+ FT_UInt len;
cur++;
@@ -1938,7 +1938,7 @@
if ( parser->root.error )
goto Exit;
- len = parser->root.cursor - cur;
+ len = (FT_UInt)( parser->root.cursor - cur );
if ( len > 0 && len < 22 && parser->root.cursor < limit )
{
@@ -1955,9 +1955,9 @@
if ( !name )
break;
- if ( cur[0] == name[0] &&
- len == (FT_PtrDist)ft_strlen( (const char *)name ) &&
- ft_memcmp( cur, name, len ) == 0 )
+ if ( cur[0] == name[0] &&
+ len == ft_strlen( (const char *)name ) &&
+ ft_memcmp( cur, name, len ) == 0 )
{
/* We found it -- run the parsing callback! */
/* We record every instance of every field */
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -433,7 +433,7 @@
if ( cur + 2 < limit && *cur == '/' && n < count )
{
- FT_PtrDist len;
+ FT_UInt len;
cur++;
@@ -445,7 +445,7 @@
if ( parser->root.error )
return;
- len = parser->root.cursor - cur;
+ len = (FT_UInt)( parser->root.cursor - cur );
parser->root.error = T1_Add_Table( char_table, charcode,
cur, len + 1 );
@@ -873,7 +873,7 @@
if ( *cur == '/' )
{
- FT_PtrDist len;
+ FT_UInt len;
if ( cur + 2 >= limit )
@@ -884,7 +884,7 @@
}
cur++; /* skip `/' */
- len = parser->root.cursor - cur;
+ len = (FT_UInt)( parser->root.cursor - cur );
error = T1_Add_Table( name_table, n, cur, len + 1 );
if ( error )
@@ -914,7 +914,7 @@
goto Fail;
}
- len = parser->root.cursor - cur;
+ len = (FT_UInt)( parser->root.cursor - cur );
error = T1_Add_Table( code_table, n, cur, len + 1 );
if ( error )
@@ -1135,7 +1135,7 @@
/* look for immediates */
else if ( *cur == '/' && cur + 2 < limit )
{
- FT_PtrDist len;
+ FT_UInt len;
cur++;
@@ -1145,7 +1145,7 @@
if ( parser->root.error )
goto Exit;
- len = parser->root.cursor - cur;
+ len = (FT_UInt)( parser->root.cursor - cur );
if ( len > 0 && len < 22 && parser->root.cursor < limit )
{
@@ -1164,9 +1164,9 @@
if ( !name )
continue;
- if ( cur[0] == name[0] &&
- len == (FT_PtrDist)ft_strlen( (const char *)name ) &&
- ft_memcmp( cur, name, len ) == 0 )
+ if ( cur[0] == name[0] &&
+ len == ft_strlen( (const char *)name ) &&
+ ft_memcmp( cur, name, len ) == 0 )
{
/* we found it -- run the parsing callback! */
parser->root.error = t42_load_keyword( face,