Fonts.
[pspp] / dump.c
diff --git a/dump.c b/dump.c
index 7665a4ccd0898cde3972beec00f7b6eb5efcd50f..830a5dac1dc3714ea57c2b5429651ff560d66b67 100644 (file)
--- a/dump.c
+++ b/dump.c
@@ -7,6 +7,7 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#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))