remove orig code from 2018/ferguson

This commit is contained in:
Landon Curt Noll committed 2023-03-07 18:33:28 -08:00
1 parent 3bde3dd167
commit 22abe83330
3 files changed
+146 -202

No files matched your search

+142 -118
View File
@@ -1,41 +1,52 @@
#!/usr/bin/env make
#
# 2018 makefile
# IOCCC 2018 winning entry - ferguson
################################################################################
#
# This work by Landon Curt Noll, Simon Cooper, and Leonid A. Broukhis
# is licensed under:
# Regarding individual entries:
#
# IOCCC winning entry code may not work on your system. Even with standards,
# conditions and build environments change, especially when it comes to more
# extreme code such you might find in an IOCCC winner. Moreover, what was
# allowed and liked in one IOCCC contest may no longer be liked/allowed in
# later IOCCC years.
#
# Corrections on winning author and fixing typos in remarks are VERY WELCOME.
#
# GitHub pull requests are welcome:
#
# If you have a patch that might make running an entry work in modern Unix-like
# environments, please create a GitHub pull request for the IOCCC judges to
# consider.
#
# Suggestions and corrections regarding Makefiles, winning author information,
# fixing typos in remarks, and code patches are welcome via opening a GitHub
# issue or better yet, by creating a GitHub pull request for the IOCCC judges
# to consider. To form a GitHub issue or GitHub pull, please visit:
#
# https://github.com/ioccc-src/winner
#
################################################################################
# This work by Landon Curt Noll and Leonid A. Broukhis is licensed under:
#
# Creative Commons Attribution-ShareAlike 3.0 Unported License.
#
# See: http://creativecommons.org/licenses/by-sa/3.0/
################
# tool locations
################
#############################
# shell used by this Makefile
#############################
#
SHELL= bash
CP= cp
CPP= cpp
GUNZIP= gunzip
BUNZIP2= bunzip2
GZIP_PROG= gzip
BZIP2= bzip2
CURL= curl
DD= dd
LD= ld
MAKE= make
RM= rm
SED= sed
TAR= tar
TRUE= true
MKDIR= mkdir
MV= mv
TR= tr
GREP= grep
SORT= sort
UNIQ= uniq
STRIP= strip
#######################
# common tool locations
#######################
#
include ../../var.mk
# Set X11_LIBDIR to the directory where the X11 library resides
#
@@ -49,29 +60,25 @@ X11_LIBDIR= /opt/X11/lib
#X11_INCDIR= /usr/X11/include
X11_INCDIR= /opt/X11/include
# Compiler warnings
#
#CWARN=
#CWARN= -Wall
#CWARN= -Wall -Wextra
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
#CWARN= -Wall -Wextra -Weverything
#CWARN= -Wall -Wextra -Weverything -pedantic
#CWARN= -Wall -Wextra -Weverything -pedantic ${CSILENCE}
# Silence warnings that ${CWARN} would normally complain about
# Common C compiler warnings to silence
#
CSILENCE=
#CSILENCE= -Wno-implicit-int
# compiler standard
# Common C compiler warning flags
#
#CWARN= ${CSILENCE}
#CWARN= -Wall ${CSILENCE}
#CWARN= -Wall -Wextra ${CSILENCE}
CWARN= -Wall -Wextra -pedantic ${CSILENCE}
# Compiler standard
#
#CSTD=
#CSTD= -ansi
CSTD= -std=c11
#CSTD= -std=c99
CSTD= -std=gnu17
# compiler bit architecture
# Compiler bit architecture
#
# Some entries require 32-bitness:
# ARCH= -m32
@@ -83,20 +90,21 @@ CSTD= -std=c11
#
ARCH=
# defines that are needed to compile
# Defines that are needed to compile
#
CDEFINE= -DQ='typedef' -D'g(o)'='goto o;' -D'w(x)'="x:" -D'H(main)'='r(main)'
#CDEFINE= -DIOCCC=25
# include files that are needed to compile
# Include files that are needed to compile
#
CINCLUDE=
#CINCLUDE= -include stdlib.h
#CINCLUDE= -include stdio.h
#CINCLUDE= -include stdlib.h -include stdio.h
#CINCLUDE= -I ${X11_INCDIR}
#CINCLUDE= -I ${HOMEBREW_PREFIX}/include/SDL2
# optimization
# Optimization
#
# Most compiles will safely use -O2. Some can use only -O1 or -O.
# A few compilers have broken optimizers or this entry make break
@@ -108,89 +116,99 @@ CINCLUDE=
#OPT= -O1
#OPT= -O2
OPT= -O3
#OPT= -O0
# default flags for ANSI C compilation
# Default flags for ANSI C compilation
#
CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
# Libraries needed to build
#
LIBS=
#LIBS= -L ${X11_LIBDIR}
#LIBS= -lm
#LIBS= -L ${X11_LIBDIR} -lX11
#LIBS= -L ${HOMEBREW_PREFIX}/lib -lSDL
# ANSI compiler
#
# Set CC to the name of your ANSI compiler.
#
# Some entries seem to need gcc. If you have gcc, set
# both CC and MAY_NEED_GCC to gcc.
#
# If you do not have gcc, set CC to the name of your ANSI compiler, and
# set MAY_NEED_GCC to either ${CC} (and hope for the best) or to just :
# to disable such programs.
# C compiler to use
#
CC= cc
#CC=clang
MAY_NEED_GCC= gcc
#CC=gcc
# Compiler add-ons or replacements for clang only
#
ifeq ($(CC),clang)
#
CSILENCE+= -Wno-padded -Wno-poison-system-directories
#
CWARN+= -Weverything
#
endif
# Specific add-ons or replacements for gcc only
#
ifeq ($(CC),gcc)
#
#CSILENCE+=
#
#CWARN+=
#
endif
##############################
# Special flags for this entry
##############################
#
OBJ= prog.o
DATA=
TARGET= prog weasel
ENTRY= ferguson
PROG= prog
#
ALT_OBJ= prog-simple.o
ALT_TARGET= prog-simple weasel-simple prog.orig
OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
#################
# build the entry
#################
#
all: ${TARGET} ${DATA} ${ALT_TARGET}
all: data ${TARGET}
@${TRUE}
prog: prog.c
.PHONY: all alt data everything clean clobber install \
love haste waste maker easter_egg sandwich \
supernova deep_magic magic charon pluto
${PROG}: ${PROG}.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
weasel: prog
${CP} -f $< $@
test: prog test.sh
./test.sh
# alternative executable
#
alt: ${ALT_TARGET}
alt: data ${ALT_TARGET}
@${TRUE}
prog-simple: prog-simple.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
weasel-simple: prog-simple
${CP} -f $< $@
prog.orig: prog.orig.c
${CC} ${CFLAGS} $< -o $@ ${LIBS}
# data files
#
data: ${DATA}
@${TRUE}
# both all and alt
#
everything: all alt
###############
# utility rules
###############
#
everything: all alt
clean:
${RM} -f ${OBJ} ${ALT_OBJ}
@-if [ -f indent.c ]; then \
echo ${RM} -f indent.c; \
${RM} -f indent.c; \
fi
clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET}
@@ -199,20 +217,28 @@ clobber: clean
echo 'ate sandwich'; \
fi
nuke: clobber
@${TRUE}
dist_clean: nuke
@${TRUE}
install:
@echo "Surely you are performing, Dr. May!"
@echo "Dr. Spock says that is not logical!"
@${TRUE}
# backwards compatibility
# you may be able to misunderstand the source by reading indent.c
#
build: all
@${TRUE}
indent.c: ${PROG}.c
@if which "${GINDENT}" >/dev/null 2>&1; then \
echo ${RM} -f $@; \
${RM} -f $@; \
echo "${GINDENT} < $< > $@"; \
${GINDENT} < $< > $@; \
elif which "${INDENT}" >/dev/null 2>&1; then \
echo ${RM} -f $@; \
${RM} -f $@; \
echo "${INDENT} < $< > $@"; \
${INDENT} < $< > $@; \
else \
echo "no intent tool found, ident $< yourself, sorry"; \
echo "exit 1"; \
exit 1; \
fi
##################
@@ -231,22 +257,19 @@ waste:
@echo 'haste'
@${TRUE}
make:
@echo 'Attend a maker faire'
maker:
@echo 'Participate in a maker faire'
@${TRUE}
easter_egg:
@echo you expected to often mis-understand this $${RANDOM} magic
@echo chongo '<was here>' "/\\oo/\\"
@echo Eggy
@echo "you expected to often misunderstand this $${RANDOM} magic"
@echo "chongo '<was here>' /\\oo/\\"
@echo "Eggy"
fabricate fashion form frame manufacture produce: make
@${TRUE}
sandwich:
sandwich: easter_egg
@if [ `id -u` -eq 0 ]; then \
echo 'Okay.'; \
echo $${RANDOM}`date +%s`$${RANDOM} > $@; \
echo "$${RANDOM}`date +%s`$${RANDOM}" > $@; \
else \
echo 'What? Make it yourself.'; \
exit 1; \
@@ -256,18 +279,19 @@ sandwich:
# as well as the West Coast Computer Faire and
# you might be confused different. :-)
#
supernova: nuke
supernova: sandwich
@-if [ -r .code_anal ]; then \
${RM} -f .code_anal_v6; \
else \
echo "planet deniers, like some members of the IAU, are so cute when they try to defend their logic"; \
fi
@echo A $@ helps ${MAKE} the elements that help form planets
@echo "A $@ helps ${MAKE} the elements that help form planets"
@${TRUE}
deep_magic:
deep_magic: supernova
@-if [ -r .code_anal ]; then \
ccode_analysis --deep_magic 3a3fabb90892eeb2f610ae0f74a35a970060665a063ab702bd686c17c4ae07f6 --FNV1a_hash_256_bit "prog"; \
ccode_analysis --deep_magic 7889066cdbdf09b0408021754586e895be641cc9be29e7eafd3ca65359541f17 \
--FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \
else \
echo "Wrong! Do it again!"; \
sleep 2; \
@@ -279,7 +303,7 @@ deep_magic:
magic: deep_magic
@-if [ -r .code_anal ]; then \
ccode_analysis --mode 216091 --level 216193 --FNV1a_hash_256_bit "prog"; \
ccode_analysis --level 20003 --mode 5717175 --FNV1a_hash_512_bit -v2 "${PROG}" "${PROG}.c"; \
else \
echo "If you don't eat yer meat, you can't have any pudding!"; \
echo "How can you have any pudding if you don't eat yer meat?!"; \
@@ -288,14 +312,14 @@ magic: deep_magic
# The IOCCC resident astronomer states
#
charon: supernova
@echo $@ is a dwarf planet
@echo dwarf is a type of planet
@echo $@ is a planet
charon: magic
@echo "$@ is a dwarf planet"
@echo "dwarf is a type of planet"
@echo "therefore IAU, $@ is a planet"
pluto: supernova
pluto: charon
${MAKE} charon
@echo $@ is a dwarf planet
@echo dwarf is a type of planet
@echo $@ is a planet
@echo get used to having lots of planets becasue supernovae can ${MAKE} a lot of them
@echo "$@ is a dwarf planet"
@echo "dwarf is a type of planet"
@echo "therefore, $@ is a planet"
@echo "having lots of planets is good feature because supernovae can help ${MAKE} a lot of them"
+4 -4
View File
@@ -4,11 +4,11 @@ Cody Boone Ferguson <weasel@xexyl.net>
<https://ioccc.xexyl.net/2018/weasel>
Twitter: @xexyl
## To build:
## Judges' comments:
### To use:
make all
make
### To rum
./weasel
@@ -41,8 +41,8 @@ If you find yourself in an evolutionary dead end, try:
man ./weasel.man
## Author's comments:
0. Preface
1. What it is
2. How it works
-80
View File
@@ -1,80 +0,0 @@
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<ctype.h>
#include<time.h>
#include<stdint.h>
Q unsigned d; Q char E; Q int k;
Q long u; Q size_t t; Q const char U;
#define L toupper
#define M SIZE_MAX-1
#ifndef S
#define S 38
#elif S < 38
#undef S
#define S 38
#elif S > M
#undef S
#define S M
#endif
#define l S-1
#define Y strlen
#define Z printf
#define K static
#define z do{
K E W[]="stqvvwxzwtzuvvryusuxvtrqsruxttrxvwqxq"; K E T[S]= {77,69,84,72,73,78,75,83,32,73,84,32,73,83,32,76,73,75,69,32,65,32,87,69,65,83,69,76,0} ;
K U C[] =" !\"#$<%:>&'()*+,-./0123456789;=?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`{|}~";
/*NO*/
K E P[2][sizeof(T)]; K t G=0;
#ifndef N
#define N 25
#elif N < 4
#undef N
#define N 3
#elif N > M
#undef N
#define N M
#endif
/*BLOB*/
K u R=1; K d D=0; K k X(k f,k t){ return (rand()%((t)-(f)+1)+(f)); }
K E c() {return C[X(0,(k)Y(C)-1)];%> Q struct x { E G[sizeof T];
t F; } x; K x O[N];
/* Special C main() handler (encapsulation): */
#define r(main) main
r(k main(k a, E **V)) { x x; E*b;
U *A=T; k h=0,s,q=0,m=0,y=0,n=N==97,J=0; t i,j,
/* prototype for special C parser H() below */
F H(); H(<% H(for (s = 1; s < a && *V[s++]; ) H(<%
H(E *v=V[s-1]; H(if (*v!='-'||h) H(g(o) w(f) H(
while (*++v) H(switch (*v) { w(case '-') h=1; g(f)
w(case 'r') H(if ((R=strtol(v+1,&b,0)) < 1 || R > 100)/*CODING*/
<% Z("mutation rate out of range\n") ; m=1); %> else m=0; g(f)
w(case 'q') q=1; Z("quiet output\n") ; g(f) w(case 'm') J=1;
g(f) w(default) g(f) %>); H(continue))); H(w(o) H(y=1;
H(i = Y(V<:s-1]); H(if(i > l) i=l; H( strncpy(T,V[s-1:>,i)
; H(T[i]='\0')))))))); })); }); H(H(if (n&&!y) for (j=0
; j<37; ++j) T[j]=W[j]-'A'); H(for ( ; *A && strchr(C, L(*A))
; ++A)); H(if (*A) <% Z("'%c' not in keyboard \"%s\"\n", *A,C)
; return 0; })/*THIS*/); H(srand((d)time(0)); memset(&x, 0, sizeof x);
memset(O,0,sizeof O)); H(Z(/*IS*/"target '%s'\n", T); H(Z(
"mutation rate %ld\n", R)); H(if((m=(m||J||N<4)))
Z("monkey at typewriter\n"); H(for ( j=0; j<N; ++j) H(for
(i=0; i<Y(T); ++i) O[j].G[i]=c())))); H(while (!D) { H(if (++
G==M) {Z("Too many attempts, blaming the monkey Eric even if "
"he isn't typing or doesn't exist. Bye.\n"); return 1; } H(for
(j=0; j<N&&!D; ++j) { F = 0;/*NOT*/ H(for (i =0; i < Y(T); ++i)) { H(
if (L(O[j].G[i]) == L(T[i]))) ++F; } /*A*/ O[j].F=F; H(if (((D=(F==Y(T)))
||G==1)&&(!q||D)) Z("Generation %4zu\tOffspring %2zu: %s\n",G
-1,j+1,O[j] .G); })); H(if (D)break;); s=0; /*COMPACT*/ H(if (m) g(p) else H(z
s=1; H(for(i=0; i<N-1; ++i) { H(if (O<:i].F >= O[i+1].F) g(h)) x=O[
i+1:>; O[i]=O[i+1]; O[i+1]=x; s=0; w(h); }); }while(!s))); w(p
) H(strcpy(P[0],O[0].G); strcpy(P[1],O[1].G)); H(for (j=0; j<N; ++j)
{ H(for (i=0;!m&&i<Y(T); ++i) H(if ( X(0,9)<5) O[j] .
G[i]=P[0][i]); H(else O[j] . G[i]=P[1][i];)); /*BLOB*/ H(if (!
q) Z("Generation %4zu\tOffspring %2zu: %s -> " ,G,j+1,O[j].
G); H(for/*OF*/ (i=0; i<Y(T); ++i) { H(if (X(1,100) <= R || m)
O[j].G[i]=c(); })); H(if (!q) Z("%s (%s)\n",O[j].G,m
?"monkey typing" : "mutation"))); /*OCTETS*/ }); H(if (!
q) Z("**\n")); })); return 0; }