character encoding, node depth
[pspp] / dump-spo.c
index 35cd8b5dcc072e837b32ce051198419e99870bd5..2a75bef6a928fd81d55b6fc2f948eb45b404e1ec 100644 (file)
@@ -1537,27 +1537,6 @@ main(int argc, char *argv[])
           continue;
         }
 
-#if 0
-      static const int col_prefix[] = {
-        0x11, 0x80, 0x00, -1, 0x00, 0x00, 0x00, 0x01, 0x00
-      };
-      size_t col_prefix_len = sizeof col_prefix / sizeof *col_prefix;
-      if (match_bytes(pos, col_prefix, col_prefix_len))
-        {
-          if (prev_end != pos)
-            {
-              if (print_offsets)
-                printf ("%04x ", prev_end);
-              hex_dump (stdout, prev_end, pos - prev_end);
-            }
-
-          printf ("col %d\n", data[pos + 3]);
-          pos += col_prefix_len - 1;
-          prev_end = pos + 1;
-          continue;
-        }
-#endif
-      
       static const int record_prefix[] = {
         0xff, 0xff, 0x00, 0x00,
       };
@@ -1632,11 +1611,8 @@ main(int argc, char *argv[])
             }
         }
 
-      static const int string_prefix[] = {
-        0x80, 0x01, 0x02, 0x28, 0x05, 0x00, 0x01
-      };
-      size_t string_prefix_len = sizeof string_prefix / sizeof *string_prefix;
-      if (match_bytes(pos, string_prefix, string_prefix_len) && data[pos + string_prefix_len] != 255)
+      if (data[pos] && data[pos + 1] && data[pos + 2] >= 0xfe
+          && data[pos + 3] == 0xff && data[pos + 4] && data[pos + 4] != 0xff)
         {
           if (prev_end != pos)
             {
@@ -1646,13 +1622,22 @@ main(int argc, char *argv[])
             }
           prev_end = pos;
 
-          int len = data[pos + 7];
-          printf ("string %.*s\n", len, &data[pos + 8]);
-          pos += 8 + len - 1;
+          static int prev_num;
+          int32_t num = data[pos] + (data[pos + 1] << 8)
+            + (data[pos + 2] << 16) + (data[pos + 3] << 24);
+          printf ("%d (%+d) ", num, num - prev_num);
+          prev_num = num;
+          pos += 4 - 1;
           prev_end = pos + 1;
           continue;
         }
-      if (match_bytes(pos, string_prefix, string_prefix_len) && data[pos + string_prefix_len] == 255)
+
+      static const int font_prefix[] = 
+        {
+          0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x41, 0x72, 0x69, 0x61, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00,
+        };
+      size_t font_prefix_len = sizeof font_prefix / sizeof *font_prefix;
+      if (match_bytes(pos, font_prefix, font_prefix_len))
         {
           if (prev_end != pos)
             {
@@ -1662,115 +1647,52 @@ main(int argc, char *argv[])
             }
           prev_end = pos;
 
-          int len = data[pos + 8] + (data[pos + 9] << 8);
-          printf ("\nlongstring %.*s\n", len, &data[pos + 10]);
-          pos += 10 + len - 1;
-          prev_end = pos + 1;
-          continue;
-        }
-
-      
+          printf ("font\n");
 
-#if 0
-      static const int heading_prefix[] = {
-        -1, 0x00, 0x00, 0x00, 0x50, 0x80, 0x00, 0x52, 0x80, 0x00, -1, 0x00,
-        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00,
-        0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
-        0x00, 0x05, 0x80, 0x01, 0x02, 0x28, 0x05, 0x00, 0x01
-      };
-      size_t heading_prefix_len = sizeof heading_prefix / sizeof *heading_prefix;
-      if (match_bytes(pos, heading_prefix, heading_prefix_len))
-        {
-          if (prev_end != pos)
-            {
-              if (print_offsets)
-                printf ("%04x ", prev_end);
-              hex_dump (stdout, prev_end, pos - prev_end);
-            }
-
-          printf ("heading %d %d\n", data[pos],data[pos + 10]);
-          pos += heading_prefix_len - 1;
+          pos += font_prefix_len - 1;
           prev_end = pos + 1;
           continue;
         }
 
-#if 0
-      static const int font_prefix[] = {
-        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, -1, 0x80, 0x00, 0x01, 0x00,
-        0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, -1,
-        0x80, 0x00, -1, 0x00, -1, 0x00, 0xc8, 0x00, -1, -1, -1, -1, -1,
-        0x00, -1, 0x00, 0x00, 0x00, 0x01, 0x00, -1,
-        0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-        0x00, 0x00, 0x00, -1, -1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-        0x00, 0x00, -1 /* 12 or 22 */,
+      static const int string_prefix[] = {
+        0x80, 0x01, 0x02, 0x28, 0x05, 0x00, 0x01
       };
-      size_t font_prefix_len = sizeof font_prefix / sizeof *font_prefix;
-      if (match_bytes(pos, font_prefix, font_prefix_len))
+      size_t string_prefix_len = sizeof string_prefix / sizeof *string_prefix;
+      if (match_bytes(pos, string_prefix, string_prefix_len) && data[pos + string_prefix_len] != 255)
         {
           if (prev_end != pos)
             {
               if (print_offsets)
-            printf ("%04x", prev_end);
+                printf ("%04x ", prev_end);
               hex_dump (stdout, prev_end, pos - prev_end);
             }
+          prev_end = pos;
 
-          printf ("font %d %d %d %d %d %d %d %d %d %d\n",
-                  data[pos + 24], data[pos + 26],
-                  data[pos + 30], data[pos + 31], data[pos + 32],
-                  data[pos + 33], data[pos + 34], data[pos + 36],
-                  data[pos + 58], data[pos + 59]);
-          pos += font_prefix_len - 1;
+          int len = data[pos + 7];
+          printf ("string %.*s\n", len, &data[pos + 8]);
+          pos += 8 + len - 1;
           prev_end = pos + 1;
           continue;
         }
-#endif
-      
-      static const int table_prefix[] = {
-        -1 /* ed or e9 */, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
-        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbc, 0x02, 0x00, 0x00,
-        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x41, 0x72, 0x69,
-        0x61, 0x6c, 0x00, -1, 0x00, -1, 0x00, 0x00, 0x00, 0x00, 0x00,
-        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
-        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00,
-        0x00, 0x00, 0x00, 0x00, -1, 0x00, 0x00, 0x00, -1,
-      };
-      size_t table_prefix_len = sizeof table_prefix / sizeof *table_prefix;
-      if (match_bytes(pos, table_prefix, table_prefix_len))
+      if (match_bytes(pos, string_prefix, string_prefix_len) && data[pos + string_prefix_len] == 255)
         {
           if (prev_end != pos)
             {
               if (print_offsets)
-                printf ("%04x", prev_end);
+                printf ("%04x ", prev_end);
               hex_dump (stdout, prev_end, pos - prev_end);
             }
+          prev_end = pos;
 
-          printf ("table %d\n", data[pos + 72]);
-          pos += table_prefix_len - 1;
+          int len = data[pos + 8] + (data[pos + 9] << 8);
+          printf ("\nlongstring %.*s\n", len, &data[pos + 10]);
+          pos += 10 + len - 1;
           prev_end = pos + 1;
           continue;
         }
 
-      static const int dim_prefix[] = {
-        0x00, 0x03, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, -1,
-        0x00, 0x00, 0x00, 0x00, 0x05, 0x80, 0x01, 0x02, 0x28,
-        0x05, 0x00,
-      };
-      size_t dim_prefix_len = sizeof dim_prefix / sizeof *dim_prefix;
-      if (match_bytes(pos, dim_prefix, dim_prefix_len))
-        {
-          if (prev_end != pos)
-            {
-              if (print_offsets)
-                printf ("%04x", prev_end);
-              hex_dump (stdout, prev_end, pos - prev_end);
-            }
+      
 
-          printf ("dim %d\n", data[pos + 8]);
-          pos += dim_prefix_len - 1;
-          prev_end = pos + 1;
-          continue;
-        }
-#endif
 
       if (!is_ascii(data[pos]))
         continue;