diff --git a/2014/deak/Makefile b/2014/deak/Makefile index b3a68b57e..a8afc519d 100644 --- a/2014/deak/Makefile +++ b/2014/deak/Makefile @@ -137,6 +137,16 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} +# Variables to redefine the coordinates in the alt version +# +X1= -2 +X2= 1 +Y1= -1.3 +Y2= 1.3 + +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} -DX1=${X1} -DX2=${X2} -DY1=${Y1} -DY2=${Y2} $< -o $@ ${LDFLAGS} + # data files # data: ${DATA} diff --git a/2014/deak/README.md b/2014/deak/README.md index 1461e5ad6..9199e3a15 100644 --- a/2014/deak/README.md +++ b/2014/deak/README.md @@ -46,7 +46,7 @@ For instance: ```sh -make clobber CDEFINE="-DX1=-3 -DX2=2 -DY1=-2.3 -DY2=2.3" alt +make clobber X1=-3 X2=2 Y1=-2.3 Y2=2.3 alt ``` You may pick and choose which ones to redefine. @@ -57,6 +57,12 @@ You may pick and choose which ones to redefine. Use `prog.alt` as you would `prog`. +### Alternate try: + +```sh +./try.alt.sh +``` + ## Judges' remarks: We consider this entry a tribute to all "Abuse of the C preprocessor" diff --git a/2014/deak/try.alt.sh b/2014/deak/try.alt.sh new file mode 100755 index 000000000..73fa21240 --- /dev/null +++ b/2014/deak/try.alt.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# +# try.alt.sh - demonstrate IOCCC winner 2014/deak alt code +# + +# make sure CC is set so that when we do make CC="$CC" it isn't empty. Doing it +# this way allows us to have the user specify a different compiler in an easy +# way. +if [[ -z "$CC" ]]; then + CC="cc" +fi + +# compile the alt code with various parameters and run it to show different +# output + +read -r -n 1 -p "Press any key to change X1 to 2, X2 to -1 and Y1 to -2.3: " +echo 1>&2 +make -B X1=2 X2=-1 Y1=-2.3 alt >/dev/null || exit +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./prog.alt | less -EXF + +read -r -n 1 -p "Press any key to change X1 to 3, X2 to -2 and Y1 to -3.3: " +echo 1>&2 +make -B X1=3 X2=-2 Y1=-3.3 alt >/dev/null || exit +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./prog.alt | less -EXF + +read -r -n 1 -p "Press any key to change X1 to 1, X2 to -1 and Y1 to -0.3: " +echo 1>&2 +make -B X1=1 X2=-1 Y1=-0.3 alt >/dev/null || exit +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./prog.alt | less -EXF + +read -r -n 1 -p "Press any key to change X1 to 1, X2 to -1, Y1 to -0.3 and Y2 to -1.3: " +echo 1>&2 +make -B X1=1 X2=-1 Y1=-0.3 Y2=-1.3 alt >/dev/null || exit +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./prog.alt | less -EXF + +read -r -n 1 -p "Press any key to try the original configuration: " +echo 1>&2 +make clobber alt >/dev/null || exit 1 +read -r -n 1 -p "Press any key to continue (space = next page, q = quit): " +echo 1>&2 +./prog.alt diff --git a/thanks-for-help.md b/thanks-for-help.md index 40602784f..3fa1b9353 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -3682,10 +3682,10 @@ details). ## [2014/deak](/2014/deak/prog.c) ([README.md](/2014/deak/README.md)) -[Cody](#cody) added [alt code](/2014/deak/README.md#alternate-code) that lets one -reconfigure the coordinates but instead of being a modified version of the entry -it is the version the author provided which would be what the program would look -like if, as the author put it: +[Cody](#cody) added [alt code](/2014/deak/README.md#alternate-code) that lets +one (via the Makefile) reconfigure the coordinates but instead of being a +modified version of the entry it is the version the author provided which would +be what the program would look like if, as the author put it: > The usage of recognizable elements from the C programming language in the application source code is intentionally kept to a bare minimum. @@ -3697,6 +3697,8 @@ This alt version did not originally compile because a value was left off the that was fixed and it also has `#include ` for `putchar(3)`. The `#ifndef..#define..#endif` was not part of the original alt code, of course. +Cody also added the [try.alt.sh](/2014/deak/try.alt.sh) script. + ## [2014/endoh1](/2014/endoh1/prog.c) ([README.md](/2014/endoh1/README.md]))