Merge pull request #1823 from xexyl/hines87-try

Add 1987/hines/try.sh
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2024-01-05 09:37:48 -08:00
commit 18349c77cc
6 files changed
+61 -1

No files matched your search

+1
View File
@@ -1,6 +1,7 @@
#
# sort with: sort -d -u
*.dSYM
goto
hines
hines.alt
hines.orig
+1 -1
View File
@@ -15,7 +15,7 @@ make all
### Try:
```sh
./hines hines.c
./try.sh
```
+9
View File
@@ -0,0 +1,9 @@
int main(void)
{
goto x;
x: goto y;
y: goto z;
z: goto a;
a: goto end;
end: return 0;
}
+2
View File
@@ -0,0 +1,2 @@
Goto goto goto goto
goto goto goto goto
+40
View File
@@ -0,0 +1,40 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1987/hines
#
# 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
make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
show()
{
if [[ "$#" -ne 1 ]]; then
echo "$0: expected 1 arg to show(), got: $#" 1>&2
return
fi
read -r -n 1 -p "Press any key to show $1 (space = next page, q = quit): "
echo 1>&2
less -rEXF "$1"
echo 1>&2
read -r -n 1 -p "Press any key to run: ./hines $1: "
echo 1>&2
./hines "$1"
echo 1>&2
}
show hines.c
show goto.c
show goto.txt
+8
View File
@@ -519,6 +519,14 @@ that for System V we had to do this) Cody added to the Makefile
`-Dindex=strchr`.
## <a name="1987_hines"></a>[1987/hines](/1987/hines/hines.c) ([README.md](/1987/hines/README.md))
[Cody](#cody) added the [try.sh](1987/hines/try.sh) script and the C file
[goto.c](1987/hines/goto.c) and the text file [goto.txt](1987/hines/goto.txt)
for demonstration purposes. Notice that the program is case sensitive which
running the program on the text file demonstrates.
## <a name="1987_lievaart"></a>[1987/lievaart](/1987/lievaart/lievaart.c) ([README.md](/1987/lievaart/README.md))
[Cody](#cody) added back the documented checks for invalid input which no longer worked