Commit c595c06c61527f1386aa0a16a2a66bfbad3f049f

suzuki toshiya 2009-08-01T00:32:12

pcf: Handle the string length by size_t variables.

diff --git a/ChangeLog b/ChangeLog
index 7cb3dd0..7161ffa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2009-07-31  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
 
+	pcf: Handle the string length by size_t variables.
+
+	* src/pcf/pcfread.c (pcf_interpret_style): The types
+	of nn, len, lengths[4] are changed to size_t, because
+	they are loaded by (or compared with) ft_strlen().
+
+	* src/pcf/pcfutil.c (BitOrderInvert, TwoByteSwap,
+	FourByteSwap): The type of the 2nd argument `nbytes'
+	is changed to size_t, for similarity with ANSI C
+	string functions.
+
+	* src/pcf/pcfdrivr.c (PCF_Glyph_Load): The type of
+	`bytes' is changed to FT_Offset, because it is passed
+	to FT_ALLOC(), via ft_glyphslot_alloc_bitmap().  At
+	least, using unsigned type is better.
+
+2009-07-31  suzuki toshiya <mpsuzuki@hiroshima-u.ac.jp>
+
 	pcf: Fix some data types mismatching with their sources.
 
 	* src/pcf/pcfread.c (pcf_seek_to_table_type,
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 799b498..b34e542 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -455,7 +455,7 @@ THE SOFTWARE.
     FT_Error    error  = PCF_Err_Ok;
     FT_Bitmap*  bitmap = &slot->bitmap;
     PCF_Metric  metric;
-    int         bytes;
+    FT_Offset   bytes;
 
     FT_UNUSED( load_flags );
 
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index 4ec4db8..cbbd105 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -992,9 +992,9 @@ THE SOFTWARE.
 
     PCF_Property  prop;
 
-    int    nn, len;
-    char*  strings[4] = { NULL, NULL, NULL, NULL };
-    int    lengths[4];
+    size_t  nn, len;
+    char*   strings[4] = { NULL, NULL, NULL, NULL };
+    size_t  lengths[4];
 
 
     face->style_flags = 0;
@@ -1076,7 +1076,7 @@ THE SOFTWARE.
         /* add_style_name and setwidth_name     */
         if ( nn == 0 || nn == 3 )
         {
-          int  mm;
+          size_t  mm;
 
 
           for ( mm = 0; mm < len; mm++ )
diff --git a/src/pcf/pcfutil.c b/src/pcf/pcfutil.c
index 67ddbe8..b91274f 100644
--- a/src/pcf/pcfutil.c
+++ b/src/pcf/pcfutil.c
@@ -42,9 +42,9 @@ in this Software without prior written authorization from The Open Group.
 
   FT_LOCAL_DEF( void )
   BitOrderInvert( unsigned char*  buf,
-                  int             nbytes )
+                  size_t          nbytes )
   {
-    for ( ; --nbytes >= 0; buf++ )
+    for ( ; nbytes > 0; nbytes--, buf++ )
     {
       unsigned int  val = *buf;
 
@@ -64,7 +64,7 @@ in this Software without prior written authorization from The Open Group.
 
   FT_LOCAL_DEF( void )
   TwoByteSwap( unsigned char*  buf,
-               int             nbytes )
+               size_t          nbytes )
   {
     unsigned char  c;
 
@@ -83,7 +83,7 @@ in this Software without prior written authorization from The Open Group.
 
   FT_LOCAL_DEF( void )
   FourByteSwap( unsigned char*  buf,
-                int             nbytes )
+                size_t          nbytes )
   {
     unsigned char  c;
 
diff --git a/src/pcf/pcfutil.h b/src/pcf/pcfutil.h
index 1557be3..ce10fb5 100644
--- a/src/pcf/pcfutil.h
+++ b/src/pcf/pcfutil.h
@@ -37,15 +37,15 @@ FT_BEGIN_HEADER
 
   FT_LOCAL( void )
   BitOrderInvert( unsigned char*  buf,
-                  int             nbytes );
+                  size_t          nbytes );
 
   FT_LOCAL( void )
   TwoByteSwap( unsigned char*  buf,
-               int             nbytes );
+               size_t          nbytes );
 
   FT_LOCAL( void )
   FourByteSwap( unsigned char*  buf,
-                int             nbytes );
+                size_t          nbytes );
 
 FT_END_HEADER