Commit 10bf05a31d63c6674fd057514d1066d1f081f4aa

David Turner 2004-04-21T14:30:37

* src/cff/cffobjs.c (cff_face_init): fixed a small memory leak * src/autofit/afloader.c, src/autofit/afmodule.c, src/base/ftdebug.c: removed compiler warnings * src/autofit/aftypes.h, src/lzw/zopen.c, src/pcf/pcfdrivr.c, src/pcf/pcfread.c, src/psaux/psobjs.c, src/type42/t42drivr.c: changed data arrays to "const" to avoid populating the ".data" segment

diff --git a/ChangeLog b/ChangeLog
index 7e17d65..587f83e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2004-04-21  David Turner    <david@freetype.org>
+
+        * src/cff/cffobjs.c (cff_face_init): fixed a small memory leak
+
+        * src/autofit/afloader.c, src/autofit/afmodule.c, src/base/ftdebug.c:
+        removed compiler warnings
+
+        * src/autofit/aftypes.h, src/lzw/zopen.c, src/pcf/pcfdrivr.c,
+        src/pcf/pcfread.c, src/psaux/psobjs.c, src/type42/t42drivr.c:
+        changed data arrays to "const" to avoid populating the ".data"
+        segment
+
 2004-04-20  Werner Lemberg  <wl@gnu.org>
 
 	* src/psaux/psobjs.c (T1Radix): Renamed to...
@@ -262,7 +274,7 @@
 	(psh_blues_snap_stem): Don't use blue_shift but blue_threshold.
 
 	* src/pshinter/pshalgo.c (PSH_STRONG_THRESHOLD_MAXIMUM): New macro.
-	(psh_glyph_find_string_points): Use PSH_STRONG_THRESHOLD_MAXIMUM. 
+	(psh_glyph_find_string_points): Use PSH_STRONG_THRESHOLD_MAXIMUM.
 	(psh_glyph_find_blue_points): New function.  Needed for fonts like
 	p052003l.pfb (URW Palladio L Roman) which have flex curves at the
 	base line within blue zones, but the flex curves aren't covered by
@@ -362,7 +374,7 @@
 	accordingly.  These values are calculated outside of the function
 	now.
 	Add new argument `offsets'.
-	(IsMacResource): Use `FT_Raccess_Get_HeaderInfo' and 
+	(IsMacResource): Use `FT_Raccess_Get_HeaderInfo' and
 	`FT_Raccess_Get_DataOffsets'.
 	(load_face_in_embedded_rfork): New function.
 	(load_mac_face): Use load_face_in_embedded_rfork.
diff --git a/src/autofit/afloader.c b/src/autofit/afloader.c
index b2299ab..ed42238 100644
--- a/src/autofit/afloader.c
+++ b/src/autofit/afloader.c
@@ -71,7 +71,6 @@
   {
     FT_Error          error    = 0;
     FT_Face           face     = loader->face;
-    AF_FaceGlobals    globals  = loader->globals;
     FT_GlyphLoader    gloader  = loader->gloader;
     AF_ScriptMetrics  metrics  = loader->metrics;
     AF_GlyphHints     hints    = &loader->hints;
diff --git a/src/autofit/afmodule.c b/src/autofit/afmodule.c
index d088c24..f266a7a 100644
--- a/src/autofit/afmodule.c
+++ b/src/autofit/afmodule.c
@@ -31,6 +31,8 @@
                             FT_UInt        glyph_index,
                             FT_Int32       load_flags )
   {
+    FT_UNUSED(size);
+
     return af_loader_load_glyph( module->loader, slot->face,
                                  glyph_index, load_flags );
   }
diff --git a/src/autofit/aftypes.h b/src/autofit/aftypes.h
index 0e4d590..abd2ff5 100644
--- a/src/autofit/aftypes.h
+++ b/src/autofit/aftypes.h
@@ -17,7 +17,7 @@ FT_BEGIN_HEADER
  /**************************************************************************/
  /**************************************************************************/
 
-#define AF_DEBUG
+#define xxAF_DEBUG
 
 #ifdef AF_DEBUG
 
diff --git a/src/base/ftdebug.c b/src/base/ftdebug.c
index b84edbf..a6c1841 100644
--- a/src/base/ftdebug.c
+++ b/src/base/ftdebug.c
@@ -159,7 +159,7 @@
         q = p;
         while ( *p && *p != ':' )
           p++;
-          
+
         if ( *p == ':' && p > q )
         {
           FT_Int  n, i, len = (FT_Int)( p - q );
@@ -221,16 +221,18 @@
 
 
   FT_EXPORT_DEF( FT_Int )
-  FT_Trace_Get_Count( void ) 
+  FT_Trace_Get_Count( void )
   {
-    return 0; 
+    return 0;
   }
 
 
   FT_EXPORT_DEF( const char * )
-  FT_Trace_Get_Name( FT_Int  idx ) 
-  { 
-    return NULL; 
+  FT_Trace_Get_Name( FT_Int  idx )
+  {
+    FT_UNUSED( idx );
+
+    return NULL;
   }
 
 
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 5e9e70a..bbe1654 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -73,7 +73,7 @@
 
     sbit_metrics = &size->strike_metrics;
 
-    error = sfnt->set_sbit_strike( face, 
+    error = sfnt->set_sbit_strike( face,
                                    metrics->x_ppem, metrics->y_ppem,
                                    &strike_index );
 
@@ -100,7 +100,7 @@
       size->strike_index = (FT_UInt)strike_index;
     }
     else
-    {   
+    {
       size->strike_index = 0xFFFFU;
 
       sbit_metrics->x_ppem      = 0;
@@ -113,7 +113,7 @@
 
     return error;
   }
-   
+
 #endif /* TT_CONFIG_OPTION_EMBEDDED_BITMAPS */
 
 
@@ -503,33 +503,50 @@
           char*  fullp  = full;
           char*  family = root->family_name;
 
-
+         /* we're going to try to extract the style name from the
+          * full name. We need to ignore spaces and dashes during
+          * the search.
+          */
           if ( full )
           {
             while ( *fullp )
             {
+             /* skip common characters at the start of both strings
+              */
               if ( *fullp == *family )
               {
                 family++;
                 fullp++;
+                continue;
               }
-              else
+
+             /* ignore spaces or dashes in full name during comparison
+              */
+              if ( *fullp == ' ' || *fullp == '-' )
+              {
+                fullp++;
+                continue;
+              }
+             /* ignore spaces and dashes in family name during comparison
+              */
+              if ( *family == ' ' || *family == '-' )
+              {
+                family++;
+                continue;
+              }
+
+              if ( !*family && *fullp )
               {
-                if ( *fullp == ' ' || *fullp == '-' )
-                  fullp++;
-                else if ( *family == ' ' || *family == '-' )
-                  family++;
-                else
-                {
-                  if ( !*family )
-                  {
-                    style_name = cff_strcpy( memory, fullp );
-                    FT_FREE( full );
-                  }
-                  break;
-                }
+               /* the full name begins with the same characters than the
+                * family name, with spaces and dashes removed. In this
+                * case, the remaining string in "fullp" will be used
+                * as the style name
+                */
+                style_name = cff_strcpy( memory, fullp );
               }
+              break;
             }
+            FT_FREE( full );
           }
         }
         else
diff --git a/src/lzw/zopen.c b/src/lzw/zopen.c
index 75e619b..5267f16 100644
--- a/src/lzw/zopen.c
+++ b/src/lzw/zopen.c
@@ -173,7 +173,7 @@ zclose(s_zstate_t *zs)
  * code in turn.  When the buffer fills up empty it and start over.
  */
 
-static char_type rmask[9] =
+static const char_type rmask[9] =
 	{0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff};
 
 /*
@@ -258,7 +258,7 @@ zread(s_zstate_t *zs)
 		*stackp++ = finchar = tab_suffixof(code);
 
 		/* And put them out in forward order.  */
-middle:		
+middle:
 		if (stackp == de_stack)
 			continue;
 
diff --git a/src/pcf/pcfdrivr.c b/src/pcf/pcfdrivr.c
index 5cf83e9..80f043f 100644
--- a/src/pcf/pcfdrivr.c
+++ b/src/pcf/pcfdrivr.c
@@ -501,7 +501,7 @@ THE SOFTWARE.
   *  BDF SERVICE
   *
   */
-  
+
   static FT_Error
   pcf_get_bdf_property( PCF_Face          face,
                         const char*       prop_name,
@@ -546,7 +546,7 @@ THE SOFTWARE.
   }
 
 
-  static FT_Service_BDFRec  pcf_service_bdf =
+  static const FT_Service_BDFRec  pcf_service_bdf =
   {
     (FT_BDF_GetCharsetIdFunc)pcf_get_charset_id,
     (FT_BDF_GetPropertyFunc) pcf_get_bdf_property
@@ -559,14 +559,14 @@ THE SOFTWARE.
   *
   */
 
-  static FT_ServiceDescRec  pcf_services[] =
+  static const FT_ServiceDescRec  pcf_services[] =
   {
     { FT_SERVICE_ID_BDF,       &pcf_service_bdf },
     { FT_SERVICE_ID_XF86_NAME, FT_XF86_FORMAT_PCF },
     { NULL, NULL }
   };
-  
-  
+
+
   static FT_Module_Interface
   pcf_driver_requester( FT_Module    module,
                         const char*  name )
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index c8a1404..3beabbf 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -49,7 +49,7 @@ THE SOFTWARE.
 
 
 #if defined( FT_DEBUG_LEVEL_TRACE )
-  static const char*  tableNames[] =
+  static const char* const  tableNames[] =
   {
     "prop", "accl", "mtrcs", "bmps", "imtrcs",
     "enc", "swidth", "names", "accel"
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index accaf29..7087ca5 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -285,7 +285,7 @@
 #if 'A' == 65
   /* ASCII */
 
-  char ft_char_table[128] =
+  static const char ft_char_table[128] =
   {
     /* 0x00 */
     -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
@@ -306,7 +306,7 @@
 #if 'A' == 193
   /* EBCDIC */
 
-  char ft_char_table[128] =
+  static const char ft_char_table[128] =
   {
     /* 0x80 */
     -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, -1, -1, -1, -1, -1, -1,
diff --git a/src/type42/t42drivr.c b/src/type42/t42drivr.c
index f4a7bec..2afe2db 100644
--- a/src/type42/t42drivr.c
+++ b/src/type42/t42drivr.c
@@ -102,7 +102,7 @@
   }
 
 
-  static FT_Service_GlyphDictRec  t42_service_glyph_dict =
+  static const FT_Service_GlyphDictRec  t42_service_glyph_dict =
   {
     (FT_GlyphDict_GetNameFunc)  t42_get_glyph_name,
     (FT_GlyphDict_NameIndexFunc)t42_get_name_index
@@ -122,7 +122,7 @@
   }
 
 
-  static FT_Service_PsFontNameRec  t42_service_ps_font_name =
+  static const FT_Service_PsFontNameRec  t42_service_ps_font_name =
   {
     (FT_PsName_GetFunc)t42_get_ps_font_name
   };