X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=dump.c;h=830a5dac1dc3714ea57c2b5429651ff560d66b67;hb=8f03a15bc9fce38e9651dcb3ce82ba7815ccc9b5;hp=7665a4ccd0898cde3972beec00f7b6eb5efcd50f;hpb=245cfa40ee078a212b37afef1cdd052087e4f1b4;p=pspp diff --git a/dump.c b/dump.c index 7665a4ccd0..830a5dac1d 100644 --- a/dump.c +++ b/dump.c @@ -7,6 +7,7 @@ #include #include #include +#include "u8-mbtouc.h" static uint8_t *data; static size_t n; @@ -178,6 +179,22 @@ dump_raw(FILE *stream, int start, int end) } +static bool __attribute__((unused)) +all_utf8(const char *p_) +{ + const uint8_t *p = (const uint8_t *) p_; + size_t len = strlen ((char *) p); + for (size_t ofs = 0, mblen; ofs < len; ofs += mblen) + { + ucs4_t uc; + + mblen = u8_mbtouc (&uc, p + ofs, len - ofs); + if ((uc < 32 && uc != '\n') || uc == 127 || uc == 0xfffd) + return false; + } + return true; +} + static char * get_string(const char *where) { @@ -734,15 +751,19 @@ dump_fonts(void) match_byte_assert(0); if (!match_byte(0x40) && !match_byte(0x20) && !match_byte(0x80) && !match_byte(0x10) && !match_byte(0x70)) match_byte_assert(0x50); - if (!match_byte(0x41)) - match_byte_assert(0x51); + match_byte_assert(0x41); if (!match_u32(0) && !match_u32(1)) match_u32_assert(2); match_byte_assert(0); /* OK, this seems really unlikely to be totally correct, but it matches my corpus... */ if (!match_u32(0) && !match_u32(2)) - match_u32_assert(0xfaad); + { + if (i == 7) + match_u32_assert(0xfaad); + else + match_u32_assert(0); + } if (!match_u32(0) && !match_u32(1) && !match_u32(2)) match_u32_assert(3); @@ -754,7 +775,6 @@ dump_fonts(void) if (version > 1) { - /* These seem unlikely to be correct too. */ if (i != 3) { if (!match_u32(8))