diff --git a/1987/hines/.gitignore b/1987/hines/.gitignore index 1fe6aeb3f..164e28a8c 100644 --- a/1987/hines/.gitignore +++ b/1987/hines/.gitignore @@ -1,6 +1,7 @@ # # sort with: sort -d -u *.dSYM +goto hines hines.alt hines.orig diff --git a/1987/hines/README.md b/1987/hines/README.md index c841b0be7..12803f12e 100644 --- a/1987/hines/README.md +++ b/1987/hines/README.md @@ -15,7 +15,7 @@ make all ### Try: ```sh -./hines hines.c +./try.sh ``` diff --git a/1987/hines/goto.c b/1987/hines/goto.c new file mode 100644 index 000000000..db96f0278 --- /dev/null +++ b/1987/hines/goto.c @@ -0,0 +1,9 @@ +int main(void) +{ + goto x; + x: goto y; + y: goto z; + z: goto a; + a: goto end; + end: return 0; +} diff --git a/1987/hines/goto.txt b/1987/hines/goto.txt new file mode 100644 index 000000000..6de72a194 --- /dev/null +++ b/1987/hines/goto.txt @@ -0,0 +1,2 @@ +Goto goto goto goto +goto goto goto goto diff --git a/1987/hines/try.sh b/1987/hines/try.sh new file mode 100755 index 000000000..5abfc9c77 --- /dev/null +++ b/1987/hines/try.sh @@ -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 diff --git a/thanks-for-help.md b/thanks-for-help.md index 75776d279..1215f90a1 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -519,6 +519,14 @@ that for System V we had to do this) Cody added to the Makefile `-Dindex=strchr`. +## [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. + + ## [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