dump: Crazy simplification.
authorBen Pfaff <blp@cs.stanford.edu>
Fri, 7 Nov 2014 07:11:37 +0000 (23:11 -0800)
committerBen Pfaff <blp@cs.stanford.edu>
Fri, 7 Nov 2014 07:11:37 +0000 (23:11 -0800)
dump.c

diff --git a/dump.c b/dump.c
index bf6003e9b1255079f73f9ebfdec6dd51dad8a4eb..a7bd6c2c14dcbde968f2a05dd4a54bfc9d6aa5a4 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -204,7 +204,6 @@ dump_value_31(void)
     match_byte_assert (0x58);
 }
 
-static void dump_value(int level, bool match1);
 static void dump_substs(void (*dump)(int level), int level);
 static void dump_value__(int level, bool match1);
 
@@ -222,6 +221,9 @@ dump_value__with_preskip(int level)
 static void
 dump_value__(int level, bool match1)
 {
+  for (int i = 0; i <= level; i++)
+    printf ("    ");
+
   if (match_byte (3))
     {
       char *s1 = get_string();
@@ -293,38 +295,16 @@ dump_value__(int level, bool match1)
 }
 
 static void
-dump_value(int level, bool match1)
+dump_category(int level)
 {
-  for (int i = 0; i <= level; i++)
-    printf ("    ");
-
   match_byte (0);
   match_byte (0);
   match_byte (0);
   match_byte (0);
-  dump_value__(level, match1);
+  dump_value__ (level, true);
   match_byte(0);
   match_byte(0);
   match_byte(0);
-}
-
-static void
-dump_dim_value(int level)
-{
-  for (int i = 0; i <= level; i++)
-    printf ("    ");
-
-  match_byte(0);
-  match_byte(0);
-  match_byte(0);
-  match_byte(0);
-  dump_value__(level, true);
-}
-
-static void
-dump_category(int level)
-{
-  dump_value (level, true);
 
   if (match_u32 (1))
     match_byte (0);
@@ -348,12 +328,14 @@ dump_category(int level)
     dump_category (level + 1);
 }
 
+static void dump_title_value(int level);
+
 static void
 dump_dim(void)
 {
   int n_categories;
   printf("next dim\n");
-  dump_dim_value(0);
+  dump_title_value(0);
 
   /* This byte is usually 0x02 but 0x00 and 0x75 (!) have also been spotted. */
   pos++;
@@ -472,22 +454,6 @@ dump_title_value(int level)
     dump_substs(dump_title_value, level + 1);
 }
 
-static void
-dump_footnote_value(int level)
-{
-  for (int i = 0; i <= level; i++)
-    printf ("    ");
-
-  match_byte (0);
-  match_byte (0);
-  match_byte (0);
-  match_byte (0);
-  if (data[pos] <= 5)
-    dump_value__(level, false);
-  else
-    dump_substs(dump_footnote_value, level + 1);
-}
-
 static void
 dump_title(void)
 {
@@ -500,7 +466,7 @@ dump_title(void)
   match_byte_assert(0x58);
   if (match_byte(0x31))
     {
-      dump_footnote_value(0); putchar('\n');
+      dump_data_value(0); putchar('\n');
     }
   else
     match_byte_assert(0x58);
@@ -519,7 +485,7 @@ dump_title(void)
       for (int i = 0; i < n_footnotes; i++)
         {
           printf("footnote %d:\n", i);
-          dump_footnote_value(0);
+          dump_data_value(0);
           if (match_byte (0x31))
             {
               /* Custom footnote marker string. */