From 3e2287f5ec7e49431d68af04388cef72ff885e4f Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Tue, 16 Jan 2024 08:47:33 -0800
Subject: [PATCH 1/5] Add alt scripts to 1994/schnitzi
This required an update to the .gitignore file.
---
1994/schnitzi/.gitignore | 5 +++
1994/schnitzi/Makefile | 2 +-
1994/schnitzi/README.md | 21 ++++++++-----
1994/schnitzi/try.alt.sh | 30 ++++++++++++++++++
1994/schnitzi/try.sh | 66 ++++++++++++++++++++++++++++++++++++++++
1994/schnitzi/try.txt | 1 +
thanks-for-help.md | 6 +++-
7 files changed, 121 insertions(+), 10 deletions(-)
create mode 100755 1994/schnitzi/try.alt.sh
create mode 100755 1994/schnitzi/try.sh
create mode 100644 1994/schnitzi/try.txt
diff --git a/1994/schnitzi/.gitignore b/1994/schnitzi/.gitignore
index f8f3ac60e..07752b42f 100644
--- a/1994/schnitzi/.gitignore
+++ b/1994/schnitzi/.gitignore
@@ -8,6 +8,11 @@ prog.orig
schnitzi
schnitzi2
schnitzi2.c
+schnitzi3
+schnitzi3.c
schnitzi.alt
schnitzi.alt2
schnitzi.orig
+try1.txt
+try2.txt
+try3.txt
diff --git a/1994/schnitzi/Makefile b/1994/schnitzi/Makefile
index b19f80c7f..89928da1b 100644
--- a/1994/schnitzi/Makefile
+++ b/1994/schnitzi/Makefile
@@ -39,7 +39,7 @@ include ../../var.mk
# Common C compiler warnings to silence
#
CSILENCE= -Wno-deprecated-declarations -Wno-error -Wno-implicit-function-declaration \
- -Wno-strict-prototypes
+ -Wno-strict-prototypes -Wno-implicit-int
# Common C compiler warning flags
#
diff --git a/1994/schnitzi/README.md b/1994/schnitzi/README.md
index 33f4adfbc..ca8fd4440 100644
--- a/1994/schnitzi/README.md
+++ b/1994/schnitzi/README.md
@@ -31,12 +31,7 @@ For more detailed information see [1994 schnitzi in bugs.md](/bugs.md#1994-schni
## Try:
```sh
-./schnitzi < /etc/motd 2>/dev/null
-./schnitzi < /etc/passwd 2>/dev/null
-
-./schnitzi < schnitzi.c > schnitzi2.c 2>/dev/null
-make schnitzi2
-./schnitzi2 < README.md
+./try.sh
```
@@ -65,6 +60,13 @@ Use `schnitzi.alt` and `schnitzi.alt2` as you would `schnitzi` above except that
feeding the source code to it will not work right.
+### Alternate try:
+
+```sh
+./try.alt.sh
+```
+
+
## Judges' remarks:
Try:
@@ -77,6 +79,9 @@ Compare the output of the program with its source. Sure the output
is different, but there is more than meets the `diff`'s eye. Can you
find out why?
+You might also wish to redirect the output to another file,
+compile it and compare how it works to the original code.
+
## Author's remarks:
@@ -92,14 +97,14 @@ line; for instance, for the file 'info', the program
would be run as follows:
```sh
-schnitzi < info
+./schnitzi < info
```
The program generates interesting results when its source file is
used as input:
```sh
-schnitzi < schnitzi.c
+./schnitzi < schnitzi.c
```
The result of this command is a program which does the exact same
diff --git a/1994/schnitzi/try.alt.sh b/1994/schnitzi/try.alt.sh
new file mode 100755
index 000000000..2e61c3d39
--- /dev/null
+++ b/1994/schnitzi/try.alt.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+#
+# try.alt.sh - demonstrate IOCCC winner 1994/schnitzi alt code
+#
+
+# 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" alt >/dev/null || exit 1
+
+
+read -r -n 1 -p "Press any key to run: ./schnitzi.alt < README.md (space = next page, q = quit): "
+echo 1>&2
+./schnitzi.alt < README.md | less -rEXF
+echo 1>&2
+
+echo "$ ./schnitzi.alt2 < schnitzi.alt2.c | diff - schnitzi.c" 1>&2
+read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
+echo 1>&2
+./schnitzi.alt2 < schnitzi.alt2.c | diff - schnitzi.c
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: ./schnitzi.alt2 < README.md (space = next page, q = quit): "
+echo 1>&2
+./schnitzi.alt2 < README.md
+echo 1>&2
diff --git a/1994/schnitzi/try.sh b/1994/schnitzi/try.sh
new file mode 100755
index 000000000..1da6af393
--- /dev/null
+++ b/1994/schnitzi/try.sh
@@ -0,0 +1,66 @@
+#!/usr/bin/env bash
+#
+# try.sh - demonstrate IOCCC winner 1994/schnitzi
+#
+
+# 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
+
+
+read -r -n 1 -p "Press any key to run: ./schnitzi < schnitzi.c > schnitzi2.c: "
+echo 1>&2
+./schnitzi < schnitzi.c > schnitzi2.c 2>/dev/null
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: make schnitzi2: "
+echo 1>&2
+make schnitzi2
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: ./schnitzi2 < schnitzi2.c > schnitzi3.c: "
+echo 1>&2
+./schnitzi2 < schnitzi2.c > schnitzi3.c 2>/dev/null
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: make schnitzi3: "
+echo 1>&2
+make schnitzi3
+echo 1>&2
+
+
+read -r -n 1 -p "Press any key to run: diff3 schnitzi.c schnitzi2.c schnitzi3.c (space = next page, q = quit): "
+echo 1>&2
+diff3 schnitzi.c schnitzi2.c schnitzi3.c | less -rEXF
+echo 1>&2
+
+read -r -n 1 -p "Press any key to show try.txt: "
+echo 1>&2
+cat try.txt
+echo 1>&2
+
+rm -f try1.txt try2.txt try3.txt
+read -r -n 1 -p "Press any key to run: ./schnitzi < try.txt | tee try1.txt (space = next page, q = quit): "
+echo 1>&2
+./schnitzi < try.txt 2>/dev/null | tee try1.txt
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: ./schnitzi2 < try.txt | tee try2.txt (space = next page, q = quit): "
+echo 1>&2
+./schnitzi2 < try.txt 2>/dev/null | tee try2.txt
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: ./schnitzi3 < try.txt | tee try3.txt (space = next page, q = quit): "
+echo 1>&2
+./schnitzi3 < try.txt 2>/dev/null | tee try3.txt
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: diff3 try1.txt try2.txt try3.txt: "
+echo 1>&2
+diff3 try1.txt try2.txt try3.txt && echo "All three files are the same!"
+echo 1>&2
diff --git a/1994/schnitzi/try.txt b/1994/schnitzi/try.txt
new file mode 100644
index 000000000..f175fa345
--- /dev/null
+++ b/1994/schnitzi/try.txt
@@ -0,0 +1 @@
+1994/schnitzi IOCCC winner test file.
diff --git a/thanks-for-help.md b/thanks-for-help.md
index 8889a8e75..282c8d7a0 100644
--- a/thanks-for-help.md
+++ b/thanks-for-help.md
@@ -1935,11 +1935,15 @@ bugs.md](/bugs.md#1994-schnitzi).
The purpose for these versions it both demonstrate how the magic works behind it
and to help others, should they wish, get the code to work with `fgets(3)`, with
-or without an increase in buffer size. See [1994/schnitzi in
+or without an increase in buffer size. Note that without this feeding longer
+files, say the README.md file, will crash the program. See [1994/schnitzi in
bugs.md](/bugs.md#1994-schnitzi) where Cody also explains the magic for more
details. Later on, if nobody takes up the task, Cody might resume it, but for
now there is more important work to do so that the next contest can run.
+Cody also added the [try.sh](/1994/schnitzi/try.sh) and
+[try.alt.sh](/1994/schnitzi/try.alt.sh) scripts.
+
## [1994/shapiro](/1994/shapiro/shapiro.c) ([README.md](/1994/shapiro/README.md]))
From edbbfedacd963450085a47a1df75aea45e0f1db4 Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Tue, 16 Jan 2024 09:09:19 -0800
Subject: [PATCH 2/5] Add 1994/ldb/try.sh
---
1994/ldb/README.md | 6 +-----
1994/ldb/try.sh | 41 +++++++++++++++++++++++++++++++++++++++++
thanks-for-help.md | 17 +++++++++--------
3 files changed, 51 insertions(+), 13 deletions(-)
create mode 100755 1994/ldb/try.sh
diff --git a/1994/ldb/README.md b/1994/ldb/README.md
index 56d903f1b..c1dc4d873 100644
--- a/1994/ldb/README.md
+++ b/1994/ldb/README.md
@@ -28,11 +28,7 @@ some_command | ./ldb
## Try:
```sh
-./ldb < /etc/passwd
-
-printf "The International Obfuscated C Code Contest\n
- Best One-liner\n
- by Laurion Burchall" | ./ldb
+./try.sh
```
diff --git a/1994/ldb/try.sh b/1994/ldb/try.sh
new file mode 100755
index 000000000..e0471b94f
--- /dev/null
+++ b/1994/ldb/try.sh
@@ -0,0 +1,41 @@
+#!/usr/bin/env bash
+#
+# try.sh - demonstrate IOCCC winner 1994/ldb
+#
+
+# 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
+
+ldb_file()
+{
+ if [[ "$#" != 1 ]]; then
+ echo "$0: ldb_file() expects 1 arg, got $#" 1>&2
+ return
+ fi
+ read -r -n 1 -p "Press any key to run: ./ldb < $1: "
+ echo 1>&2
+ ./ldb < "$1" | sed '/^$/d'
+ echo 1>&2
+}
+
+ldb_ioccc()
+{
+ echo "$ printf \"The International Obfuscated C Code Contest\\nBest One-liner\\nby Laurion Burchall\" | ./ldb"
+ read -r -n 1 -p "Press any key to continue: "
+ echo 1>&2
+ printf "The International Obfuscated C Code Contest\nBest One-liner\nby Laurion Burchall" | ./ldb | sed '/^$/d'
+ echo 1>&2
+}
+
+for i in $(seq 1 5); do
+ ldb_file /etc/passwd
+ ldb_ioccc
+ ldb_file ldb.c
+ ldb_file README.md
+done
diff --git a/thanks-for-help.md b/thanks-for-help.md
index 282c8d7a0..b665eea4e 100644
--- a/thanks-for-help.md
+++ b/thanks-for-help.md
@@ -1903,7 +1903,7 @@ entries that actually did not work because of missing or incorrect prototypes).
## [1994/ldb](/1994/ldb/ldb.c) ([README.md](/1994/ldb/README.md]))
[Cody](#cody) fixed this so it would compile and work with modern compilers. The problem
-was that `srand()` returns void but it was used in a `||` expression. Thus the
+was that `srand()` returns `void` but it was used in a `||` expression. Thus the
comma operator was needed.
Cody also fixed it for clang under Linux which objected to incompatible pointer
@@ -1913,14 +1913,15 @@ but what was being passed to it is an `int`).
Cody also changed the entry to use `fgets(3)` instead of `gets(3)`. This one has
a minor annoyance in that it now prints a newline after the output but this
seems like a worthy compromise for preventing the interspersed output in macOS
-and at the same time it's safer (fixing it to not have the extra newline is more
-problematic than it's worth and in macOS another line of output would be shown
-without the change anyway and the difference is that now it's just a blank line
-rather than an annoying warning).
+and at the same time it's safer and allows for parsing file with longer lines.
+Fixing it it to not have the extra newline is more problematic than it's worth,
+in macOS another line of output would be shown without the change anyway -
+unless `2>/dev/null` - and the difference is that now it's just a blank line
+rather than an annoying warning. A subtlety about this fix: if a line is greater
+than 231 in length if the program chooses that line it might print the first 231
+characters or it might print (up to) the next 231 characters and so on.
-A subtlety about this fix: if a line is greater than 231 in length if the
-program chooses that line it might print the first 231 characters or it might
-print (up to) the next 231 characters and so on.
+Cody also added the [try.sh](/1994/ldb/try.sh) script.
## [1994/schnitzi](/1994/schnitzi/schnitzi.c) ([README.md](/1994/schnitzi/README.md]))
From 0b33dbb9f08ea7b793a06e1c7edca42e45a67e80 Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Tue, 16 Jan 2024 09:11:03 -0800
Subject: [PATCH 3/5] Fix typo in 1994/dodsond2/README.md
---
1994/dodsond2/README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/1994/dodsond2/README.md b/1994/dodsond2/README.md
index 6761aa134..ce9713ad3 100644
--- a/1994/dodsond2/README.md
+++ b/1994/dodsond2/README.md
@@ -31,7 +31,7 @@ For more detailed information see [1994 dodsond2 in bugs.md](/bugs.md#1994-dodso
## Alternate code:
This version allows you to choose how many arrows to start with, instead of the
-default 0. If one tried specifying a value < 0 it will set it to 0.
+default 0. If one tries specifying a value < 0 it will set it to 0.
Fun fact: this version helped uncover and fix a bug that prevented the entry
from working in some cases.
From d1b6f9531bd88afc667742abc5870b35c118bc38 Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Tue, 16 Jan 2024 12:10:25 -0800
Subject: [PATCH 4/5] Slightly improve 1995/dodsond1/try.sh
---
1995/dodsond1/try.sh | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/1995/dodsond1/try.sh b/1995/dodsond1/try.sh
index 817cb73dc..d87ecb209 100755
--- a/1995/dodsond1/try.sh
+++ b/1995/dodsond1/try.sh
@@ -17,8 +17,12 @@ make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
-echo "$ cat try.this.txt"
+read -r -n 1 -p "Press any key to show try.this.txt: "
+echo 1>&2
cat try.this.txt
+echo 1>&2
-echo "$ ./dodsond1 < try.this.txt"
+read -r -n 1 -p "Press any key to run: ./dodsond1 < try.this.txt: "
+echo 1>&2
./dodsond1 < try.this.txt
+echo 1>&2
From 7390b11f251fc5577ee3dfdfc2a25449ca75c750 Mon Sep 17 00:00:00 2001
From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com>
Date: Tue, 16 Jan 2024 12:24:17 -0800
Subject: [PATCH 5/5] Improve 1995/esde/try.sh
---
1995/esde/try.sh | 24 +++++++++++++++++++-----
1 file changed, 19 insertions(+), 5 deletions(-)
diff --git a/1995/esde/try.sh b/1995/esde/try.sh
index e64239021..c6ae1ad31 100755
--- a/1995/esde/try.sh
+++ b/1995/esde/try.sh
@@ -15,13 +15,27 @@ make CC="$CC" all >/dev/null || exit 1
# clear screen after compilation so that only the entry is shown
clear
-echo "$ ./esde esde.data Johanson"
+read -r -n 1 -p "Press any key to show esde.data: "
+echo 1>&2
+cat esde.data
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: ./esde esde.data Johanson: "
+echo 1>&2
./esde esde.data Johanson
-echo
+echo 1>&2
-echo "$ ./esde esde.data2 read"
+read -r -n 1 -p "Press any key to show esde.data2: "
+echo 1>&2
+cat esde.data2
+echo 1>&2
+
+read -r -n 1 -p "Press any key to run: ./esde esde.data2 read: "
+echo 1>&2
./esde esde.data2 read
-echo
+echo 1>&2
-echo "$ ./esde README.md date"
+read -r -n 1 -p "Press any key to run: ./esde README.md date: "
+echo 1>&2
./esde README.md date
+echo 1>&2