Apply fixes for cppcheck nitpicks.

http://cppcheck.sourceforge.net/

Note that the current version heavily chokes on FreeType, delivering
even wrong results.  I will report those issues to the cppcheck team
so that a newer version gives improved results hopefully.

*/* Improve variable scopes.
*/* Remove redundant initializations which get overwritten.

* src/base/ftmac.c ,builds/mac/ftmac.c (count_faces_scalable):
Remove unused variable.

* src/base/ftdbgmem.c (ft_mem_table_destroy): `table' can't be zero.

* src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt1_entry_validate):
Remove functionless code.

* src/tools/ftrandom.c (main): Fix memory leak.
This commit is contained in:
Werner Lemberg 2013-06-04 10:30:48 +02:00
parent eeb8320445
commit dc624ca4dc
26 changed files with 269 additions and 181 deletions

View File

@ -1,3 +1,26 @@
2013-06-04 Werner Lemberg <wl@gnu.org>
Apply fixes for cppcheck nitpicks.
http://cppcheck.sourceforge.net/
Note that the current version heavily chokes on FreeType, delivering
even wrong results. I will report those issues to the cppcheck team
so that a newer version gives improved results hopefully.
*/* Improve variable scopes.
*/* Remove redundant initializations which get overwritten.
* src/base/ftmac.c ,builds/mac/ftmac.c (count_faces_scalable):
Remove unused variable.
* src/base/ftdbgmem.c (ft_mem_table_destroy): `table' can't be zero.
* src/gxvalid/gxvkern.c (gxv_kern_subtable_fmt1_entry_validate):
Remove functionless code.
* src/tools/ftrandom.c (main): Fix memory leak.
2013-06-03 Werner Lemberg <wl@gnu.org>
Add CFF_CONFIG_OPTION_OLD_ENGINE configuration option.

View File

@ -696,11 +696,9 @@ typedef short ResourceIndex;
count_faces_scalable( char* fond_data )
{
AsscEntry* assoc;
FamRec* fond;
short i, face, face_all;
fond = (FamRec*)fond_data;
face_all = EndianS16_BtoN( *( (short *)( fond_data +
sizeof ( FamRec ) ) ) ) + 1;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
@ -1186,7 +1184,7 @@ typedef short ResourceIndex;
ResFileRefNum res_ref;
ResourceIndex res_index;
Handle fond;
short num_faces_in_res, num_faces_in_fond;
short num_faces_in_res;
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
@ -1199,6 +1197,9 @@ typedef short ResourceIndex;
num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index )
{
short num_faces_in_fond;
fond = Get1IndResource( TTAG_FOND, res_index );
if ( ResError() )
break;

View File

@ -966,14 +966,15 @@
/* can make a single edge. */
if ( link )
{
AF_Segment seg1 = edge->first;
AF_Segment link1;
AF_Segment seg1 = edge->first;
FT_Pos dist2 = 0;
do
{
link1 = seg1->link;
AF_Segment link1 = seg1->link;
if ( link1 )
{
dist2 = AF_SEGMENT_DIST( link, link1 );

View File

@ -55,7 +55,7 @@
static FT_Error
af_face_globals_compute_script_coverage( AF_FaceGlobals globals )
{
FT_Error error = FT_Err_Ok;
FT_Error error;
FT_Face face = globals->face;
FT_CharMap old_charmap = face->charmap;
FT_Byte* gscripts = globals->glyph_scripts;

View File

@ -4,7 +4,7 @@
/* */
/* Memory debugger (body). */
/* */
/* Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2009 by */
/* Copyright 2001-2006, 2009, 2013 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -344,85 +344,80 @@
ft_mem_table_destroy( FT_MemTable table )
{
FT_ULong i;
FT_Long leak_count = 0;
FT_ULong leaks = 0;
FT_DumpMemory( table->memory );
if ( table )
/* remove all blocks from the table, revealing leaked ones */
for ( i = 0; i < table->size; i++ )
{
FT_Long leak_count = 0;
FT_ULong leaks = 0;
FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
/* remove all blocks from the table, revealing leaked ones */
for ( i = 0; i < table->size; i++ )
while ( node )
{
FT_MemNode *pnode = table->buckets + i, next, node = *pnode;
next = node->link;
node->link = 0;
while ( node )
if ( node->size > 0 )
{
next = node->link;
node->link = 0;
printf(
"leaked memory block at address %p, size %8ld in (%s:%ld)\n",
node->address, node->size,
FT_FILENAME( node->source->file_name ),
node->source->line_no );
if ( node->size > 0 )
{
printf(
"leaked memory block at address %p, size %8ld in (%s:%ld)\n",
node->address, node->size,
FT_FILENAME( node->source->file_name ),
node->source->line_no );
leak_count++;
leaks += node->size;
leak_count++;
leaks += node->size;
ft_mem_table_free( table, node->address );
}
node->address = NULL;
node->size = 0;
ft_mem_table_free( table, node );
node = next;
}
table->buckets[i] = 0;
}
ft_mem_table_free( table, table->buckets );
table->buckets = NULL;
table->size = 0;
table->nodes = 0;
/* remove all sources */
for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
{
FT_MemSource source, next;
for ( source = table->sources[i]; source != NULL; source = next )
{
next = source->link;
ft_mem_table_free( table, source );
ft_mem_table_free( table, node->address );
}
table->sources[i] = NULL;
node->address = NULL;
node->size = 0;
ft_mem_table_free( table, node );
node = next;
}
printf(
"FreeType: total memory allocations = %ld\n", table->alloc_total );
printf(
"FreeType: maximum memory footprint = %ld\n", table->alloc_max );
ft_mem_table_free( table, table );
if ( leak_count > 0 )
ft_mem_debug_panic(
"FreeType: %ld bytes of memory leaked in %ld blocks\n",
leaks, leak_count );
printf( "FreeType: no memory leaks detected\n" );
table->buckets[i] = 0;
}
ft_mem_table_free( table, table->buckets );
table->buckets = NULL;
table->size = 0;
table->nodes = 0;
/* remove all sources */
for ( i = 0; i < FT_MEM_SOURCE_BUCKETS; i++ )
{
FT_MemSource source, next;
for ( source = table->sources[i]; source != NULL; source = next )
{
next = source->link;
ft_mem_table_free( table, source );
}
table->sources[i] = NULL;
}
printf( "FreeType: total memory allocations = %ld\n",
table->alloc_total );
printf( "FreeType: maximum memory footprint = %ld\n",
table->alloc_max );
ft_mem_table_free( table, table );
if ( leak_count > 0 )
ft_mem_debug_panic(
"FreeType: %ld bytes of memory leaked in %ld blocks\n",
leaks, leak_count );
printf( "FreeType: no memory leaks detected\n" );
}

View File

@ -358,11 +358,9 @@
count_faces_scalable( char* fond_data )
{
AsscEntry* assoc;
FamRec* fond;
short i, face, face_all;
fond = (FamRec*)fond_data;
face_all = EndianS16_BtoN( *( (short *)( fond_data +
sizeof ( FamRec ) ) ) ) + 1;
assoc = (AsscEntry*)( fond_data + sizeof ( FamRec ) + 2 );
@ -800,7 +798,7 @@
ResFileRefNum res_ref;
ResourceIndex res_index;
Handle fond;
short num_faces_in_res, num_faces_in_fond;
short num_faces_in_res;
if ( noErr != FT_FSPathMakeRes( pathname, &res_ref ) )
@ -813,6 +811,9 @@
num_faces_in_res = 0;
for ( res_index = 1; ; ++res_index )
{
short num_faces_in_fond;
fond = Get1IndResource( TTAG_FOND, res_index );
if ( ResError() )
break;

View File

@ -520,7 +520,7 @@
unsigned long *alen )
{
unsigned long i, j;
char *fp, *dp;
char* dp;
*alen = 0;
@ -531,7 +531,9 @@
dp = list->field[0];
for ( i = j = 0; i < list->used; i++ )
{
fp = list->field[i];
char* fp = list->field[i];
while ( *fp )
dp[j++] = *fp++;

View File

@ -143,7 +143,7 @@
/* pointer to parsed font object */
CFF_Decoder* decoder = font->decoder;
FT_Bool needExtraSetup = FALSE;
FT_Bool needExtraSetup;
/* character space units */
CF2_Fixed boldenX = font->syntheticEmboldeningAmountX;

View File

@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT kern table validation (body). */
/* */
/* Copyright 2004, 2005, 2006, 2007 */
/* Copyright 2004-2007, 2013 */
/* by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@ -303,8 +303,6 @@
#ifdef GXV_LOAD_UNUSED_VARS
kernAction = FT_NEXT_USHORT( p );
kernValue = FT_NEXT_USHORT( p );
#else
p += 4;
#endif
}
}

View File

@ -200,7 +200,7 @@
/* without volatile on `error' GCC 4.1.1. emits: */
/* warning: variable 'error' might be clobbered by 'longjmp' or 'vfork' */
/* this warning seems spurious but --- */
FT_Error volatile error = FT_Err_Ok;
FT_Error volatile error;
FT_ValidatorRec volatile valid;

View File

@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT mort table validation (body). */
/* */
/* Copyright 2005 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* Copyright 2005, 2013 by suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@ -163,14 +163,15 @@
};
GXV_Validate_Func func;
FT_UShort i;
FT_UShort i;
GXV_NAME_ENTER( "subtables in a chain" );
for ( i = 0; i < nSubtables; i++ )
{
GXV_Validate_Func func;
FT_UShort length;
FT_UShort coverage;
#ifdef GXV_LOAD_UNUSED_VARS

View File

@ -4,7 +4,7 @@
/* */
/* TrueTypeGX/AAT morx table validation (body). */
/* */
/* Copyright 2005, 2008 by */
/* Copyright 2005, 2008, 2013 by */
/* suzuki toshiya, Masatake YAMATO, Red Hat K.K., */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
@ -57,8 +57,6 @@
};
GXV_Validate_Func func;
FT_UShort i;
@ -66,6 +64,8 @@
for ( i = 0; i < nSubtables; i++ )
{
GXV_Validate_Func func;
FT_ULong length;
FT_ULong coverage;
#ifdef GXV_LOAD_UNUSED_VARS

View File

@ -111,7 +111,7 @@
FT_Stream source )
{
FT_LzwState lzw = &zip->lzw;
FT_Error error = FT_Err_Ok;
FT_Error error;
zip->stream = stream;

View File

@ -92,7 +92,7 @@ THE SOFTWARE.
PCF_Toc toc = &face->toc;
PCF_Table tables;
FT_Memory memory = FT_FACE(face)->memory;
FT_Memory memory = FT_FACE( face )->memory;
FT_UInt n;
@ -402,7 +402,7 @@ THE SOFTWARE.
FT_ULong nprops, i;
FT_ULong format, size;
FT_Error error;
FT_Memory memory = FT_FACE(face)->memory;
FT_Memory memory = FT_FACE( face )->memory;
FT_ULong string_size;
FT_String* strings = 0;
@ -566,10 +566,10 @@ THE SOFTWARE.
pcf_get_metrics( FT_Stream stream,
PCF_Face face )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_FACE(face)->memory;
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
PCF_Metric metrics = 0;
PCF_Metric metrics = 0;
FT_ULong nmetrics, i;
@ -663,8 +663,8 @@ THE SOFTWARE.
pcf_get_bitmaps( FT_Stream stream,
PCF_Face face )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_FACE(face)->memory;
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_Long* offsets = NULL;
FT_Long bitmapSizes[GLYPHPADOPTIONS];
FT_ULong format, size;
@ -765,8 +765,8 @@ THE SOFTWARE.
pcf_get_encodings( FT_Stream stream,
PCF_Face face )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_FACE(face)->memory;
FT_Error error;
FT_Memory memory = FT_FACE( face )->memory;
FT_ULong format, size;
int firstCol, lastCol;
int firstRow, lastRow;
@ -914,7 +914,7 @@ THE SOFTWARE.
FT_ULong type )
{
FT_ULong format, size;
FT_Error error = FT_Err_Ok;
FT_Error error;
PCF_Accel accel = &face->accel;
@ -1014,20 +1014,20 @@ THE SOFTWARE.
( *(prop->value.atom) == 'B' || *(prop->value.atom) == 'b' ) )
{
face->style_flags |= FT_STYLE_FLAG_BOLD;
strings[1] = (char *)"Bold";
strings[1] = (char*)"Bold";
}
prop = pcf_find_property( pcf, "SETWIDTH_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
strings[3] = (char *)(prop->value.atom);
strings[3] = (char*)( prop->value.atom );
prop = pcf_find_property( pcf, "ADD_STYLE_NAME" );
if ( prop && prop->isString &&
*(prop->value.atom) &&
!( *(prop->value.atom) == 'N' || *(prop->value.atom) == 'n' ) )
strings[0] = (char *)(prop->value.atom);
strings[0] = (char*)( prop->value.atom );
for ( len = 0, nn = 0; nn < 4; nn++ )
{
@ -1041,7 +1041,7 @@ THE SOFTWARE.
if ( len == 0 )
{
strings[0] = (char *)"Regular";
strings[0] = (char*)"Regular";
lengths[0] = ft_strlen( strings[0] );
len = lengths[0] + 1;
}
@ -1079,7 +1079,7 @@ THE SOFTWARE.
for ( mm = 0; mm < len; mm++ )
if (s[mm] == ' ')
if ( s[mm] == ' ' )
s[mm] = '-';
}
@ -1097,7 +1097,7 @@ THE SOFTWARE.
PCF_Face face )
{
FT_Error error = FT_Err_Ok;
FT_Memory memory = FT_FACE(face)->memory;
FT_Memory memory = FT_FACE( face )->memory;
FT_Bool hasBDFAccelerators;

View File

@ -120,7 +120,6 @@
afm_stream_read_one( AFM_Stream stream )
{
char* str;
int ch;
afm_stream_skip_spaces( stream );
@ -131,7 +130,9 @@
while ( 1 )
{
ch = AFM_GETC();
int ch = AFM_GETC();
if ( AFM_IS_SPACE( ch ) )
break;
else if ( AFM_IS_NEWLINE( ch ) )
@ -160,7 +161,6 @@
afm_stream_read_string( AFM_Stream stream )
{
char* str;
int ch;
afm_stream_skip_spaces( stream );
@ -172,7 +172,9 @@
/* scan to eol */
while ( 1 )
{
ch = AFM_GETC();
int ch = AFM_GETC();
if ( AFM_IS_NEWLINE( ch ) )
{
stream->status = AFM_STREAM_STATUS_EOL;

View File

@ -401,13 +401,13 @@
FT_Fixed delta,
FT_Int dimension )
{
PSH_Hint hint;
FT_UInt count;
FT_UInt count;
for ( count = 0; count < table->max_hints; count++ )
{
hint = table->hints + count;
PSH_Hint hint = table->hints + count;
hint->cur_pos = FT_MulFix( hint->org_pos, scale ) + delta;
hint->cur_len = FT_MulFix( hint->org_len, scale );

View File

@ -316,7 +316,7 @@
FT_UInt bit_count,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_Error error;
PS_Mask mask;
@ -583,12 +583,13 @@
FT_UInt end_point )
{
FT_UInt count = dim->masks.num_masks;
PS_Mask mask;
if ( count > 0 )
{
mask = dim->masks.masks + count - 1;
PS_Mask mask = dim->masks.masks + count - 1;
mask->end_point = end_point;
}
}
@ -621,7 +622,7 @@
FT_UInt end_point,
FT_Memory memory )
{
FT_Error error = FT_Err_Ok;
FT_Error error;
/* reset current mask, if any */

View File

@ -806,8 +806,7 @@
static Bool
End_Profile( RAS_ARGS Bool overshoot )
{
Long h;
PProfile oldProfile;
Long h;
h = (Long)( ras.top - ras.cProfile->offset );
@ -821,6 +820,9 @@
if ( h > 0 )
{
PProfile oldProfile;
FT_TRACE6(( "Ending profile %p, start = %ld, height = %ld\n",
ras.cProfile, ras.cProfile->start, h ));
@ -877,7 +879,7 @@
Insert_Y_Turn( RAS_ARGS Int y )
{
PLong y_turns;
Int y2, n;
Int n;
n = ras.numTurns - 1;
@ -891,7 +893,9 @@
if ( n >= 0 && y > y_turns[n] )
while ( n >= 0 )
{
y2 = (Int)y_turns[n];
Int y2 = (Int)y_turns[n];
y_turns[n] = y;
y = y2;
n--;
@ -927,7 +931,6 @@
static Bool
Finalize_Profile_Table( RAS_ARG )
{
Int bottom, top;
UShort n;
PProfile p;
@ -939,6 +942,9 @@
{
while ( n > 0 )
{
Int bottom, top;
if ( n > 1 )
p->link = (PProfile)( p->offset + p->height );
else
@ -2032,8 +2038,6 @@
int i;
unsigned start;
PProfile lastProfile;
ras.fProfile = NULL;
ras.joint = FALSE;
@ -2051,7 +2055,8 @@
for ( i = 0; i < ras.outline.n_contours; i++ )
{
Bool o;
PProfile lastProfile;
Bool o;
ras.state = Unknown_State;
@ -2275,8 +2280,6 @@
PProfile right )
{
Long e1, e2;
int c1, c2;
Byte f1, f2;
Byte* target;
FT_UNUSED( y );
@ -2295,6 +2298,10 @@
if ( e2 >= 0 && e1 < ras.bWidth )
{
int c1, c2;
Byte f1, f2;
if ( e1 < 0 )
e1 = 0;
if ( e2 >= ras.bWidth )
@ -2518,21 +2525,24 @@
PProfile left,
PProfile right )
{
Long e1, e2;
PByte bits;
Byte f1;
FT_UNUSED( left );
FT_UNUSED( right );
if ( x2 - x1 < ras.precision )
{
Long e1, e2;
Byte f1;
e1 = CEILING( x1 );
e2 = FLOOR ( x2 );
if ( e1 == e2 )
{
PByte bits;
bits = ras.bTarget + ( y >> 3 );
f1 = (Byte)( 0x80 >> ( y & 7 ) );
@ -2729,8 +2739,6 @@
static void
Vertical_Gray_Sweep_Step( RAS_ARG )
{
Int c1, c2;
PByte pix, bit, bit2;
short* count = (short*)count_table;
Byte* grays;
@ -2739,6 +2747,9 @@
if ( ras.traceOfs > ras.gray_width )
{
PByte pix;
pix = ras.gTarget + ras.traceG + ras.gray_min_x * 4;
grays = ras.grays;
@ -2749,6 +2760,9 @@
Int last_bit = last_pixel & 3;
Bool over = 0;
Int c1, c2;
PByte bit, bit2;
if ( ras.gray_max_x >= last_cell && last_bit != 3 )
{
@ -2841,7 +2855,6 @@
{
Long e1, e2;
PByte pixel;
Byte color;
/* During the horizontal sweep, we only take care of drop-outs */
@ -2895,6 +2908,9 @@
if ( e1 >= 0 )
{
Byte color;
if ( x2 - x1 >= ras.precision_half )
color = ras.grays[2];
else

View File

@ -630,7 +630,7 @@ typedef ptrdiff_t FT_PtrDist;
TPos x2,
TCoord y2 )
{
TCoord ex1, ex2, fx1, fx2, delta, mod, lift, rem;
TCoord ex1, ex2, fx1, fx2, delta, mod;
long p, first, dx;
int incr;
@ -691,6 +691,9 @@ typedef ptrdiff_t FT_PtrDist;
if ( ex1 != ex2 )
{
TCoord lift, rem;
p = ONE_PIXEL * ( y2 - y1 + delta );
lift = (TCoord)( p / dx );
rem = (TCoord)( p % dx );
@ -1257,9 +1260,7 @@ typedef ptrdiff_t FT_PtrDist;
TPos area,
TCoord acount )
{
FT_Span* span;
int count;
int coverage;
int coverage;
/* compute the coverage line's coverage, depending on the */
@ -1301,6 +1302,10 @@ typedef ptrdiff_t FT_PtrDist;
if ( coverage )
{
FT_Span* span;
int count;
/* see whether we can add this span to the current list */
count = ras.num_gray_spans;
span = ras.gray_spans + count - 1;

View File

@ -155,8 +155,6 @@ names_dump( FILE* out,
case OUTPUT_WATCOM_LBC:
{
/* we must omit the .dll suffix from the library name */
char temp[512];
const char* dot;
@ -167,10 +165,12 @@ names_dump( FILE* out,
exit( 4 );
}
/* we must omit the .dll suffix from the library name */
dot = strchr( dll_name, '.' );
if ( dot != NULL )
{
int len = dot - dll_name;
char temp[512];
int len = dot - dll_name;
if ( len > (int)( sizeof ( temp ) - 1 ) )

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2005, 2007, 2008 by George Williams */
/* Copyright (C) 2005, 2007, 2008, 2013 by George Williams */
/*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@ -184,7 +184,6 @@
{
FT_Library context;
FT_Face face;
int i, num;
if ( FT_Init_FreeType( &context ) )
@ -203,6 +202,9 @@
TestFace( face );
else
{
int i, num;
num = face->num_faces;
FT_Done_Face( face );
@ -327,12 +329,9 @@
FindFonts( char** fontdirs,
char** extensions )
{
DIR* examples;
struct dirent* ent;
int i, max;
char buffer[1025];
struct stat statb;
int i, max;
char buffer[1025];
struct stat statb;
max = 0;
@ -340,6 +339,10 @@
for ( i = 0; fontdirs[i] != NULL; ++i )
{
DIR* examples;
struct dirent* ent;
examples = opendir( fontdirs[i] );
if ( examples == NULL )
{
@ -555,7 +558,6 @@
char** argv )
{
char **dirs, **exts;
char *pt, *end;
int dcnt = 0, ecnt = 0, rset = false, allexts = false;
int i;
time_t now;
@ -567,7 +569,10 @@
for ( i = 1; i < argc; ++i )
{
pt = argv[i];
char* pt = argv[i];
char* end;
if ( pt[0] == '-' && pt[1] == '-' )
++pt;
@ -633,12 +638,21 @@
}
if ( allexts )
{
free( exts );
exts = NULL;
}
else if ( ecnt == 0 )
{
free( exts );
exts = default_ext_list;
}
if ( dcnt == 0 )
{
free( dirs );
dirs = default_dir_list;
}
if ( testfile != NULL )
ExecuteTest( testfile ); /* This should never return */

View File

@ -17,12 +17,15 @@
static void
test_cos( void )
{
FT_Fixed f1, f2;
double d1, d2;
int i;
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Fixed f1, f2;
double d1, d2;
f1 = FT_Cos(i);
d1 = f1/65536.0;
d2 = cos( i*SPI );
@ -38,16 +41,18 @@
}
static void
test_sin( void )
{
FT_Fixed f1, f2;
double d1, d2;
int i;
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Fixed f1, f2;
double d1, d2;
f1 = FT_Sin(i);
d1 = f1/65536.0;
d2 = sin( i*SPI );
@ -66,12 +71,15 @@
static void
test_tan( void )
{
FT_Fixed f1, f2;
double d1, d2;
int i;
int i;
for ( i = 0; i < FT_ANGLE_PI2-0x2000000; i += 0x10000 )
{
FT_Fixed f1, f2;
double d1, d2;
f1 = FT_Tan(i);
d1 = f1/65536.0;
d2 = tan( i*SPI );
@ -90,12 +98,16 @@
static void
test_atan2( void )
{
FT_Fixed c2, s2;
double l, a, c1, s1;
int i, j;
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Fixed c2, s2;
double l, a, c1, s1;
int j;
l = 5.0;
a = i*SPI;
@ -117,16 +129,20 @@
}
}
static void
test_unit( void )
{
FT_Vector v;
double a, c1, s1;
FT_Fixed c2, s2;
int i;
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Vector v;
double a, c1, s1;
FT_Fixed c2, s2;
FT_Vector_Unit( &v, i );
a = ( i*SPI );
c1 = cos(a);
@ -150,12 +166,15 @@
static void
test_length( void )
{
FT_Vector v;
FT_Fixed l, l2;
int i;
int i;
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Vector v;
FT_Fixed l, l2;
l = (FT_Fixed)(500.0*65536.0);
v.x = (FT_Fixed)( l * cos( i*SPI ) );
v.y = (FT_Fixed)( l * sin( i*SPI ) );
@ -174,19 +193,27 @@
static void
test_rotate( void )
{
FT_Fixed c2, s2, c4, s4;
FT_Vector v;
double l, ra, a, c1, s1, cra, sra, c3, s3;
int i, j, rotate;
int rotate;
for ( rotate = 0; rotate < FT_ANGLE_2PI; rotate += 0x10000 )
{
double ra, cra, sra;
int i;
ra = rotate*SPI;
cra = cos( ra );
sra = sin( ra );
for ( i = 0; i < FT_ANGLE_2PI; i += 0x10000 )
{
FT_Fixed c2, s2, c4, s4;
FT_Vector v;
double l, a, c1, s1, c3, s3;
int j;
l = 500.0;
a = i*SPI;

View File

@ -122,7 +122,6 @@
start = (FT_Byte*)stream->cursor;
limit = (FT_Byte*)stream->limit;
p = start;
/* Figure out how long the width table is. */
/* This info is a little-endian short at offset 99. */

View File

@ -69,13 +69,13 @@
t1_get_name_index( T1_Face face,
FT_String* glyph_name )
{
FT_Int i;
FT_String* gname;
FT_Int i;
for ( i = 0; i < face->type1.num_glyphs; i++ )
{
gname = face->type1.glyph_names[i];
FT_String* gname = face->type1.glyph_names[i];
if ( !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)i;

View File

@ -72,13 +72,13 @@
t42_get_name_index( T42_Face face,
FT_String* glyph_name )
{
FT_Int i;
FT_String* gname;
FT_Int i;
for ( i = 0; i < face->type1.num_glyphs; i++ )
{
gname = face->type1.glyph_names[i];
FT_String* gname = face->type1.glyph_names[i];
if ( glyph_name[0] == gname[0] && !ft_strcmp( glyph_name, gname ) )
return (FT_UInt)ft_atol( (const char *)face->type1.charstrings[i] );

View File

@ -93,7 +93,6 @@
if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
{
FT_Int charcode, idx, min_char, max_char;
FT_Byte* char_name;
FT_Byte* glyph_name;
@ -109,6 +108,9 @@
charcode = 0;
for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
{
FT_Byte* char_name;
type1->encoding.char_index[charcode] = 0;
type1->encoding.char_name [charcode] = (char *)".notdef";