Add 1987/hines/try.sh
The files goto.c and goto.txt were also added. The first one is a short file that is easy to see how many 'goto's there are and the goto.txt file has seven 'goto's and one 'Goto' to demonstrate that the program is case-sensitive. The .gitignore file was updated with 'goto' though the Makefile does not have (of course) a 'goto' rule as it's only there to have a C file which is easy to see how many 'goto's there are.
This commit is contained in:
1 parent
9223a14012
commit
bc7ebdaa4b
6 files changed
+61
-1
No files matched your search
@@ -1,6 +1,7 @@
|
|||||||
#
|
#
|
||||||
# sort with: sort -d -u
|
# sort with: sort -d -u
|
||||||
*.dSYM
|
*.dSYM
|
||||||
|
goto
|
||||||
hines
|
hines
|
||||||
hines.alt
|
hines.alt
|
||||||
hines.orig
|
hines.orig
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ make all
|
|||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./hines hines.c
|
./try.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
goto x;
|
||||||
|
x: goto y;
|
||||||
|
y: goto z;
|
||||||
|
z: goto a;
|
||||||
|
a: goto end;
|
||||||
|
end: return 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
Goto goto goto goto
|
||||||
|
goto goto goto goto
|
||||||
Executable
+40
@@ -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
|
||||||
@@ -519,6 +519,14 @@ that for System V we had to do this) Cody added to the Makefile
|
|||||||
`-Dindex=strchr`.
|
`-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))
|
## <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
|
[Cody](#cody) added back the documented checks for invalid input which no longer worked
|
||||||
|
|||||||
Reference in new issue
Block a user