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).
104 lines
2.8 KiB
C
104 lines
2.8 KiB
C
/*
|
|
* mbcheck.c - writes the location of each string in a single char * but
|
|
* ignores single byte characters to see ONLY emojis. By write location and see
|
|
* where only emojis are it means warn about it, not print it out itself.
|
|
*
|
|
* This way I can check if the ASCII only data file has any emojis (or other
|
|
* multibyte characters) by accident. This is why it reads from the ASCII only
|
|
* data source file by default, but it can be used on data.src too with -i
|
|
* data.src to see which strings have emojis.
|
|
*
|
|
* It reads one 'string' at a time; it does not read in the whole file at once.
|
|
* The -i option allows for another file.
|
|
*/
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <ctype.h>
|
|
#include <stdlib.h>
|
|
#include <getopt.h>
|
|
#include <errno.h>
|
|
#include <stdint.h>
|
|
|
|
static unsigned loc = 0;
|
|
static char const *filename = "data.asc.src";
|
|
static uintmax_t unicode = 0;
|
|
static uintmax_t codes = 0;
|
|
static size_t i = 0;
|
|
|
|
int
|
|
main(int argc, char **argv)
|
|
{
|
|
FILE *fp = NULL;
|
|
size_t len = 0;
|
|
char *buf = NULL;
|
|
int k;
|
|
int byte;
|
|
|
|
while ((k = getopt(argc, argv, "i:l")) != -1)
|
|
{
|
|
switch (k)
|
|
{
|
|
case 'i':
|
|
filename = optarg;
|
|
break;
|
|
case 'l':
|
|
loc = 1;
|
|
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);
|
|
}
|
|
|
|
/*
|
|
* i now starts out at 1 due to the way the padded file is
|
|
*/
|
|
i = 1;
|
|
while (getdelim(&buf, &len, '\0', fp) != -1)
|
|
{
|
|
for (codes = k = 0; k[buf]; ++k)
|
|
{
|
|
byte = k[buf];
|
|
if ((byte & 0xF8) == 0xF0)
|
|
{
|
|
if (loc) printf("<%zu:%d>\n", i, k);
|
|
k += 3;
|
|
++unicode;
|
|
++codes;
|
|
}
|
|
else if ((byte & 0xF0) == 0xE0)
|
|
{
|
|
if (loc) printf("<%zu:%d>\n", i, k);
|
|
k+= 2;
|
|
++unicode;
|
|
++codes;
|
|
}
|
|
else if ((byte & 0xE0) == 0xC0)
|
|
{
|
|
if (loc) printf("<%zu:%d>\n", i, k);
|
|
++k;
|
|
++unicode;
|
|
++codes;
|
|
}
|
|
}
|
|
if (codes)
|
|
fprintf(stderr, "%4ju unicode character%s found in string %zu in file %s\n", codes,
|
|
codes==1?"":"s", i, filename);
|
|
++i;
|
|
}
|
|
|
|
fclose(fp);
|
|
fp = NULL;
|
|
printf("%ju unicode character%s found in %s\n", unicode, unicode==1?"":"s", filename);
|
|
if (unicode > 0)
|
|
exit(666);
|
|
}
|