From 3463d7955771d080932d78f53ef81b8cf62b4527 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 17 Jan 2024 08:05:04 -0800 Subject: [PATCH 1/2] Add 1995/heathbar/try.sh --- 1995/heathbar/README.md | 2 +- 1995/heathbar/try.sh | 52 +++++++++++++++++++++++++++++++++++++++++ thanks-for-help.md | 5 ++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100755 1995/heathbar/try.sh diff --git a/1995/heathbar/README.md b/1995/heathbar/README.md index 5f35526b3..a18afe62c 100644 --- a/1995/heathbar/README.md +++ b/1995/heathbar/README.md @@ -17,7 +17,7 @@ where num is a non-negative number. ## Try: ```sh -./heathbar 4253 2281 +./try.sh ``` diff --git a/1995/heathbar/try.sh b/1995/heathbar/try.sh new file mode 100755 index 000000000..29deea7ab --- /dev/null +++ b/1995/heathbar/try.sh @@ -0,0 +1,52 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1995/heathbar +# + +# 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 + +heathbar() +{ + if [[ "$#" -ne 2 ]]; then + echo "$0: heathbar() expects two args, got $#" 1>&2 + return + elif [[ "$1" -lt 0 || "$2" -lt 0 ]]; then + echo "$0: heathbar() expects two positive digits, got $1 $2" 1>&2 + return + fi + + read -r -n 1 -p "Press any key to run: ./heathbar $1 $2: " + echo 1>&2 + ./heathbar "$1" "$2" + echo 1>&2 + + read -r -n 1 -p "Press any key to run: echo \$(($1 + $2)): " + echo 1>&2 + echo "$(("$1" + "$2"))" + echo 1>&2 + + if [[ $(("$1"+"$2")) == "$(./heathbar "$1" "$2")" ]]; then + echo "\$(($1+$2)) == ./heathbar $1 $2: $(./heathbar "$1" "$2")" 1>&2 + else + echo "ERROR: \$(($1+$2)) != ./heathbar $1 $2: $(($1+$2)) != $(./heathbar "$1" "$2")" 1>&2 + fi + + echo 1>&2 +} +heathbar 4253 2281 +heathbar 1 2 +heathbar 3 5 +heathbar 1234 999 +read -r -n 1 -p "Press any key to try non-numbers: " +echo 1>&2 +heathbar foo bar diff --git a/thanks-for-help.md b/thanks-for-help.md index b665eea4e..e90c383b7 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2052,6 +2052,11 @@ to specify which one to use is to make it easier on the user as typing running `./try.alt.sh`. +## [1995/heathbar](/1995/heathbar/heathbar.c) ([README.md](/1995/heathbar/README.md])) + +[Cody](#cody) added the [try.sh](/1995/heathbar/try.sh) script. + + ## [1995/leo](/1995/leo/leo.c) ([README.md](/1995/leo/README.md])) At our change in how to deal with spoilers, [Cody](#cody) uudecoded the spoiler provided From 0a4af08ac9f6ad39f9e829eaf64f1d02f7881131 Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Wed, 17 Jan 2024 08:52:30 -0800 Subject: [PATCH 2/2] Add 1995/savastio/try.sh and update bugs.md The try.sh script demonstrates both positive numbers and input that is not a number at all (comparing two different strings). The bugs.md has a new INABIAF - negative numbers will hang the program. It is not clear if another version should be added to gracefully handle this but that can be decided another time. It is not a documented feature so it might be called a bug to fix. --- 1995/savastio/.gitignore | 2 ++ 1995/savastio/Makefile | 3 ++- 1995/savastio/README.md | 18 +++++++++++++-- 1995/savastio/try.sh | 49 ++++++++++++++++++++++++++++++++++++++++ bugs.md | 10 ++++++++ thanks-for-help.md | 5 ++++ 6 files changed, 84 insertions(+), 3 deletions(-) create mode 100755 1995/savastio/try.sh diff --git a/1995/savastio/.gitignore b/1995/savastio/.gitignore index 126a92046..360cec6d8 100644 --- a/1995/savastio/.gitignore +++ b/1995/savastio/.gitignore @@ -1,6 +1,8 @@ # # sort with: sort -d -u *.dSYM +bar.txt +foo.txt indent indent.c indent.o diff --git a/1995/savastio/Makefile b/1995/savastio/Makefile index ce3d09aa7..cd781bf02 100644 --- a/1995/savastio/Makefile +++ b/1995/savastio/Makefile @@ -39,7 +39,8 @@ include ../../var.mk # Common C compiler warnings to silence # CSILENCE= -Wno-empty-body -Wno-format -Wno-incompatible-library-redeclaration \ - -Wno-non-literal-null-conversion -Wno-deprecated-non-prototype -Wno-strict-prototypes + -Wno-non-literal-null-conversion -Wno-deprecated-non-prototype -Wno-strict-prototypes \ + -Wno-implicit-int # Common C compiler warning flags # diff --git a/1995/savastio/README.md b/1995/savastio/README.md index 3664b616c..8b83566a0 100644 --- a/1995/savastio/README.md +++ b/1995/savastio/README.md @@ -5,18 +5,32 @@ make all ``` +### Bugs and (Mis)features: + +The current status of this entry is: + +``` +STATUS: INABIAF - please **DO NOT** fix +``` + +For more detailed information see [1995 savastio in bugs.md](/bugs.md#1995-savastio). + + ## To use: ```sh ./savastio -# enter a number such as 100 +# enter a POSITIVE number such as 100 ``` +NOTE: if you specify a negative number it will get stuck, showing no output. But +what happens if you give a non-number? + ## Try: ```sh -echo 42 | ./savastio +./try.sh ``` diff --git a/1995/savastio/try.sh b/1995/savastio/try.sh new file mode 100755 index 000000000..8d072c172 --- /dev/null +++ b/1995/savastio/try.sh @@ -0,0 +1,49 @@ +#!/usr/bin/env bash +# +# try.sh - demonstrate IOCCC winner 1995/savastio +# + +# 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 + +read -r -n 1 -p "Press any key to run: echo 42 | ./savastio: " +echo 1>&2 +echo 42 | ./savastio +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 24 | ./savastio: " +echo 1>&2 +echo 24 | ./savastio +echo 1>&2 + +read -r -n 1 -p "Press any key to run: echo 6 | ./savastio: " +echo 1>&2 +echo 6 | ./savastio +echo 1>&2 + +rm -f foo.txt +read -r -n 1 -p "Press any key to run: echo foo | ./savastio | tee foo.txt: " +echo 1>&2 +echo foo | ./savastio | tee foo.txt +echo 1>&2 + +rm -f bar.txt +read -r -n 1 -p "Press any key to run: echo bar | ./savastio | tee bar.txt: " +echo 1>&2 +echo bar | ./savastio | tee bar.txt +echo 1>&2 + +read -r -n 1 -p "Press any key to show the diff of foo.txt and bar.txt: " +echo 1>&2 +diff -s foo.txt bar.txt +echo 1>&2 +rm foo.txt bar.txt diff --git a/bugs.md b/bugs.md index c52c760ca..bfd4cf016 100644 --- a/bugs.md +++ b/bugs.md @@ -1479,6 +1479,16 @@ supposed to be printed again and one is supposed to press a key as at that point it calls `getchar()` via the pointer `m`. So this is a feature not a bug. +## 1995 savastio + +### STATUS: INABIAF - please **DO NOT** fix +### Source code: [1995/savastio/savastio.c](1995/savastio/savastio.c) +### Information: [1995/savastio/README.md](1995/savastio/README.md) + +This program expects a POSITIVE number. If you specify a negative number it will +not show any output, stuck in a loop. + + ## 1995 vanschnitz ### STATUS: missing file - please provide it diff --git a/thanks-for-help.md b/thanks-for-help.md index e90c383b7..d20396b85 100644 --- a/thanks-for-help.md +++ b/thanks-for-help.md @@ -2071,6 +2071,11 @@ function (`pain()` as it's annoying that clang is this way :-) ) that `main()` calls which has the four args. +## [1995/savastio](/1995/savastio/savastio.c) ([README.md](/1995/savastio/README.md])) + +[Cody](#cody) added the [try.sh](/1995/savastio/try.sh) script. + + ## [1995/vanschnitz](/1995/vanschnitz/vanschnitz.c) ([README.md](/1995/vanschnitz/README.md)) [Cody](#cody) added the authors' [spoiler as a C