[bdf] Signedness fixes. * src/bdf/bdf.h, src/bdf/bdfdrivr.c, src/bdf/bdfdrivr.h, src/bdf/bdflib.c: Apply.
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 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
diff --git a/ChangeLog b/ChangeLog
index e6671de..4d48343 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2015-02-22 Werner Lemberg <wl@gnu.org>
+ [bdf] Signedness fixes.
+
+ * src/bdf/bdf.h, src/bdf/bdfdrivr.c, src/bdf/bdfdrivr.h,
+ src/bdf/bdflib.c: Apply.
+
+2015-02-22 Werner Lemberg <wl@gnu.org>
+
* src/bdf/bdflib.c (_bdf_atous): New function.
(_bdf_parse_glyphs, _bdf_parse_start): Use it.
diff --git a/src/bdf/bdf.h b/src/bdf/bdf.h
index d11be6f..bd5a2e4 100644
--- a/src/bdf/bdf.h
+++ b/src/bdf/bdf.h
@@ -167,10 +167,10 @@ FT_BEGIN_HEADER
typedef struct hashtable_
{
- int limit;
- int size;
- int used;
- hashnode* table;
+ unsigned int limit;
+ unsigned int size;
+ unsigned int used;
+ hashnode* table;
} hashtable;
@@ -194,7 +194,7 @@ FT_BEGIN_HEADER
char* name; /* Name of the font. */
bdf_bbx_t bbx; /* Font bounding box. */
- long point_size; /* Point size of the font. */
+ unsigned long point_size; /* Point size of the font. */
unsigned long resolution_x; /* Font horizontal resolution. */
unsigned long resolution_y; /* Font vertical resolution. */
diff --git a/src/bdf/bdfdrivr.c b/src/bdf/bdfdrivr.c
index 55a428c..6d7dced 100644
--- a/src/bdf/bdfdrivr.c
+++ b/src/bdf/bdfdrivr.c
@@ -106,7 +106,7 @@ THE SOFTWARE.
mid = ( min + max ) >> 1;
- code = encodings[mid].enc;
+ code = (FT_ULong)encodings[mid].enc;
if ( charcode == code )
{
@@ -146,7 +146,7 @@ THE SOFTWARE.
mid = ( min + max ) >> 1;
- code = encodings[mid].enc;
+ code = (FT_ULong)encodings[mid].enc;
if ( charcode == code )
{
@@ -165,7 +165,7 @@ THE SOFTWARE.
charcode = 0;
if ( min < cmap->num_encodings )
{
- charcode = encodings[min].enc;
+ charcode = (FT_ULong)encodings[min].enc;
result = encodings[min].glyph + 1;
}
@@ -427,7 +427,7 @@ THE SOFTWARE.
/* the number of glyphs (with one slot for the undefined glyph */
/* at position 0 and all unencoded glyphs) */
- bdfface->num_glyphs = font->glyphs_size + 1;
+ bdfface->num_glyphs = (FT_Long)( font->glyphs_size + 1 );
bdfface->num_fixed_sizes = 1;
if ( FT_NEW_ARRAY( bdfface->available_sizes, 1 ) )
@@ -494,7 +494,7 @@ THE SOFTWARE.
{
(face->en_table[n]).enc = cur[n].encoding;
FT_TRACE4(( " idx %d, val 0x%lX\n", n, cur[n].encoding ));
- (face->en_table[n]).glyph = (FT_Short)n;
+ (face->en_table[n]).glyph = (FT_UShort)n;
if ( cur[n].encoding == font->default_char )
{
@@ -734,11 +734,11 @@ THE SOFTWARE.
slot->bitmap_left = glyph.bbx.x_offset;
slot->bitmap_top = glyph.bbx.ascent;
- slot->metrics.horiAdvance = glyph.dwidth << 6;
- slot->metrics.horiBearingX = glyph.bbx.x_offset << 6;
- slot->metrics.horiBearingY = glyph.bbx.ascent << 6;
- slot->metrics.width = bitmap->width << 6;
- slot->metrics.height = bitmap->rows << 6;
+ slot->metrics.horiAdvance = (FT_Pos)( glyph.dwidth << 6 );
+ slot->metrics.horiBearingX = (FT_Pos)( glyph.bbx.x_offset << 6 );
+ slot->metrics.horiBearingY = (FT_Pos)( glyph.bbx.ascent << 6 );
+ slot->metrics.width = (FT_Pos)( bitmap->width << 6 );
+ slot->metrics.height = (FT_Pos)( bitmap->rows << 6 );
/*
* XXX DWIDTH1 and VVECTOR should be parsed and
diff --git a/src/bdf/bdfdrivr.h b/src/bdf/bdfdrivr.h
index ca0dae5..3c61d64 100644
--- a/src/bdf/bdfdrivr.h
+++ b/src/bdf/bdfdrivr.h
@@ -43,7 +43,7 @@ FT_BEGIN_HEADER
typedef struct BDF_encoding_el_
{
- FT_ULong enc;
+ FT_Long enc;
FT_UShort glyph;
} BDF_encoding_el;
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index fe97f0e..c1d4e59 100644
--- a/src/bdf/bdflib.c
+++ b/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. */
@@ -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,
@@ -1162,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 | \
@@ -1771,7 +1772,7 @@
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 */
@@ -2360,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 )
{