Commit 8ce3026304d3167c1f7b6b36d75a139050145b11

Werner Lemberg 2015-03-27T08:33:47

[cff] Trace charstring nesting levels. * src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdCALLGSUBR, cf2_cmdCALLSUBR, cf2_cmdRETURN>: Implement it. * src/cff/cffgload.c (cff_decoder_parse_charstrings) <cff_op_callsubr, cff_op_callgsubr, cff_op_return>: Ditto.

diff --git a/ChangeLog b/ChangeLog
index 7a4e3b2..7d58921 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2015-03-27  Werner Lemberg  <wl@gnu.org>
+
+	[cff] Trace charstring nesting levels.
+
+	* src/cff/cf2intrp.c (cf2_interpT2CharString) <cf2_cmdCALLGSUBR,
+	cf2_cmdCALLSUBR, cf2_cmdRETURN>: Implement it.
+
+	* src/cff/cffgload.c (cff_decoder_parse_charstrings)
+	<cff_op_callsubr, cff_op_callgsubr, cff_op_return>: Ditto.
+
 2015-03-21  Alexei Podtelezhnikov <apodtele@gmail.com>
 
 	[base] Optimize `FT_Angle_Diff'.
diff --git a/src/cff/cf2intrp.c b/src/cff/cf2intrp.c
index 5ee4e55..d7f7a7b 100644
--- a/src/cff/cf2intrp.c
+++ b/src/cff/cf2intrp.c
@@ -771,8 +771,9 @@
           switch ( op1 )
           {
           case cf2_cmdCALLGSUBR:
-            FT_TRACE4(( "(%d)\n",
-                        subrIndex + (CF2_UInt)decoder->globals_bias ));
+            FT_TRACE4(( " (idx %d, entering level %d)\n",
+                        subrIndex + (CF2_UInt)decoder->globals_bias,
+                        charstringIndex + 1 ));
 
             if ( cf2_initGlobalRegionBuffer( decoder,
                                              subrIndex,
@@ -785,8 +786,9 @@
 
           default:
             /* cf2_cmdCALLSUBR */
-            FT_TRACE4(( "(%d)\n",
-                        subrIndex + (CF2_UInt)decoder->locals_bias ));
+            FT_TRACE4(( " (idx %d, entering level %d)\n",
+                        subrIndex + (CF2_UInt)decoder->locals_bias,
+                        charstringIndex + 1 ));
 
             if ( cf2_initLocalRegionBuffer( decoder,
                                             subrIndex,
@@ -802,7 +804,7 @@
         continue; /* do not clear the stack */
 
       case cf2_cmdRETURN:
-        FT_TRACE4(( " return\n" ));
+        FT_TRACE4(( " return (leaving level %d)\n", charstringIndex ));
 
         if ( charstringIndex < 1 )
         {
diff --git a/src/cff/cffgload.c b/src/cff/cffgload.c
index 414790a..b5bc4a2 100644
--- a/src/cff/cffgload.c
+++ b/src/cff/cffgload.c
@@ -2389,7 +2389,9 @@
                                       decoder->locals_bias );
 
 
-            FT_TRACE4(( " callsubr(%d)\n", idx ));
+            FT_TRACE4(( " callsubr (idx %d, entering level %d)\n",
+                        idx,
+                        zone - decoder->zones + 1 ));
 
             if ( idx >= decoder->num_locals )
             {
@@ -2431,7 +2433,9 @@
                                       decoder->globals_bias );
 
 
-            FT_TRACE4(( " callgsubr(%d)\n", idx ));
+            FT_TRACE4(( " callgsubr (idx %d, entering level %d)\n",
+                        idx,
+                        zone - decoder->zones + 1 ));
 
             if ( idx >= decoder->num_globals )
             {
@@ -2468,7 +2472,8 @@
           break;
 
         case cff_op_return:
-          FT_TRACE4(( " return\n" ));
+          FT_TRACE4(( " return (leaving level %d)\n",
+                      decoder->zone - decoder->zones ));
 
           if ( decoder->zone <= decoder->zones )
           {