+/* If an example has expected output, it's complete and should not be
+ * included in future examples. */
+static bool has_expected_output(char **lines)
+{
+ unsigned int i;
+
+ for (i = 0; lines[i]; i++) {
+ char *p = lines[i] + strspn(lines[i], " \t");
+ if (!strstarts(p, "//"))
+ continue;
+ p += strspn(p, "/ ");
+ if (strncasecmp(p, "given", strlen("given")) == 0)
+ return true;
+ }
+ return false;
+}
+
+static unsigned int try_compiling(struct manifest *m,
+ struct ccan_file *i,
+ char **prev,
+ struct ccan_file *mangled[3],
+ bool res[3],
+ char *err[3],
+ char **lines[3])
+{
+ unsigned int num;
+
+ /* Try standalone. */
+ mangled[0] = i;
+ res[0] = compile(i, m, mangled[0], &err[0]);
+ lines[0] = get_ccan_file_lines(i);
+ if (res[0] && streq(err[0], ""))
+ return 1;
+
+ if (prev) {
+ lines[1] = combine(i, get_ccan_file_lines(i), prev);
+
+ mangled[1] = mangle_example(m, i, lines[1]);
+ res[1] = compile(i, m, mangled[1], &err[1]);
+ if (res[1] && streq(err[1], "")) {
+ return 2;
+ }
+ num = 2;
+ } else
+ num = 1;
+
+ /* Try standalone. */
+ lines[num] = get_ccan_file_lines(i);
+ mangled[num] = mangle_example(m, i, lines[num]);
+ res[num] = compile(i, m, mangled[num], &err[num]);
+
+ return num+1;
+}
+
+static void build_examples(struct manifest *m,
+ unsigned int *timeleft UNNEEDED, struct score *score)