Merge pull request #1744 from xexyl/ovdluhe89-try

Add 1989/ovdluhe/try.sh and fix Makefile
This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-12-19 11:02:19 -08:00
commit 5601fcdee7
4 files changed
+42 -6

No files matched your search

+1 -1
View File
@@ -68,7 +68,7 @@ CINCLUDE=
# Optimization # Optimization
# #
OPT= OPT= -O3
# Default flags for ANSI C compilation # Default flags for ANSI C compilation
# #
+1 -5
View File
@@ -22,11 +22,7 @@ by chance or is killed.
### Try: ### Try:
```sh ```sh
./ovdluhe < ./ovdluhe.c ./try.sh ; sleep 2 ; ./try.sh
./ovdluhe < ./ovdluhe.c
./ovdluhe < README.md
./ovdluhe < README.md
``` ```
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 1989/ovdluhe
#
# 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
i=0
for ((i=0; i<4; ++i)); do
read -r -n 1 -p "Press any key to run: ./ovdluhe < ovdluhe.c: "
echo 1>&2
./ovdluhe < ovdluhe.c
echo 1>&2
read -r -n 1 -p "Press any key to run: ./ovdluhe < README.md: "
echo 1>&2
./ovdluhe < README.md
echo 1>&2
read -r -n 1 -p "Press any key to run: ./ovdluhe < Makefile: "
echo 1>&2
./ovdluhe < Makefile
echo 1>&2
done
+6
View File
@@ -744,6 +744,12 @@ and over again, flooding the screen. The problem is that there was a `for` loop
that by necessity had to not have an increment stage but only in the `if` path that by necessity had to not have an increment stage but only in the `if` path
(in the loop itself) did the pointer get updated. (in the loop itself) did the pointer get updated.
Cody also provided the [try.sh](/1989/ovdluhe/try.sh) script which runs the
program four times on three files to show the different output. It doesn't run
the program on each file four times in a row but rather does it on each file
and starts over, doing it four times, to help with hopefully allowing different
output.
Cody also provided an [alternate version](/1989/ovdluhe/ovdluhe.alt.c) based on the Cody also provided an [alternate version](/1989/ovdluhe/ovdluhe.alt.c) based on the
author's remarks. See the README.md for details. The fix described above was author's remarks. See the README.md for details. The fix described above was
fixed in this version too, after it was discovered and fixed. fixed in this version too, after it was discovered and fixed.