start moving beyond PMModelItemInfo
[pspp] / dump.c
diff --git a/dump.c b/dump.c
index 8a820d7b86c12ad2ca78b1be232b9993a643cc0a..7f3c2b8c75174a045f9666ff379af99efaef5aa3 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -508,6 +508,7 @@ dump_value(FILE *stream, int level)
   for (int i = 0; i <= level; i++)
     fprintf (stream, "    ");
 
+  printf ("%02x: value (%d)\n", pos, data[pos]);
   if (match_byte (1))
     {
       unsigned int format;
@@ -589,6 +590,7 @@ dump_value(FILE *stream, int level)
     }
   else
     {
+      printf ("else %#x\n", pos);
       dump_value_modifier(stream);
 
       char *base = get_string();
@@ -650,15 +652,9 @@ dump_category(FILE *stream, int level, int **indexes, int *allocated_indexes,
   printf ("<category>\n");
   dump_value (stream, level + 1);
 
-  int merge = data[pos];
-  if (!match_byte(0))
-    match_byte_assert (1);
-
+  bool merge = get_bool();
   match_byte_assert (0);
-
-  int unindexed = data[pos];
-  if (!match_byte(0))
-    match_byte_assert (1);
+  int unindexed = get_bool();
 
   int x = get_u32 ();
   pos -= 4;
@@ -675,24 +671,14 @@ dump_category(FILE *stream, int level, int **indexes, int *allocated_indexes,
             fprintf (stream, "    ");
           fprintf (stream, "<merge/>\n");
         }
+      assert (unindexed);
     }
   else
     {
-      if (merge)
-        {
-          fprintf(stderr, "index not -1 but merged\n");
-          exit(1);
-        }
-      if (x != 2)
-        {
-          fprintf(stderr, "index not -1 but x != 2\n");
-          exit(1);
-        }
-      if (n_categories != 0)
-        {
-          fprintf(stderr, "index not -1 but subcategories\n");
-          exit(1);
-        }
+      assert (!merge);
+      assert (!unindexed);
+      assert (x == 2);
+      assert (n_categories == 0);
       if (*n_indexes >= *allocated_indexes)
         {
           *allocated_indexes = *allocated_indexes ? 2 * *allocated_indexes : 16;
@@ -701,14 +687,6 @@ dump_category(FILE *stream, int level, int **indexes, int *allocated_indexes,
       (*indexes)[(*n_indexes)++] = indx;
     }
 
-  int expected_unindexed = indx == -1;
-  if (unindexed != expected_unindexed)
-    {
-      fprintf(stderr, "unindexed (%d) mismatch with indx (%d)\n",
-              unindexed, indx);
-      exit(1);
-    }
-
   if (n_categories == 0)
     {
       for (int i = 0; i <= level + 1; i++)
@@ -730,20 +708,29 @@ dump_dim(int indx)
   printf ("<dimension index=\"%d\">\n", indx);
   dump_value (stdout, 0);
 
-  /* This byte is usually 0 but many other values have been spotted. */
+  /* This byte is usually 0 but many other values have been spotted.
+     No visible effect. */
   pos++;
 
+  /* This byte can cause data to be oddly replicated. */
   if (!match_byte(0) && !match_byte(1))
     match_byte_assert(2);
+
   if (!match_u32(0))
     match_u32_assert(2);
-  if (!match_byte(0))
-    match_byte_assert(1);
-  if (!match_byte(0))
-    match_byte_assert(1);
+
+  bool show_dim_label = get_bool();
+  if (show_dim_label)
+    printf("  <show-dim-label/>\n");
+
+  bool hide_all_labels = get_bool();
+  if (hide_all_labels)
+    printf("  <hide-all-labels/>\n");
+
   match_byte_assert(1);
   if (!match_u32(UINT32_MAX))
     match_u32_assert(indx);
+
   n_categories = get_u32();
 
   int *indexes = NULL;
@@ -1023,7 +1010,8 @@ dump_fonts(void)
   printf ("<layer>%d</layer>\n", get_u32());
   if (!match_byte(0))
     match_byte_assert(1);
-  match_byte_assert(0);
+  if (!match_byte(0))
+    match_byte_assert(1);
   if (!match_byte(0))
     match_byte_assert(1);
   printf("<epoch>%d</epoch>\n", get_u32());
@@ -1132,7 +1120,7 @@ dump_fonts(void)
       printf("<locale>%s</locale>\n", get_string());
 
       get_bool();
-      match_byte_assert(0);
+      get_bool();
       get_bool();
       get_bool();