From ba17ec7e8fb5e329a490d8a1e2a9cd24c355172e Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Sun, 10 Dec 2023 12:33:33 -0800
Subject: [PATCH 1/2] 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).
---
2014/deak/Makefile | 10 +++++++++
2014/deak/README.md | 6 ++++++
2014/deak/try.alt.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++
thanks-for-help.md | 10 +++++----
4 files changed, 71 insertions(+), 4 deletions(-)
create mode 100755 2014/deak/try.alt.sh
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..21bef5b60 100644
--- a/2014/deak/README.md
+++ b/2014/deak/README.md
@@ -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]))
From 57c52579a8deae0235e3ffcd87ff07de18b6b162 Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Sun, 10 Dec 2023 12:36:54 -0800
Subject: [PATCH 2/2] Minor fix in 2014/deak/README.md
Removed reference to CDEFINE for alt code as this is no longer required.
Instead refer to the more simpler way of doing it.
---
2014/deak/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/2014/deak/README.md b/2014/deak/README.md
index 21bef5b60..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.