shithub: puzzles

Download patch

ref: a2bf0508c7256a62d973446fce841504580e2591
parent: df783b93e3271264a8d54f90876f41a80ef2247d
author: Ben Harris <bjh21@bjh21.me.uk>
date: Sun Feb 12 11:25:48 EST 2023

Reserialise the game in fuzzpuzz

This means that the serialising code gets tested, and also provides a
convenient way to canonicalise a (valid) save file.

--- a/fuzzpuzz.c
+++ b/fuzzpuzz.c
@@ -32,6 +32,13 @@
     return (ret == len);
 }
 
+static void savefile_write(void *wctx, const void *buf, int len)
+{
+    FILE *fp = (FILE *)wctx;
+
+    fwrite(buf, 1, len, fp);
+}
+
 int main(int argc, char **argv)
 {
     const char *err;
@@ -96,6 +103,7 @@
             midend_free(me);
             continue;
         }
+        midend_serialise(me, savefile_write, stdout);
         midend_free(me);
         ret = 0;
     }