Commit 71fecc539e135d2f5a0295e433693f8090811e26

Werner Lemberg 2017-12-05T12:06:29

Improve tracing messages by using singular and plural forms. * src/*/*.c: Implement it.

diff --git a/ChangeLog b/ChangeLog
index fbb6d3b..f1b6067 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2017-12-05  Werner Lemberg  <wl@gnu.org>
+
+	Improve tracing messages by using singular and plural forms.
+
+	* src/*/*.c: Implement it.
+
 2017-12-04  Werner Lemberg  <wl@gnu.org>
 
 	[truetype] Allow shared points in `cvar' table (#52532).
diff --git a/src/cff/cffdrivr.c b/src/cff/cffdrivr.c
index cf630a8..d085691 100644
--- a/src/cff/cffdrivr.c
+++ b/src/cff/cffdrivr.c
@@ -240,8 +240,10 @@
                                                        &dummy,
                                                        &ah );
 
-          FT_TRACE5(( "  idx %d: advance height %d font units\n",
-                      start + nn, ah ));
+          FT_TRACE5(( "  idx %d: advance height %d font unit%s\n",
+                      start + nn,
+                      ah,
+                      ah == 1 ? "" : "s" ));
           advances[nn] = ah;
         }
       }
@@ -269,8 +271,10 @@
                                                        &dummy,
                                                        &aw );
 
-          FT_TRACE5(( "  idx %d: advance width %d font units\n",
-                      start + nn, aw ));
+          FT_TRACE5(( "  idx %d: advance width %d font unit%s\n",
+                      start + nn,
+                      aw,
+                      aw == 1 ? "" : "s" ));
           advances[nn] = aw;
         }
       }
diff --git a/src/cff/cffload.c b/src/cff/cffload.c
index e8479d4..76e0cdd 100644
--- a/src/cff/cffload.c
+++ b/src/cff/cffload.c
@@ -1297,7 +1297,9 @@
 
     if ( numOperands > count )
     {
-      FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d args\n", count ));
+      FT_TRACE4(( " cff_blend_doBlend: Stack underflow %d argument%s\n",
+                  count,
+                  count == 1 ? "" : "s" ));
 
       error = FT_THROW( Stack_Underflow );
       goto Exit;
diff --git a/src/cff/cffparse.c b/src/cff/cffparse.c
index e4e2bcd..325948e 100644
--- a/src/cff/cffparse.c
+++ b/src/cff/cffparse.c
@@ -949,7 +949,9 @@
       goto Exit;
     }
 
-    FT_TRACE4(( "   %d values blended\n", numBlends ));
+    FT_TRACE4(( "   %d value%s blended\n",
+                numBlends,
+                numBlends == 1 ? "" : "s" ));
 
     error = cff_blend_doBlend( subFont, parser, numBlends );
 
diff --git a/src/pcf/pcfread.c b/src/pcf/pcfread.c
index da216b0..537da0d 100644
--- a/src/pcf/pcfread.c
+++ b/src/pcf/pcfread.c
@@ -840,7 +840,7 @@ THE SOFTWARE.
     FT_TRACE4(( "pcf_get_bitmaps:\n"
                 "  format: 0x%lX\n"
                 "          (%s, %s,\n"
-                "           padding=%d bits, scanning=%d bits)\n",
+                "           padding=%d bit%s, scanning=%d bit%s)\n",
                 format,
                 PCF_BYTE_ORDER( format ) == MSBFirst
                   ? "most significant byte first"
@@ -849,7 +849,9 @@ THE SOFTWARE.
                   ? "most significant bit first"
                   : "least significant bit first",
                 8 << PCF_GLYPH_PAD_INDEX( format ),
-                8 << PCF_SCAN_UNIT_INDEX( format ) ));
+                ( 8 << PCF_GLYPH_PAD_INDEX( format ) ) == 1 ? "" : "s",
+                8 << PCF_SCAN_UNIT_INDEX( format ),
+                ( 8 << PCF_SCAN_UNIT_INDEX( format ) ) == 1 ? "" : "s" ));
 
     if ( !PCF_FORMAT_MATCH( format, PCF_DEFAULT_FORMAT ) )
       return FT_THROW( Invalid_File_Format );
diff --git a/src/pfr/pfrgload.c b/src/pfr/pfrgload.c
index 93f5fc7..98efb9e 100644
--- a/src/pfr/pfrgload.c
+++ b/src/pfr/pfrgload.c
@@ -756,8 +756,10 @@
 
       count = glyph->num_subs - old_count;
 
-      FT_TRACE4(( "compound glyph with %d elements (offset %lu):\n",
-                  count, offset ));
+      FT_TRACE4(( "compound glyph with %d element%s (offset %lu):\n",
+                  count,
+                  count == 1 ? "" : "s",
+                  offset ));
 
       /* now, load each individual glyph */
       for ( n = 0; n < count; n++ )
@@ -810,7 +812,9 @@
         /* proceed to next sub-glyph */
       }
 
-      FT_TRACE4(( "end compound glyph with %d elements\n", count ));
+      FT_TRACE4(( "end compound glyph with %d element%s\n",
+                  count,
+                  count == 1 ? "" : "s" ));
     }
     else
     {
diff --git a/src/sfnt/ttsbit.c b/src/sfnt/ttsbit.c
index f41847b..c55c499 100644
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -1007,8 +1007,9 @@
       goto Fail;
     }
 
-    FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d components\n",
-                num_components ));
+    FT_TRACE3(( "tt_sbit_decoder_load_compound: loading %d component%s\n",
+                num_components,
+                num_components == 1 ? "" : "s" ));
 
     for ( nn = 0; nn < num_components; nn++ )
     {
diff --git a/src/smooth/ftgrays.c b/src/smooth/ftgrays.c
index 6a230a6..d43dd45 100644
--- a/src/smooth/ftgrays.c
+++ b/src/smooth/ftgrays.c
@@ -1718,8 +1718,11 @@ typedef ptrdiff_t  FT_PtrDist;
       if ( !ras.invalid )
         gray_record_cell( RAS_VAR );
 
-      FT_TRACE7(( "band [%d..%d]: %d cells\n",
-                  ras.min_ey, ras.max_ey, ras.num_cells ));
+      FT_TRACE7(( "band [%d..%d]: %d cell%s\n",
+                  ras.min_ey,
+                  ras.max_ey,
+                  ras.num_cells,
+                  ras.num_cells == 1 ? "" : "s" ));
     }
     else
     {
diff --git a/src/truetype/ttgxvar.c b/src/truetype/ttgxvar.c
index 4ff1657..9aa4825 100644
--- a/src/truetype/ttgxvar.c
+++ b/src/truetype/ttgxvar.c
@@ -1043,10 +1043,11 @@
                                    outerIndex,
                                    innerIndex );
 
-    FT_TRACE5(( "%s value %d adjusted by %d units (%s)\n",
+    FT_TRACE5(( "%s value %d adjusted by %d unit%s (%s)\n",
                 vertical ? "vertical height" : "horizontal width",
                 *avalue,
                 delta,
+                delta == 1 ? "" : "s",
                 vertical ? "VVAR" : "HVAR" ));
 
     *avalue += delta;
@@ -1333,13 +1334,15 @@
 
       if ( p )
       {
-        FT_TRACE5(( "value %c%c%c%c (%d units) adjusted by %d units (MVAR)\n",
+        FT_TRACE5(( "value %c%c%c%c (%d unit%s) adjusted by %d unit%s (MVAR)\n",
                     (FT_Char)( value->tag >> 24 ),
                     (FT_Char)( value->tag >> 16 ),
                     (FT_Char)( value->tag >> 8 ),
                     (FT_Char)( value->tag ),
                     value->unmodified,
-                    delta ));
+                    value->unmodified == 1 ? "" : "s",
+                    delta,
+                    delta == 1 ? "" : "s" ));
 
         /* since we handle both signed and unsigned values as FT_Short, */
         /* ensure proper overflow arithmetic                            */
@@ -1499,8 +1502,10 @@
     blend->gv_glyphcnt = gvar_head.glyphCount;
     offsetToData       = gvar_start + gvar_head.offsetToData;
 
-    FT_TRACE5(( "gvar: there are %d shared coordinates:\n",
-                blend->tuplecount ));
+    FT_TRACE5(( "gvar: there %s %d shared coordinate%s:\n",
+                blend->tuplecount == 1 ? "is" : "are",
+                blend->tuplecount,
+                blend->tuplecount == 1 ? "" : "s" ));
 
     if ( FT_NEW_ARRAY( blend->glyphoffsets, blend->gv_glyphcnt + 1 ) )
       goto Exit;
@@ -3027,7 +3032,10 @@
       FT_Stream_SeekSet( stream, here );
     }
 
-    FT_TRACE5(( "cvar: there are %d tuples:\n", tupleCount & 0xFFF ));
+    FT_TRACE5(( "cvar: there %s %d tuple%s:\n",
+                ( tupleCount & 0xFFF ) == 1 ? "is" : "are",
+                tupleCount & 0xFFF,
+                ( tupleCount & 0xFFF ) == 1 ? "" : "s" ));
 
     for ( i = 0; i < ( tupleCount & 0xFFF ); i++ )
     {
@@ -3517,8 +3525,10 @@
       FT_Stream_SeekSet( stream, here );
     }
 
-    FT_TRACE5(( "gvar: there are %d tuples:\n",
-                tupleCount & GX_TC_TUPLE_COUNT_MASK ));
+    FT_TRACE5(( "gvar: there %s %d tuple%s:\n",
+                ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "is" : "are",
+                tupleCount & GX_TC_TUPLE_COUNT_MASK,
+                ( tupleCount & GX_TC_TUPLE_COUNT_MASK ) == 1 ? "" : "s" ));
 
     for ( j = 0; j < n_points; j++ )
       points_org[j] = outline->points[j];
diff --git a/src/truetype/ttinterp.c b/src/truetype/ttinterp.c
index 2bb43ec..bb45655 100644
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -8486,7 +8486,9 @@
     } while ( !exc->instruction_trap );
 
   LNo_Error_:
-    FT_TRACE4(( "  %d instructions executed\n", ins_counter ));
+    FT_TRACE4(( "  %d instruction%s executed\n",
+                ins_counter == 1 ? "" : "s",
+                ins_counter ));
     return FT_Err_Ok;
 
   LErrorCodeOverflow_: