Files
Cody Boone Ferguson ad622a5354 2024/ferguson1 bug fix, make goto complete (149)
A bug was discovered in prog.c (now prog.alt2.c, see below) that has
been fixed. It was not a critical bug but it came about when juggling
things during development, and fixing it means there should now only be
one place where an event might not trigger (or actually it's an event
within an event that does not trigger - polymorphism related).

The prog.c is the goto complete version - what was once prog.goto.max.c
(git status is confused however - it shows that that file is now
prog.alt2.c but actually prog.alt2.c is what prog.c was). For practical
reasons (and to make the judges not weep and curse me quite as much)
this was not the prog.c but since some others have made corrections to
their winning code I have decided to do the same thing here. It was a
hassle to juggle between the different versions and I ran out of the
number of files allowed - that is what I mean by practical reasons.

The prog.c has maintained its thematic 4666 bytes, after some formatting
updates.

Typo fixes were made in some of the supplementary C files.

Makefile updated so that one can compile prog.alt2.c.

.entry.json, index.html and obfuscation.html were all updated.

The judges' remarks were slightly corrected. It is not 134 (now 149)
jumps that occurs but rather gotos. The jumps can be over 1000, in fact
one test run was over 1400, although shorter games can be fewer (though
still a lot).

Other errors in documentation that were artefacts from earlier stages in
development were also corrected, although I'm sure there are more (the
ones that were discovered were ones near to stats that had to be
updated).
2025-08-13 08:14:05 -07:00

70 lines
1.7 KiB
C

/*
* printer.c - prints out everything from data file for visual inspection
*
* This tool can be used to not only help identify if your system will work with
* the emojis data file but also show what the strings are without having to
* look at the source data file (this program decrypts the strings in a similar
* way to the game itself, see below).
*
* Using the macro (identical except it uses puts() on some of the strings that
* are unencrypted) from prog.c we will print out every string
* at every location in the order it occurs.
*/
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <getopt.h>
#include <errno.h>
/*
* macro similar to prog.c
*/
#define Z(x) (x)*BLOCKSIZE
#define V(x) puts(&y[Z(x)]);
static char *y;
static char *filename = "data";
static size_t len;
static int k;
int main(int argc, char **argv)
{
FILE *fp = NULL;
while ((k = getopt(argc, argv, "i:")) != -1)
{
switch (k)
{
case 'i':
filename = optarg;
break;
case ':':
case '?':
exit(1);
break; /* this triggered an annoying warning but it's an extra sanity check */
}
}
errno = 0;
fp = fopen(filename, "r");
if (fp == NULL)
{
fprintf(stderr, "couldn't open data file %s: %s\n", filename, strerror(errno));
exit(1);
}
if (getdelim(&y, &len, EOF, fp) != -1)
{
/*
* now we have to test every single string to make sure it's valid.
* The makedata.sh script generates V.c.
*/
#include "V.c"
}
free(y);
y = NULL;
fclose(fp);
fp = NULL;
}