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.
This commit is contained in:
Cody Boone Ferguson committed 2024-01-27 10:52:18 -08:00
1 parent 6f20a57493
commit d8fa53cc29
5 files changed
+86 -18

No files matched your search

+5 -1
View File
@@ -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
#
+48 -9
View File
@@ -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:
+17 -6
View File
@@ -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