static bool
match_byte(uint8_t b)
{
- if (data[pos] == b)
+ if (pos < n && data[pos] == b)
{
pos++;
return true;
}
}
+static int
+find_dimensions(void)
+{
+ {
+ const char dimensions[] = "-,,,.\0";
+ int x = try_find_tail(dimensions, sizeof dimensions - 1);
+ if (x)
+ return x;
+ }
+
+ const char dimensions[] = "-,,, .\0";
+ return find_tail(dimensions, sizeof dimensions - 1);
+}
+
static void
dump_fonts(void)
{
- int i;
-
printf("fonts: offset=%08x\n", pos);
match_byte(0);
- for (i = 1; i <= 8; i++)
+ for (int i = 1; i <= 8; i++)
{
printf("%08x: font %d, ", pos, i);
match_byte_assert(i);
putchar('\n');
}
+ match_u32_assert(240);
+ pos += 240;
+
+ match_u32_assert(18);
+ pos += 18;
+
+ if (match_u32(117))
+ pos += 117;
+ else
+ {
+ match_u32_assert(142);
+ pos += 142;
+ }
+
+ int count = get_u32();
+ pos += 4 * count;
+
+ char *encoding = get_string();
+ printf("encoding=%s\n", encoding);
+
+ if (!match_u32(0))
+ match_u32_assert(UINT32_MAX);
+ if (!match_byte(0))
+ match_byte_assert(1);
+ match_byte_assert(0);
+ if (!match_byte(0))
+ match_byte_assert(1);
+ if (!match_byte(0x99) && !match_byte(0x98))
+ match_byte_assert(0x97);
+ match_byte_assert(7);
+ match_byte_assert(0);
+ match_byte_assert(0);
+ if (match_byte('.'))
+ match_byte_assert(',');
+ else
+ {
+ match_byte_assert(',');
+ if (!match_byte('.'))
+ match_byte_assert(' ');
+ }
+ match_u32_assert(5);
+ for (int i = 0; i < 5; i++)
+ get_string();
+ pos += get_u32();
+ if (pos != find_dimensions())
+ fprintf (stderr, "%08x / %08x\n", pos, find_dimensions());
}
int
}
else if (!strcmp(argv[1], "dimensions") || !strcmp(argv[1], "all"))
{
- {
- const char dimensions[] = "-,,,.\0";
- start = try_find_tail(dimensions, sizeof dimensions - 1);
- }
-
- if (!start)
- {
- const char dimensions[] = "-,,, .\0";
- start = find_tail(dimensions, sizeof dimensions - 1);
- }
-
- pos = start;
+ pos = 0x27;
+ dump_title ();
+ dump_fonts();
dump_dims ();
+ printf("\n\ndata:\n");
dump_data ();
- dump_title ();
- if (!strcmp(argv[1], "all"))
- dump_fonts();
+ if (pos == n - 1)
+ match_byte_assert (1);
+ if (pos > n)
+ {
+ fprintf (stderr, "%x / %x\n", pos, n);
+ exit(1);
+ }
exit(0);
}
else