From d8fa53cc29c8a56390443d3cc5a8092c0ec79386 Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Sat, 27 Jan 2024 10:52:18 -0800
Subject: [PATCH] Improvements to build and script of 2013/endoh4
The Makefile was modified in such a way that allows one to easily
redefine the size (in the code the S macro). For instance:
make clobber SIZE=50,50 all
The try.sh was renamed to endoh4.sh as it's more of a wrapper to the
program rather than things to try. Also it now lets one specify more
than one file to feed to the program (in sequence).
The bugs.md was updated - added INABIAF. If the file format is invalid
it will very likely crash.
---
2013/endoh4/Makefile | 6 +++-
2013/endoh4/README.md | 57 ++++++++++++++++++++++++++-----
2013/endoh4/{try.sh => endoh4.sh} | 23 +++++++++----
bugs.md | 9 +++++
thanks-for-help.md | 9 +++--
5 files changed, 86 insertions(+), 18 deletions(-)
rename 2013/endoh4/{try.sh => endoh4.sh} (60%)
diff --git a/2013/endoh4/Makefile b/2013/endoh4/Makefile
index ded40e601..7111b5cf2 100644
--- a/2013/endoh4/Makefile
+++ b/2013/endoh4/Makefile
@@ -55,9 +55,13 @@ CSTD= -std=gnu11
#
ARCH=
+# Variable to simplify redefining size
+#
+SIZE= 70,23
+
# Defines that are needed to compile
#
-CDEFINE=
+CDEFINE= -DS=${SIZE}
# Include files that are needed to compile
#
diff --git a/2013/endoh4/README.md b/2013/endoh4/README.md
index a4ca3d20e..7fbe88128 100644
--- a/2013/endoh4/README.md
+++ b/2013/endoh4/README.md
@@ -4,23 +4,45 @@
make
```
+If you wish to change the size (see the [Author's remarks](#authors-remarks)
+below) you can do so with the `SIZE` variable. For instance you can do:
+
+
+```sh
+make clobber SIZE=50,50 all
+```
+
+but you can also do this directly with the [endoh4.sh](endoh4.sh) script as
+described below.
+
+
+### Bugs and (Mis)features:
+
+The current status of this entry is:
+
+```
+STATUS: INABIAF - please **DO NOT** fix
+```
+
+For more detailed information see [2013 endoh4 in bugs.md](/bugs.md#2013-endoh4).
+
## To use:
```sh
./endoh4 < file
-./run.sh file
+./endoh4.sh file
```
The second form is preferable as it will temporarily make the cursor invisible
-as recommended by the author. If no file is specified in `run.sh` command line
-it will feed to the program [endoh4.c](endoh4.c).
+as recommended by the author. If no file is specified in the `./endoh4.sh` command
+line it will feed to the program [endoh4.c](endoh4.c).
## Try:
```sh
-./run.sh cube.txt
+./endoh4.sh cube.txt
```
Hit ctrl-c to end the program.
@@ -30,14 +52,31 @@ The author recommends the use of xterm.
For an example, if you are a football/soccer fan, try:
```sh
-./run.sh solids/archimedian-solid/a11-truncated-icosahedron.txt
+./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt
```
+You can provide more than one file:
+
+```sh
+./endoh4.sh solids/archimedian-solid/a11-truncated-icosahedron.txt cube.txt
+```
+
+Hit ctrl-c/intr to go to the next file.
+
+If you wish to change the size to `50,50` without passing any arg:
+
+
+```sh
+SIZE=50,50 ./endoh4.sh
+```
+
+Not specifying a file feeds [endoh4.c](endoh4.c) to the program.
+
## Judges' remarks:
This program is formatted as the net for a tetrahedron (hint: try feeding the
-program it's own source code like `./run.sh`). When it runs there is an
+program it's own source code like `./endoh4.sh`). When it runs there is an
animation for the computation to work out the convex hull.
@@ -69,7 +108,7 @@ This simple spec involves many details.
### Portability
I think it conforms with both C89 and C99. I confirmed that it worked on gcc,
-clang, and tcc. It should not be warned with `-pedantic` and `-Wextra`.
+clang, and tcc. It should not trigger warnings with `-pedantic` and `-Wextra`.
### Tips
@@ -85,7 +124,7 @@ tput cnorm
or
```sh
-./run.sh cube.txt
+./endoh4.sh cube.txt
```
### Bonuses
@@ -100,7 +139,7 @@ The shape of this code is the geometric net of a regular tetrahedron.
So, try:
```sh
-./endoh4 < endoh4.c # or ./run.sh
+./endoh4 < endoh4.c # or ./endoh4.sh
```
The [solids/](solids/) directory includes various solid data:
diff --git a/2013/endoh4/try.sh b/2013/endoh4/endoh4.sh
similarity index 60%
rename from 2013/endoh4/try.sh
rename to 2013/endoh4/endoh4.sh
index 82b34f2fc..486bb2e8f 100755
--- a/2013/endoh4/try.sh
+++ b/2013/endoh4/endoh4.sh
@@ -6,11 +6,13 @@
# 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
+[[ -z "$CC" ]] && CC="cc"
-make CC="$CC" all >/dev/null || exit 1
+# let user redefine size. This requires that we clobber so that they can change
+# it each time.
+[[ -z "$SIZE" ]] && SIZE=70,23
+
+make clobber CC="$CC" SIZE="$SIZE" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
@@ -23,11 +25,20 @@ trap "tput cnorm;echo" 0 1 2 3 15
tput civis
# run program attempting to feed it a file, if specified
-if [[ "$#" -eq 1 ]]; then
- ./endoh4 < "$1"
+if [[ "$#" -gt 0 ]]; then
+ while [[ "$#" -gt 0 ]]; do
+ read -r -n 1 -p "Press any key to run: ./endoh4 < $1: "
+ echo 1>&2
+ ./endoh4 < "$1"
+ echo 1>&2
+ shift 1
+ done
else
# otherwise feed the source code of the program to the program
+ read -r -n 1 -p "Press any key to run: ./endoh4 < endoh4.c: "
+ echo 1>&2
./endoh4 < endoh4.c
+ echo 1>&2
fi
# explicitly set cursor back just in case it's not terminated through one of the
diff --git a/bugs.md b/bugs.md
index aa081950b..25d8d0b16 100644
--- a/bugs.md
+++ b/bugs.md
@@ -3114,6 +3114,15 @@ A workaround is inserting a whitespace: `C2 E2`.
--
+## 2013 endoh4
+
+### STATUS: INABIAF - please **DO NOT** fix
+### Source code: [2013/endoh4/endoh4.c](2013/endoh4/endoh4.c)
+### Information: [2013/endoh4/README.md](2013/endoh4/README.md)
+
+Invalid input files will very likely crash the program.
+
+
## 2013 hou
diff --git a/thanks-for-help.md b/thanks-for-help.md
index 1d2b540de..29c1f390d 100644
--- a/thanks-for-help.md
+++ b/thanks-for-help.md
@@ -3987,11 +3987,16 @@ arg type and count to `main()`) added a second (unused) arg to `main()`.
## [2013/endoh4](/2013/endoh4/endoh4.c) ([README.md](/2013/endoh4/README.md))
-[Cody](#cody) added the [try.sh](/2013/endoh4/try.sh) script which temporarily
+[Cody](#cody) added the [endoh4.sh](/2013/endoh4/endoh4.sh) script which temporarily
turns off the cursor as suggested by the author, with the addition that if no
file is specified it will feed the source code [endoh4.c](/2013/endoh4/endoh4.c)
to the program rather than the file specified. It does not try and detect if the
-file exists or can be read as that will be handled by the shell/program.
+file exists or can be read as that will be handled by the shell/program. One may
+pass more than one file to the script.
+
+Cody also made it easier to redefine the size at compilation time (see the
+author's remarks for more details on what this means). The `endoh4.sh` script
+allows one to redefine it as well.
## [2013/hou](/2013/hou/hou.c) ([README.md](/2013/hou/README.md))