Specify dimension list at beginning of data.
[pspp] / dump.c
diff --git a/dump.c b/dump.c
index e9a068699e005fba3778c5597181c93d0f8a6d4a..1cdb749f81fc714f09876a9701391cb48416e2bb 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -579,10 +579,15 @@ dump_category(FILE *stream, int level, int *indexes, int *n_indexes, int max_ind
   int merge = data[pos];
   if (!match_byte(0))
     match_byte_assert (1);
+
   match_byte_assert (0);
+
   int unindexed = data[pos];
   if (!match_byte(0))
     match_byte_assert (1);
+
+  int x = get_u32 ();
+  pos -= 4;
   if (!match_u32 (0))
     match_u32_assert (2);
 
@@ -604,6 +609,11 @@ dump_category(FILE *stream, int level, int *indexes, int *n_indexes, int max_ind
           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");
@@ -684,14 +694,21 @@ static void
 dump_data(void)
 {
   /* The first three numbers add to the number of dimensions. */
-  int t = get_u32();
-  t += get_u32();
-  match_u32_assert(n_dims - t);
+  int l = get_u32();
+  int r = get_u32();
+  int c = n_dims - l - r;
+  match_u32_assert(c);
 
   /* The next n_dims numbers are a permutation of the dimension numbers. */
   int a[n_dims];
   for (int i = 0; i < n_dims; i++)
-    a[i] = get_u32();
+    {
+      int dim = get_u32();
+      a[i] = dim;
+
+      const char *name = i < l ? "layer" : i < l + r ? "row" : "column";
+      printf ("<%s dimension=\"%d\"/>\n", name, dim);
+    }
   check_permutation(a, n_dims, "dimensions");
 
   int x = get_u32();