match_byte_assert (0x58);
}
-static void dump_value(int level);
+static void dump_substs(void (*dump)(int level), int level);
+static void dump_value__(int level, bool match1);
+
+static void
+dump_value__with_preskip(int level)
+{
+ match_byte(0);
+ match_byte(0);
+ match_byte(0);
+ match_byte(0);
+ dump_value__ (level, false);
+ putchar('\n');
+}
static void
dump_value__(int level, bool match1)
{
+ for (int i = 0; i <= level; i++)
+ printf (" ");
+
if (match_byte (3))
{
char *s1 = get_string();
match_byte (1);
}
else
- {
- dump_value_31();
- char *base = get_string();
-
- int x = get_u32();
- printf ("\"%s\" with %d variables:\n", base, x);
- if (match_u32(0))
- {
- for (int i = 0; i < x; i++)
- {
- dump_value (level+1);
- putchar('\n');
- }
- }
- else
- {
- for (int i = 0; i < x; i++)
- {
- int y = get_u32();
- match_u32_assert(0);
- for (int j = 0; j <= level; j++)
- printf (" ");
- printf("variable %d has %d values:\n", i, y);
- for (int j = 0; j < y; j++)
- {
- match_byte(0);
- if (match_byte(3))
- {
- char *a = get_string();
- match_byte_assert(0x58);
- char *b = get_string();
- char *c = get_string();
- for (int k = 0; k <= level + 1; k++)
- printf (" ");
- printf ("\"%s\", \"%s\", \"%s\"", a, b, c);
- }
- else
- dump_value (level+1);
-
- match_byte(0);
- match_byte(0);
- match_byte(0);
- match_byte(0);
- putchar('\n');
- }
- }
- }
- }
+ dump_substs(dump_value__with_preskip, level + 1);
}
static void
-dump_value(int level)
+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, true);
+ 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 (" ");
-
- if (data[pos] == 3 || data[pos] == 5)
- dump_value__(level, true);
- else
- dump_value(level);
-}
-
-static void
-dump_category(int level)
-{
- dump_value (level);
if (match_u32 (1))
match_byte (0);
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++;
match_u32_assert(2);
if (!match_byte(0))
match_byte_assert(1);
- match_byte(0);
- match_byte(0);
- match_byte(0);
- match_byte(0);
get_u32();
match_byte(0);
match_byte(0);
- match_byte(0);
- match_byte(0);
n_categories = get_u32();
printf("%d nested categories\n", n_categories);
for (int i = 0; i < n_categories; i++)
match_byte(0);
match_byte(0);
match_byte(0);
- if (data[pos] == 1 || data[pos] == 2 || data[pos] == 3 || data[pos] == 4)
+ if (data[pos] <= 5)
dump_value__(0, false);
- else if (data[pos] == 5)
- dump_value (0);
else
dump_substs (dump_data_value, level + 1);
}
match_byte (0);
match_byte (0);
match_byte (0);
- if (data[pos] == 1 || data[pos] == 2 || data[pos] == 3 || data[pos] == 4)
- dump_value(level);
- else if (data[pos] == 5)
+ if (data[pos] <= 5)
dump_value__(level, true);
else
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] == 2 || data[pos] == 4)
- dump_value(level);
- else if (data[pos] == 1 || data[pos] == 3 || data[pos] == 5)
- dump_value__(level, false);
- else
- dump_substs(dump_footnote_value, level + 1);
-}
-
static void
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);
for (int i = 0; i < n_footnotes; i++)
{
printf("footnote %d:\n", i);
- dump_footnote_value(0);
- match_byte(0);
- match_byte(0);
- match_byte(0);
- match_byte(0);
+ dump_data_value(0);
if (match_byte (0x31))
{
/* Custom footnote marker string. */
dump_dims ();
printf("\n\ndata:\n");
dump_data ();
- if (pos == n - 1)
- match_byte_assert (1);
+ match_byte (1);
if (pos != n)
{
fprintf (stderr, "%x / %x\n", pos, n);