diff options
Diffstat (limited to 'freetype/src/bdf/bdflib.c')
-rw-r--r-- | freetype/src/bdf/bdflib.c | 133 |
1 files changed, 91 insertions, 42 deletions
diff --git a/freetype/src/bdf/bdflib.c b/freetype/src/bdf/bdflib.c index abcfdee7b..8655d0ed3 100644 --- a/freetype/src/bdf/bdflib.c +++ b/freetype/src/bdf/bdflib.c @@ -243,7 +243,7 @@ /* Mocklisp hash function. */ while ( *kp ) - res = ( res << 5 ) - res + *kp++; + res = ( res << 5 ) - res + (unsigned long)*kp++; ndp = bp + ( res % ht->size ); while ( *ndp ) @@ -264,9 +264,9 @@ hash_rehash( hashtable* ht, FT_Memory memory ) { - hashnode* obp = ht->table, *bp, *nbp; - int i, sz = ht->size; - FT_Error error = FT_Err_Ok; + hashnode* obp = ht->table, *bp, *nbp; + unsigned int i, sz = ht->size; + FT_Error error = FT_Err_Ok; ht->size <<= 1; @@ -294,8 +294,8 @@ hash_init( hashtable* ht, FT_Memory memory ) { - int sz = INITIAL_HT_SIZE; - FT_Error error = FT_Err_Ok; + unsigned int sz = INITIAL_HT_SIZE; + FT_Error error = FT_Err_Ok; ht->size = sz; @@ -316,8 +316,8 @@ { if ( ht != 0 ) { - int i, sz = ht->size; - hashnode* bp = ht->table; + unsigned int i, sz = ht->size; + hashnode* bp = ht->table; for ( i = 0; i < sz; i++, bp++ ) @@ -570,10 +570,11 @@ char* line, unsigned long linelen ) { - int mult, final_empty; - char *sp, *ep, *end; - char seps[32]; - FT_Error error = FT_Err_Ok; + unsigned long final_empty; + int mult; + char *sp, *ep, *end; + char seps[32]; + FT_Error error = FT_Err_Ok; /* Initialize the list. */ @@ -682,7 +683,7 @@ unsigned long lineno, buf_size; int refill, hold, to_skip; ptrdiff_t bytes, start, end, cursor, avail; - char* buf = 0; + char* buf = NULL; FT_Memory memory = stream->memory; FT_Error error = FT_Err_Ok; @@ -715,7 +716,7 @@ { bytes = (ptrdiff_t)FT_Stream_TryRead( stream, (FT_Byte*)buf + cursor, - (FT_ULong)( buf_size - cursor ) ); + buf_size - (unsigned long)cursor ); avail = cursor + bytes; cursor = 0; refill = 0; @@ -760,7 +761,7 @@ if ( FT_RENEW_ARRAY( buf, buf_size, new_size ) ) goto Exit; - cursor = buf_size; + cursor = (ptrdiff_t)buf_size; buf_size = new_size; } else @@ -858,9 +859,9 @@ /* Routine to convert an ASCII string into an unsigned long integer. */ static unsigned long - _bdf_atoul( char* s, - char** end, - int base ) + _bdf_atoul( char* s, + char** end, + unsigned int base ) { unsigned long v; const unsigned char* dmap; @@ -903,7 +904,7 @@ } - /* Routine to convert an ASCII string into an signed long integer. */ + /* Routine to convert an ASCII string into a signed long integer. */ static long _bdf_atol( char* s, char** end, @@ -958,7 +959,54 @@ } - /* Routine to convert an ASCII string into an signed short integer. */ + /* Routine to convert an ASCII string into an unsigned short integer. */ + static unsigned short + _bdf_atous( char* s, + char** end, + unsigned int base ) + { + unsigned short v; + const unsigned char* dmap; + + + if ( s == 0 || *s == 0 ) + return 0; + + /* Make sure the radix is something recognizable. Default to 10. */ + switch ( base ) + { + case 8: + dmap = odigits; + break; + case 16: + dmap = hdigits; + break; + default: + base = 10; + dmap = ddigits; + break; + } + + /* Check for the special hex prefix. */ + if ( *s == '0' && + ( *( s + 1 ) == 'x' || *( s + 1 ) == 'X' ) ) + { + base = 16; + dmap = hdigits; + s += 2; + } + + for ( v = 0; sbitset( dmap, *s ); s++ ) + v = (unsigned short)( v * base + a2i[(int)*s] ); + + if ( end != 0 ) + *end = s; + + return v; + } + + + /* Routine to convert an ASCII string into a signed short integer. */ static short _bdf_atos( char* s, char** end, @@ -1115,20 +1163,20 @@ /* Parse flags. */ -#define _BDF_START 0x0001 -#define _BDF_FONT_NAME 0x0002 -#define _BDF_SIZE 0x0004 -#define _BDF_FONT_BBX 0x0008 -#define _BDF_PROPS 0x0010 -#define _BDF_GLYPHS 0x0020 -#define _BDF_GLYPH 0x0040 -#define _BDF_ENCODING 0x0080 -#define _BDF_SWIDTH 0x0100 -#define _BDF_DWIDTH 0x0200 -#define _BDF_BBX 0x0400 -#define _BDF_BITMAP 0x0800 - -#define _BDF_SWIDTH_ADJ 0x1000 +#define _BDF_START 0x0001U +#define _BDF_FONT_NAME 0x0002U +#define _BDF_SIZE 0x0004U +#define _BDF_FONT_BBX 0x0008U +#define _BDF_PROPS 0x0010U +#define _BDF_GLYPHS 0x0020U +#define _BDF_GLYPH 0x0040U +#define _BDF_ENCODING 0x0080U +#define _BDF_SWIDTH 0x0100U +#define _BDF_DWIDTH 0x0200U +#define _BDF_BBX 0x0400U +#define _BDF_BITMAP 0x0800U + +#define _BDF_SWIDTH_ADJ 0x1000U #define _BDF_GLYPH_BITS ( _BDF_GLYPH | \ _BDF_ENCODING | \ @@ -1703,7 +1751,7 @@ glyph->encoding = p->glyph_enc; /* Reset the initial glyph info. */ - p->glyph_name = 0; + p->glyph_name = NULL; } else { @@ -1724,14 +1772,14 @@ glyph = font->unencoded + font->unencoded_used; glyph->name = p->glyph_name; - glyph->encoding = font->unencoded_used++; + glyph->encoding = (long)font->unencoded_used++; } else /* Free up the glyph name if the unencoded shouldn't be */ /* kept. */ FT_FREE( p->glyph_name ); - p->glyph_name = 0; + p->glyph_name = NULL; } /* Clear the flags that might be added when width and height are */ @@ -1864,8 +1912,8 @@ if ( error ) goto Exit; - glyph->bbx.width = _bdf_atos( p->list.field[1], 0, 10 ); - glyph->bbx.height = _bdf_atos( p->list.field[2], 0, 10 ); + glyph->bbx.width = _bdf_atous( p->list.field[1], 0, 10 ); + glyph->bbx.height = _bdf_atous( p->list.field[2], 0, 10 ); glyph->bbx.x_offset = _bdf_atos( p->list.field[3], 0, 10 ); glyph->bbx.y_offset = _bdf_atos( p->list.field[4], 0, 10 ); @@ -2225,8 +2273,8 @@ if ( error ) goto Exit; - p->font->bbx.width = _bdf_atos( p->list.field[1], 0, 10 ); - p->font->bbx.height = _bdf_atos( p->list.field[2], 0, 10 ); + p->font->bbx.width = _bdf_atous( p->list.field[1], 0, 10 ); + p->font->bbx.height = _bdf_atous( p->list.field[2], 0, 10 ); p->font->bbx.x_offset = _bdf_atos( p->list.field[3], 0, 10 ); p->font->bbx.y_offset = _bdf_atos( p->list.field[4], 0, 10 ); @@ -2313,7 +2361,8 @@ shift >>= 1; } - shift = (short)( ( bitcount > 3 ) ? 8 : ( 1 << bitcount ) ); + shift = (unsigned short)( ( bitcount > 3 ) ? 8 + : ( 1U << bitcount ) ); if ( p->font->bpp > shift || p->font->bpp != shift ) { |