Add alt scripts to 1994/schnitzi

This required an update to the .gitignore file.
This commit is contained in:
Cody Boone Ferguson committed 2024-01-16 08:47:33 -08:00
1 parent a8f202d825
commit 3e2287f5ec
7 files changed
+121 -10

No files matched your search

+5
View File
@@ -8,6 +8,11 @@ prog.orig
schnitzi schnitzi
schnitzi2 schnitzi2
schnitzi2.c schnitzi2.c
schnitzi3
schnitzi3.c
schnitzi.alt schnitzi.alt
schnitzi.alt2 schnitzi.alt2
schnitzi.orig schnitzi.orig
try1.txt
try2.txt
try3.txt
+1 -1
View File
@@ -39,7 +39,7 @@ include ../../var.mk
# Common C compiler warnings to silence # Common C compiler warnings to silence
# #
CSILENCE= -Wno-deprecated-declarations -Wno-error -Wno-implicit-function-declaration \ CSILENCE= -Wno-deprecated-declarations -Wno-error -Wno-implicit-function-declaration \
-Wno-strict-prototypes -Wno-strict-prototypes -Wno-implicit-int
# Common C compiler warning flags # Common C compiler warning flags
# #
+13 -8
View File
@@ -31,12 +31,7 @@ For more detailed information see [1994 schnitzi in bugs.md](/bugs.md#1994-schni
## Try: ## Try:
```sh ```sh
./schnitzi < /etc/motd 2>/dev/null ./try.sh
./schnitzi < /etc/passwd 2>/dev/null
./schnitzi < schnitzi.c > schnitzi2.c 2>/dev/null
make schnitzi2
./schnitzi2 < README.md
``` ```
@@ -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. feeding the source code to it will not work right.
### Alternate try:
```sh
./try.alt.sh
```
## Judges' remarks: ## Judges' remarks:
Try: 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 is different, but there is more than meets the `diff`'s eye. Can you
find out why? 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: ## Author's remarks:
@@ -92,14 +97,14 @@ line; for instance, for the file 'info', the program
would be run as follows: would be run as follows:
```sh ```sh
schnitzi < info ./schnitzi < info
``` ```
The program generates interesting results when its source file is The program generates interesting results when its source file is
used as input: used as input:
```sh ```sh
schnitzi < schnitzi.c ./schnitzi < schnitzi.c
``` ```
The result of this command is a program which does the exact same The result of this command is a program which does the exact same
+30
View File
@@ -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
+66
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
1994/schnitzi IOCCC winner test file.
+5 -1
View File
@@ -1935,11 +1935,15 @@ bugs.md](/bugs.md#1994-schnitzi).
The purpose for these versions it both demonstrate how the magic works behind it 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 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 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 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. 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.
## <a name="1994_shapiro"></a>[1994/shapiro](/1994/shapiro/shapiro.c) ([README.md](/1994/shapiro/README.md])) ## <a name="1994_shapiro"></a>[1994/shapiro](/1994/shapiro/shapiro.c) ([README.md](/1994/shapiro/README.md]))