Improve how to reconfigure coords in 2014/deak

The Makefile now has variables so that one can do something like

    make X1=-1 Y2=-1 clobber alt

or whatever, with the variables X1, X2, Y1 and Y2 set to what the author
originally had it as.

The alt code still has #ifndef..#endif so that one can (if they want to
be silly) compile it without make(1).
This commit is contained in:
Cody Boone Ferguson committed 2023-12-10 12:33:33 -08:00
1 parent ff201b7a76
commit ba17ec7e8f
4 files changed
+71 -4

No files matched your search

+10
View File
@@ -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}
+6
View File
@@ -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"
+49
View File
@@ -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
+6 -4
View File
@@ -3682,10 +3682,10 @@ details).
## <a name="2014_deak"></a>[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 <stdio.h>` 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.
## <a name="2014_endoh1"></a>[2014/endoh1](/2014/endoh1/prog.c) ([README.md](/2014/endoh1/README.md]))