freetype-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[freetype2] master 78c02bc: [type1, type42] Use `const' for string liter


From: Alexei Podtelezhnikov
Subject: [freetype2] master 78c02bc: [type1, type42] Use `const' for string literals.
Date: Mon, 10 Jun 2019 23:10:45 -0400 (EDT)

branch: master
commit 78c02bc110b6a605c41487d8c26ae18960df251b
Author: Alexei Podtelezhnikov <address@hidden>
Commit: Alexei Podtelezhnikov <address@hidden>

    [type1,type42] Use `const' for string literals.
    
    * include/freetype/internal/psaux.h (PS_Table_FuncsRec): Updated.
    * include/freetype/internal/t1types.h (T1_EncodingRec): Updated.
    * src/psaux/psobjs.[ch] (ps_table_add): Updated.
    * src/type1/t1load.c (T1_Open_Face, parse_encoding): Updated.
    * src/type42/t42objs.c (T42_Open_Face): Updated.
    * src/type42/t42parse.c (t42_parse_encoding): Updated.
    
    * src/cff/cffobjs.c (cff_face_init): Minor.
---
 ChangeLog                           | 13 +++++++++++++
 include/freetype/internal/psaux.h   |  8 ++++----
 include/freetype/internal/t1types.h |  4 ++--
 src/cff/cffobjs.c                   |  2 +-
 src/psaux/psobjs.c                  |  8 ++++----
 src/psaux/psobjs.h                  |  8 ++++----
 src/type1/t1load.c                  | 31 ++++++++++++-------------------
 src/type42/t42objs.c                | 21 ++++++++++-----------
 src/type42/t42parse.c               | 10 ++--------
 9 files changed, 52 insertions(+), 53 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 54222e7..6e07120 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2019-06-10  Alexei Podtelezhnikov  <address@hidden>
 
+       [type1,type42] Use `const' for string literals.
+
+       * include/freetype/internal/psaux.h (PS_Table_FuncsRec): Updated.
+       * include/freetype/internal/t1types.h (T1_EncodingRec): Updated.
+       * src/psaux/psobjs.[ch] (ps_table_add): Updated.
+       * src/type1/t1load.c (T1_Open_Face, parse_encoding): Updated.
+       * src/type42/t42objs.c (T42_Open_Face): Updated.
+       * src/type42/t42parse.c (t42_parse_encoding): Updated.
+
+       * src/cff/cffobjs.c (cff_face_init): Minor.
+
+2019-06-10  Alexei Podtelezhnikov  <address@hidden>
+
        [bdf,pcf] Use `const' for string literals.
 
        * src/bdf/bdf.h (bdf_property_t): Updated `name'.
diff --git a/include/freetype/internal/psaux.h 
b/include/freetype/internal/psaux.h
index 3ab01c3..f962a97 100644
--- a/include/freetype/internal/psaux.h
+++ b/include/freetype/internal/psaux.h
@@ -96,10 +96,10 @@ FT_BEGIN_HEADER
     (*done)( PS_Table  table );
 
     FT_Error
-    (*add)( PS_Table  table,
-            FT_Int    idx,
-            void*     object,
-            FT_UInt   length );
+    (*add)( PS_Table     table,
+            FT_Int       idx,
+            const void*  object,
+            FT_UInt      length );
 
     void
     (*release)( PS_Table  table );
diff --git a/include/freetype/internal/t1types.h 
b/include/freetype/internal/t1types.h
index e197a1a..d94c8c1 100644
--- a/include/freetype/internal/t1types.h
+++ b/include/freetype/internal/t1types.h
@@ -76,8 +76,8 @@ FT_BEGIN_HEADER
     FT_Int       code_first;
     FT_Int       code_last;
 
-    FT_UShort*   char_index;
-    FT_String**  char_name;
+    FT_UShort*         char_index;
+    const FT_String**  char_name;
 
   } T1_EncodingRec, *T1_Encoding;
 
diff --git a/src/cff/cffobjs.c b/src/cff/cffobjs.c
index 1a1030c..f76245f 100644
--- a/src/cff/cffobjs.c
+++ b/src/cff/cffobjs.c
@@ -962,7 +962,7 @@
           cffface->style_name = style_name;
         else
           /* assume "Regular" style if we don't know better */
-          cffface->style_name = cff_strcpy( memory, (char *)"Regular" );
+          cffface->style_name = cff_strcpy( memory, "Regular" );
 
         /********************************************************************
          *
diff --git a/src/psaux/psobjs.c b/src/psaux/psobjs.c
index e2168a3..8bfdb92 100644
--- a/src/psaux/psobjs.c
+++ b/src/psaux/psobjs.c
@@ -174,10 +174,10 @@
    *   reallocation fails.
    */
   FT_LOCAL_DEF( FT_Error )
-  ps_table_add( PS_Table  table,
-                FT_Int    idx,
-                void*     object,
-                FT_UInt   length )
+  ps_table_add( PS_Table     table,
+                FT_Int       idx,
+                const void*  object,
+                FT_UInt      length )
   {
     if ( idx < 0 || idx >= table->max_elems )
     {
diff --git a/src/psaux/psobjs.h b/src/psaux/psobjs.h
index 9466a1d..c44dc45 100644
--- a/src/psaux/psobjs.h
+++ b/src/psaux/psobjs.h
@@ -53,10 +53,10 @@ FT_BEGIN_HEADER
                 FT_Memory  memory );
 
   FT_LOCAL( FT_Error )
-  ps_table_add( PS_Table  table,
-                FT_Int    idx,
-                void*     object,
-                FT_UInt   length );
+  ps_table_add( PS_Table     table,
+                FT_Int       idx,
+                const void*  object,
+                FT_UInt      length );
 
   FT_LOCAL( void )
   ps_table_done( PS_Table  table );
diff --git a/src/type1/t1load.c b/src/type1/t1load.c
index 3896af7..5cffdfa 100644
--- a/src/type1/t1load.c
+++ b/src/type1/t1load.c
@@ -1507,12 +1507,7 @@
 
       /* We need to `zero' out encoding_table.elements */
       for ( n = 0; n < array_size; n++ )
-      {
-        char*  notdef = (char *)".notdef";
-
-
-        (void)T1_Add_Table( char_table, n, notdef, 8 );
-      }
+        (void)T1_Add_Table( char_table, n, ".notdef", 8 );
 
       /* Now we need to read records of the form                */
       /*                                                        */
@@ -2147,7 +2142,6 @@
 
       /* 0 333 hsbw endchar */
       FT_Byte  notdef_glyph[] = { 0x8B, 0xF7, 0xE1, 0x0D, 0x0E };
-      char*    notdef_name    = (char *)".notdef";
 
 
       error = T1_Add_Table( swap_table, 0,
@@ -2162,7 +2156,7 @@
       if ( error )
         goto Fail;
 
-      error = T1_Add_Table( name_table, 0, notdef_name, 8 );
+      error = T1_Add_Table( name_table, 0, ".notdef", 8 );
       if ( error )
         goto Fail;
 
@@ -2633,8 +2627,7 @@
     /* we must now build type1.encoding when we have a custom array */
     if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
     {
-      FT_Int    charcode, idx, min_char, max_char;
-      FT_Byte*  glyph_name;
+      FT_Int  charcode, idx, min_char, max_char;
 
 
       /* OK, we do the following: for each element in the encoding  */
@@ -2648,27 +2641,27 @@
       charcode = 0;
       for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
       {
-        FT_Byte*  char_name;
+        const FT_String*  char_name =
+              (const FT_String*)loader.encoding_table.elements[charcode];
 
 
         type1->encoding.char_index[charcode] = 0;
-        type1->encoding.char_name [charcode] = (char *)".notdef";
+        type1->encoding.char_name [charcode] = ".notdef";
 
-        char_name = loader.encoding_table.elements[charcode];
         if ( char_name )
           for ( idx = 0; idx < type1->num_glyphs; idx++ )
           {
-            glyph_name = (FT_Byte*)type1->glyph_names[idx];
-            if ( ft_strcmp( (const char*)char_name,
-                            (const char*)glyph_name ) == 0 )
+            const FT_String*  glyph_name = type1->glyph_names[idx];
+
+
+            if ( ft_strcmp( char_name, glyph_name ) == 0 )
             {
               type1->encoding.char_index[charcode] = (FT_UShort)idx;
-              type1->encoding.char_name [charcode] = (char*)glyph_name;
+              type1->encoding.char_name [charcode] = glyph_name;
 
               /* Change min/max encoded char only if glyph name is */
               /* not /.notdef                                      */
-              if ( ft_strcmp( (const char*)".notdef",
-                              (const char*)glyph_name ) != 0 )
+              if ( ft_strcmp( ".notdef", glyph_name ) != 0 )
               {
                 if ( charcode < min_char )
                   min_char = charcode;
diff --git a/src/type42/t42objs.c b/src/type42/t42objs.c
index 234c0a3..d31bace 100644
--- a/src/type42/t42objs.c
+++ b/src/type42/t42objs.c
@@ -98,8 +98,7 @@
     /* we must now build type1.encoding when we have a custom array */
     if ( type1->encoding_type == T1_ENCODING_TYPE_ARRAY )
     {
-      FT_Int    charcode, idx, min_char, max_char;
-      FT_Byte*  glyph_name;
+      FT_Int  charcode, idx, min_char, max_char;
 
 
       /* OK, we do the following: for each element in the encoding   */
@@ -114,27 +113,27 @@
       charcode = 0;
       for ( ; charcode < loader.encoding_table.max_elems; charcode++ )
       {
-        FT_Byte*  char_name;
+        const FT_String*  char_name =
+              (const FT_String*)loader.encoding_table.elements[charcode];
 
 
         type1->encoding.char_index[charcode] = 0;
-        type1->encoding.char_name [charcode] = (char *)".notdef";
+        type1->encoding.char_name [charcode] = ".notdef";
 
-        char_name = loader.encoding_table.elements[charcode];
         if ( char_name )
           for ( idx = 0; idx < type1->num_glyphs; idx++ )
           {
-            glyph_name = (FT_Byte*)type1->glyph_names[idx];
-            if ( ft_strcmp( (const char*)char_name,
-                            (const char*)glyph_name ) == 0 )
+            const FT_String*  glyph_name = type1->glyph_names[idx];
+
+
+            if ( ft_strcmp( char_name, glyph_name ) == 0 )
             {
               type1->encoding.char_index[charcode] = (FT_UShort)idx;
-              type1->encoding.char_name [charcode] = (char*)glyph_name;
+              type1->encoding.char_name [charcode] = glyph_name;
 
               /* Change min/max encoded char only if glyph name is */
               /* not /.notdef                                      */
-              if ( ft_strcmp( (const char*)".notdef",
-                              (const char*)glyph_name ) != 0 )
+              if ( ft_strcmp( ".notdef", glyph_name ) != 0 )
               {
                 if ( charcode < min_char )
                   min_char = charcode;
diff --git a/src/type42/t42parse.c b/src/type42/t42parse.c
index a4aefcf..c47a777 100644
--- a/src/type42/t42parse.c
+++ b/src/type42/t42parse.c
@@ -374,12 +374,7 @@
 
       /* We need to `zero' out encoding_table.elements */
       for ( n = 0; n < count; n++ )
-      {
-        char*  notdef = (char *)".notdef";
-
-
-        (void)T1_Add_Table( char_table, n, notdef, 8 );
-      }
+        (void)T1_Add_Table( char_table, n, ".notdef", 8 );
 
       /* Now we need to read records of the form                */
       /*                                                        */
@@ -1022,8 +1017,7 @@
     }
 
     /* if /.notdef does not occupy index 0, do our magic. */
-    if ( ft_strcmp( (const char*)".notdef",
-                    (const char*)name_table->elements[0] ) )
+    if ( ft_strcmp( ".notdef", (const char*)name_table->elements[0] ) )
     {
       /* Swap glyph in index 0 with /.notdef glyph.  First, add index 0  */
       /* name and code entries to swap_table.  Then place notdef_index   */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]