* src/bdf/bdflib.c (_bdf_atous): New function. (_bdf_parse_glyphs, _bdf_parse_start): Use it.
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
diff --git a/ChangeLog b/ChangeLog
index fac4871..e6671de 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2015-02-22 Werner Lemberg <wl@gnu.org>
+ * src/bdf/bdflib.c (_bdf_atous): New function.
+ (_bdf_parse_glyphs, _bdf_parse_start): Use it.
+
+2015-02-22 Werner Lemberg <wl@gnu.org>
+
[pcf] Signedness fixes.
* src/pcf/pcf.h, src/pcf/pcfdrivr.c: Apply.
diff --git a/src/bdf/bdflib.c b/src/bdf/bdflib.c
index abcfdee..fe97f0e 100644
--- a/src/bdf/bdflib.c
+++ b/src/bdf/bdflib.c
@@ -958,7 +958,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,
@@ -1864,8 +1911,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 +2272,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 );