now reads past cells and dimensions!
[pspp] / dump-spo2.c
index a76aff97621ba9a17efa4d7299a662a4eeee1ad7..da9e73191703c859d47aeee0cde8cb21ebcce12e 100644 (file)
@@ -476,6 +476,23 @@ match_zeros_assert(int count, const char *where)
 }
 #define match_zeros_assert(count) match_zeros_assert(count, WHERE)
 
+static void
+put_safe(const char *s)
+{
+  while (*s)
+    {
+      if (*s == '\n')
+        printf ("\\n");
+      else if (*s == '\r')
+        printf ("\\r");
+      else if (*s < 0x20 || *s > 0x7e)
+        printf ("\\x%02"PRIx8, (uint8_t) *s);
+      else
+        putchar (*s);
+      s++;
+    }
+}
+
 static void
 parse_DspString(void)
 {
@@ -486,7 +503,9 @@ parse_DspString(void)
     match_byte_assert(5);
   match_byte_assert(0);
   match_byte_assert(1);
-  printf ("DspString(\"%s\")\n", get_string1());
+  printf ("DspString(\"");
+  put_safe(get_string1());
+  printf("\")\n");
 }
 
 static void
@@ -502,7 +521,10 @@ match_DspSimpleText(void)
 {                               /* 03 80 */
   match_byte_assert(3);
   match_byte_assert(0x80);
-  match_zeros_assert(10);
+  match_zeros_assert(5);
+  if (!match_byte(0x10))
+    match_byte_assert(0);
+  match_zeros_assert(4);
 }
 
 static void
@@ -523,7 +545,74 @@ match_NavTreeViewItem(void)
   match_zeros_assert(5);
   match_byte_assert(1);
   match_zeros_assert(5);
-  puts(get_string1());
+
+  put_safe(get_string1());
+  putc('\n', stdout);
+}
+
+static void
+parse_DspNumber(void)
+{
+  match_byte_assert(1);
+  parse_format();
+  match_byte_assert(0x80);
+  match_byte(2);
+  printf (" %f", get_double());
+  printf (" \"%s\"\n", get_string1());
+}
+
+static void
+match_DspNumber(void)
+{
+  match_byte_assert(0x2a);
+  match_byte_assert(0x80);
+  parse_DspNumber();
+}
+
+static void
+match_DspCell(void)
+{                               /* 27 80 */
+  match_byte_assert(0x27);
+  match_byte_assert(0x80);
+  match_byte_assert(0);
+  match_DspSimpleText();
+  if (data[pos] == 5)
+    match_DspString();
+  else if (data[pos] == 0x2a)
+    match_DspNumber();
+  else
+    assert(0);
+}
+
+static void
+parse_PMModelItemInfo(void)
+{                               /* 54 80 */
+  match_byte_assert(0);
+  pos += 1;                     /* Counter */
+  match_zeros_assert(7);
+  pos += 3;
+  if (!match_byte(0))
+    match_byte_assert(0xe);
+  match_byte_assert(0);
+}
+
+static void
+match_PMModelItemInfo(void)
+{                               /* 54 80 */
+  match_byte_assert(0x54);
+  match_byte_assert(0x80);
+  parse_PMModelItemInfo();
+  match_DspSimpleText();
+  match_DspString();
+}
+
+static void
+match_PMPivotItemTree(void)
+{                               /* 52 80 */
+  match_byte_assert(0x52);
+  match_byte_assert(0x80);
+  match_byte_assert(0);
+  match_PMModelItemInfo();
 }
 
 int
@@ -717,12 +806,109 @@ main(int argc, char *argv[])
   match_DspSimpleText();
 
   parse_heading("DspNumber");
+  parse_DspNumber();
+
+  match_DspCell();
+  match_DspCell();
+  match_DspCell();
+  match_DspCell();
+  match_DspCell();
+  match_DspCell();
+  match_DspCell();
+  while (data[pos] == 0)
+    pos++;
+
+  match_DspCell();
+  match_DspCell();
+  while (data[pos] == 0)
+    pos++;
+  match_DspCell();
+  match_DspCell();
+  match_DspCell();
+
   match_byte_assert(1);
-  parse_format();
-  match_byte_assert(0x80);
-  match_byte(2);
-  printf (" %f", get_double());
-  printf (" \"%s\"\n", get_string1());
+  match_byte_assert(0);
+  puts(get_string1());
+  match_u32_assert(0);
+  puts(get_string1());
+
+  match_byte_assert(0);
+  match_byte_assert(1);
+  match_byte_assert(0);
+  match_byte_assert(0);
+  match_byte_assert(0);
+  match_byte_assert(1);
+  match_byte_assert(0);
+
+  parse_heading("PMPivotItemTree");
+  match_byte_assert(0);
+
+  parse_heading("AbstractTreeBranch");
+  match_byte_assert(0);
+
+  parse_heading("PMModelItemInfo");
+  parse_PMModelItemInfo();
+  match_DspSimpleText();
+  match_DspString();
+
+  match_u32_assert(7);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(6);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(2);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(2);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+  match_PMPivotItemTree();
+
+  match_u32_assert(0);
+
+  /* ...unknown... */
+
+  while (data[pos] != 0xff || data[pos + 1] != 0xff)
+    pos++;
+  parse_heading("PVViewDimension");
 
   printf ("%#x: end of successful parse\n", pos);