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:
1 parent
6f20a57493
commit
d8fa53cc29
5 files changed
+86
-18
No files matched your search
@@ -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
@@ -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:
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
+7
-2
@@ -3987,11 +3987,16 @@ arg type and count to `main()`) added a second (unused) arg to `main()`.
|
||||
|
||||
## <a name="2013_endoh4"></a>[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.
|
||||
|
||||
|
||||
## <a name="2013_hou"></a>[2013/hou](/2013/hou/hou.c) ([README.md](/2013/hou/README.md))
|
||||
|
||||
Reference in new issue
Block a user