Commit c6a92202 authored by David Turner's avatar David Turner
Browse files

various clean-ups:

- using FT_UNUSED instead of UNUSED
- using FT_LONG64 and FT_INT64 instead of LONG64 & INT64
- using FT_SIZEOF_INT & FT_SIZEOF_LONG instead of...

- removed the #ifdefs that used SIZEOF_INT, instead we now
  use FT_Int32 and FT_UInt32 when needed to support
  32-bits quantity correctly on 64-bits systems..
parent aa8c7da0
......@@ -59,10 +59,10 @@
#undef STDC_HEADERS
/* the number of bytes in an `int' type. */
#define SIZEOF_INT 4
#define FT_SIZEOF_INT 4
/* the number of bytes in a `long' type. */
#define SIZEOF_LONG 4
#define FT_SIZEOF_LONG 4
/* Define if you have the memcpy function. */
#undef HAVE_MEMCPY
......@@ -99,12 +99,12 @@
typedef signed short FT_Int16;
typedef unsigned short FT_Word16;
#if SIZEOF_INT == 4
#if FT_SIZEOF_INT == 4
typedef signed int FT_Int32;
typedef unsigned int FT_Word32;
#elif SIZEOF_LONG == 4
#elif FT_SIZEOF_LONG == 4
typedef signed long FT_Int32;
typedef unsigned long FT_Word32;
......@@ -113,11 +113,11 @@
#error "no 32bit type found - please check your configuration files"
#endif
#if SIZEOF_LONG == 8
#if FT_SIZEOF_LONG == 8
/* LONG64 must be defined when a 64-bit type is available */
#define LONG64
#define INT64 long
#define FT_LONG64
#define FT_INT64 long
#else
......@@ -132,8 +132,8 @@
/* */
#ifdef FTCALC_USE_LONG_LONG
#define LONG64
#define INT64 long long
#define FT_LONG64
#define FT_INT64 long long
#endif /* FTCALC_USE_LONG_LONG */
#endif
......
......@@ -63,20 +63,20 @@
/* The number of bytes in an `int' type. */
#if UINT_MAX == 0xFFFFFFFF
#define SIZEOF_INT 4
#define FT_SIZEOF_INT 4
#elif UINT_MAX == 0xFFFF
#define SIZEOF_INT 2
#define FT_SIZEOF_INT 2
#elif UINT_MAX > 0xFFFFFFFF && UINT_MAX == 0xFFFFFFFFFFFFFFFF
#define SIZEOF_INT 8
#define FT_SIZEOF_INT 8
#else
#error "Unsupported number of bytes in `int' type!"
#endif
/* The number of bytes in a `long' type. */
#if ULONG_MAX == 0xFFFFFFFF
#define SIZEOF_LONG 4
#define FT_SIZEOF_LONG 4
#elif ULONG_MAX > 0xFFFFFFFF && ULONG_MAX == 0xFFFFFFFFFFFFFFFF
#define SIZEOF_LONG 8
#define FT_SIZEOF_LONG 8
#else
#error "Unsupported number of bytes in `long' type!"
#endif
......@@ -97,8 +97,8 @@
/* UNUSED is a macro used to indicate that a given parameter is not used */
/* this is only used to get rid of unpleasant compiler warnings.. */
#ifndef UNUSED
#define UNUSED( arg ) ( (arg)=(arg) )
#ifndef FT_UNUSED
#define FT_UNUSED( arg ) ( (arg)=(arg) )
#endif
......@@ -123,12 +123,12 @@
typedef signed short FT_Int16;
typedef unsigned short FT_Word16;
#if SIZEOF_INT == 4
#if FT_SIZEOF_INT == 4
typedef signed int FT_Int32;
typedef unsigned int FT_Word32;
#elif SIZEOF_LONG == 4
#elif FT_SIZEOF_LONG == 4
typedef signed long FT_Int32;
typedef unsigned long FT_Word32;
......@@ -137,11 +137,11 @@
#error "no 32bit type found - please check your configuration files"
#endif
#if SIZEOF_LONG == 8
#if FT_SIZEOF_LONG == 8
/* LONG64 must be defined when a 64-bit type is available */
#define LONG64
#define INT64 long
/* FT_LONG64 must be defined when a 64-bit type is available */
#define FT_LONG64
#define FT_INT64 long
#else
......@@ -156,8 +156,8 @@
/* */
#ifdef FTCALC_USE_LONG_LONG
#define LONG64
#define INT64 long long
#define FT_LONG64
#define FT_INT64 long long
#endif /* FTCALC_USE_LONG_LONG */
#endif
......
......@@ -47,7 +47,8 @@ typedef enum FT_Frame_Op_
ft_frame_off3_be = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 0 ),
ft_frame_off3_le = FT_MAKE_FRAME_OP( FT_FRAME_OP_OFF3, 1, 1 ),
ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 )
ft_frame_bytes = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 0 ),
ft_frame_skip = FT_MAKE_FRAME_OP( FT_FRAME_OP_BYTES, 0, 1 )
} FT_Frame_Op;
......@@ -96,6 +97,8 @@ typedef struct FT_Frame_Field_
count, \
(FT_UShort)(char*)&FT_FIELD_REF(struct_type,field) }
#define FT_FRAME_SKIP_BYTES( count ) { ft_frame_skip, count, 0 }
/*************************************************************************/
......
......@@ -111,7 +111,7 @@
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
#ifdef LONG64
#ifdef FT_LONG64
/*************************************************************************/
/* */
......@@ -252,7 +252,7 @@
while ( z )
{
z = (unsigned INT64)z >> 1;
z = (unsigned FT_INT64)z >> 1;
j++;
}
return j - 1;
......@@ -298,7 +298,7 @@
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
#else /* LONG64 */
#else /* FT_LONG64 */
/*************************************************************************/
......@@ -767,7 +767,7 @@
#endif /* FT_CONFIG_OPTION_OLD_CALCS */
#endif /* LONG64 */
#endif /* FT_LONG64 */
/* END */
......@@ -1084,7 +1084,7 @@
FT_Pos distance;
int c, n, first, orientation;
UNUSED( advance );
FT_UNUSED( advance );
/* compute control distance */
......
......@@ -540,20 +540,28 @@
continue; /* loop! */
case ft_frame_bytes: /* read a byte sequence */
case ft_frame_skip: /* skip some bytes */
{
FT_Int len = stream->limit - stream->cursor;
if ( len > fields->size )
len = fields->size;
p = (FT_Byte*)structure + fields->offset;
MEM_Copy( p, stream->cursor, len );
stream->cursor += len;
FT_Int len = fields->size;
if (stream->cursor + len > stream->limit)
{
error = FT_Err_Invalid_Stream_Operation;
goto Exit;
}
if (fields->value == ft_frame_bytes)
{
p = (FT_Byte*)structure + fields->offset;
MEM_Copy( p, stream->cursor, len );
}
stream->cursor += len;
fields++;
continue;
}
case ft_frame_byte:
case ft_frame_schar: /* read a single byte */
value = GET_Byte();
......@@ -644,7 +652,7 @@
/* now, compute the signed value is necessary */
if ( fields->value & FT_FRAME_OP_SIGNED )
value = (FT_ULong)( (FT_Long)( value << sign_shift ) >> sign_shift );
value = (FT_ULong)( (FT_Int32)( value << sign_shift ) >> sign_shift );
/* finally, store the value in the object */
......@@ -659,23 +667,11 @@
*(FT_UShort*)p = (FT_UShort)value;
break;
/* SIZEOF_INT is defined in <freetype/config/ftconfig.h> */
/* and gives the size in bytes of the `int' type on the */
/* current platform. */
/* */
/* Only on 16-bit systems the value of SIZEOF_INT can be */
/* less than 4. In this case SIZEOF_LONG is always 4. */
/* */
/* On a 64-bit system, SIZEOF_LONG can be 8, which is */
/* handled by the default case. */
/* */
#if SIZEOF_INT == 4
case 4:
*(FT_UInt*)p = (FT_UInt)value;
*(FT_UInt32*)p = (FT_UInt32)value;
break;
#endif
default:
default: /* for 64-bits systems */
*(FT_ULong*)p = (FT_ULong)value;
}
......
......@@ -70,7 +70,7 @@
void* ft_alloc( FT_Memory memory,
long size )
{
UNUSED( memory );
FT_UNUSED( memory );
return malloc( size );
}
......@@ -102,8 +102,8 @@
long new_size,
void* block )
{
UNUSED( memory );
UNUSED( cur_size );
FT_UNUSED( memory );
FT_UNUSED( cur_size );
return realloc( block, new_size );
}
......@@ -126,7 +126,7 @@
void ft_free( FT_Memory memory,
void* block )
{
UNUSED( memory );
FT_UNUSED( memory );
free( block );
}
......
......@@ -627,10 +627,10 @@
{
if ( ip + 3 >= limit )
goto Syntax_Error;
val = ( (FT_Long)ip[0] << 24 ) |
( (FT_Long)ip[1] << 16 ) |
( (FT_Long)ip[2] << 8 ) |
ip[3];
val = ( (FT_Int32)ip[0] << 24 ) |
( (FT_Int32)ip[1] << 16 ) |
( (FT_Int32)ip[2] << 8 ) |
ip[3];
ip += 4;
shift = 0;
}
......
......@@ -203,7 +203,7 @@
#else
UNUSED( driver );
FT_UNUSED( driver );
return T2_Err_Ok;
......@@ -233,7 +233,7 @@
#else
UNUSED( driver );
FT_UNUSED( driver );
#endif
}
......
......@@ -519,16 +519,6 @@
case t2_kind_fixed:
val = t2_parse_fixed( parser->stack );
/* SIZEOF_INT is defined in <freetype/config/ftconfig.h> */
/* and gives the size in bytes of the `int' type on the */
/* current platform. */
/* */
/* Only on 16-bit systems the value of SIZEOF_INT can be */
/* less than 4. In this case SIZEOF_LONG is always 4. */
/* */
/* On a 64-bit system, SIZEOF_LONG can be 8, which is */
/* handled by the default case. */
/* */
Store_Number:
switch ( field->size )
{
......@@ -540,13 +530,11 @@
*(FT_Short*)q = (FT_Short)val;
break;
#if SIZEOF_INT == 4
case 4:
*(FT_Int*)q = (FT_Int)val;
*(FT_Int32*)q = (FT_Int)val;
break;
#endif
default:
default: /* for 64-bit systems where long is 8 bytes */
*(FT_Long*)q = val;
}
break;
......@@ -578,12 +566,12 @@
case 2:
*(FT_Short*)q = (FT_Short)val;
break;
#if SIZEOF_INT == 4
case 4:
*(FT_Int*)q = (FT_Int)val;
*(FT_Int32*)q = (FT_Int)val;
break;
#endif
default:
default: /* for 64-bit systems */
*(FT_Long*)q = val;
}
......
......@@ -466,7 +466,7 @@
void t1_init_loader( CID_Loader* loader,
CID_Face face )
{
UNUSED( face );
FT_UNUSED( face );
MEM_Set( loader, 0, sizeof ( *loader ) );
}
......
......@@ -121,10 +121,10 @@
FT_Error error;
PSNames_Interface* psnames;
UNUSED( num_params );
UNUSED( params );
UNUSED( face_index );
UNUSED( stream );
FT_UNUSED( num_params );
FT_UNUSED( params );
FT_UNUSED( face_index );
FT_UNUSED( stream );
face->root.num_faces = 1;
......@@ -341,7 +341,7 @@
LOCAL_FUNC
FT_Error CID_Init_Driver( CID_Driver driver )
{
UNUSED( driver );
FT_UNUSED( driver );
return T1_Err_Ok;
}
......@@ -361,7 +361,7 @@
LOCAL_DEF
void CID_Done_Driver( CID_Driver driver )
{
UNUSED( driver );
FT_UNUSED( driver );
}
......
......@@ -761,13 +761,11 @@
*(FT_UShort*)q = (FT_UShort)val;
break;
#if SIZEOF_INT == 4
case 4:
*(FT_Int*)q = (FT_Int)val;
*(FT_Int32*)q = (FT_Int)val;
break;
#endif
default:
default: /* for 64-bit systems */
*(FT_Long*)q = val;
}
break;
......
......@@ -40,8 +40,8 @@
FT_Module_Interface CID_Get_Interface( FT_Driver driver,
const FT_String* interface )
{
UNUSED( driver );
UNUSED( interface );
FT_UNUSED( driver );
FT_UNUSED( interface );
return 0;
}
......
......@@ -146,7 +146,7 @@
/* Its purpose is simply to reduce compiler warnings. Note also that */
/* simply defining it as `(void)x' doesn't avoid warnings with certain */
/* ANSI compilers (e.g. LCC). */
#define UNUSED( x ) (x) = (x)
#define FT_UNUSED( x ) (x) = (x)
/* Disable the tracing mechanism for simplicity -- developers can */
/* activate it easily by redefining these two macros. */
......@@ -311,7 +311,7 @@
#define RAS_VARS /* void */
#define RAS_VAR /* void */
#define UNUSED_RASTER do ; while ( 0 )
#define FT_UNUSED_RASTER do ; while ( 0 )
#else /* TT_STATIC_RASTER */
......@@ -323,7 +323,7 @@
#define RAS_VARS raster,
#define RAS_VAR raster
#define UNUSED_RASTER UNUSED( raster )
#define FT_UNUSED_RASTER FT_UNUSED( raster )
#endif /* TT_STATIC_RASTER */
......@@ -2028,7 +2028,7 @@
{
Long pitch = ras.target.pitch;
UNUSED( max );
FT_UNUSED( max );
ras.traceIncr = (Short)-pitch;
......@@ -2053,9 +2053,9 @@
Byte f1, f2;
Byte* target;
UNUSED( y );
UNUSED( left );
UNUSED( right );
FT_UNUSED( y );
FT_UNUSED( left );
FT_UNUSED( right );
/* Drop-out control */
......@@ -2239,9 +2239,9 @@
Short* max )
{
/* nothing, really */
UNUSED( raster );
UNUSED( min );
UNUSED( max );
FT_UNUSED( raster );
FT_UNUSED( min );
FT_UNUSED( max );
}
......@@ -2256,8 +2256,8 @@
PByte bits;
Byte f1;
UNUSED( left );
UNUSED( right );
FT_UNUSED( left );
FT_UNUSED( right );
if ( x2 - x1 < ras.precision )
......@@ -2388,7 +2388,7 @@
void Horizontal_Sweep_Step( RAS_ARG )
{
/* Nothing, really */
UNUSED( raster );
FT_UNUSED( raster );
}
......@@ -2535,12 +2535,12 @@
PProfile right )
{
/* nothing, really */
UNUSED( raster );
UNUSED( y );
UNUSED( x1 );
UNUSED( x2 );
UNUSED( left );
UNUSED( right );
FT_UNUSED( raster );
FT_UNUSED( y );
FT_UNUSED( x1 );
FT_UNUSED( x2 );
FT_UNUSED( left );
FT_UNUSED( right );
}
......@@ -3097,7 +3097,7 @@
LOCAL_FUNC
FT_Error Render_Gray_Glyph( RAS_ARG )
{
UNUSED_RASTER;
FT_UNUSED_RASTER;
return FT_Err_Cannot_Render_Glyph;
}
......@@ -3235,9 +3235,9 @@
#else
UNUSED( raster );
UNUSED( mode );
UNUSED( palette );
FT_UNUSED( raster );
FT_UNUSED( mode );
FT_UNUSED( palette );
#endif
}
......
......@@ -77,7 +77,7 @@
FT_Module_Interface SFNT_Get_Interface( FT_Module module,
const char* interface )
{
UNUSED( module );
FT_UNUSED( module );
if ( strcmp( interface, "get_sfnt" ) == 0 )
return (FT_Module_Interface)get_sfnt_table;
......
......@@ -186,8 +186,8 @@
SFNT_Header sfnt_header;
/* for now, parameters are unused */
UNUSED( num_params );
UNUSED( params );
FT_UNUSED( num_params );
FT_UNUSED( params );
sfnt = (SFNT_Interface*)face->sfnt;
if ( !sfnt )
......@@ -246,9 +246,9 @@
FT_Error error;
SFNT_Interface* sfnt = (SFNT_Interface*)face->sfnt;
UNUSED( face_index );
UNUSED( num_params );
UNUSED( params );
FT_UNUSED( face_index );
FT_UNUSED( num_params );
FT_UNUSED( params );
/* Load tables */
......
......@@ -108,7 +108,7 @@
/* Its purpose is simply to reduce compiler warnings. Note also that */
/* simply defining it as `(void)x' doesn't avoid warnings with certain */
/* ANSI compilers (e.g. LCC). */
#define UNUSED( x ) (x) = (x)
#define FT_UNUSED( x ) (x) = (x)
/* Disable the tracing mechanism for simplicity -- developers can */
/* activate it easily by redefining these two macros. */
......@@ -125,7 +125,7 @@
#include "ftgrays.h"
#include <freetype/internal/ftobjs.h> /* for UNUSED() */
#include <freetype/internal/ftobjs.h> /* for FT_UNUSED() */
#include <freetype/internal/ftdebug.h> /* for FT_TRACE() and FT_ERROR() */
#include <freetype/ftoutln.h> /* for FT_Outline_Decompose() */
......@@ -1356,7 +1356,7 @@
TScan x, y, cover, area;
PCell start, cur, limit;
UNUSED( target );
FT_UNUSED( target );
cur = ras.cells;
......@@ -1879,7 +1879,7 @@
{
static TRaster the_raster;
UNUSED( memory );
FT_UNUSED( memory );
*araster = (FT_Raster)&the_raster;
......@@ -1893,7 +1893,7 @@