Add 2006/birken/try.sh, bugs.md, format/typo check

The try.sh runs the program on all the tofu input files, prompting the
user to press a key before running each one so they have time to look at
the output of the previous one.

The README.md file format and typo checked.

This should complete 2006/birken except that it uses gets(), not
fgets(), which has been added to the bugs.md file. I almost got it to
work but it crashes with computer.tofu so I did not change it. Will look
at this later, maybe, but the bugs.md has a diff of the single change
that almost works. I did not have the time to write where it fails but I
do happen to know at least the end result.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-24 08:13:04 -08:00
1 parent e9ffd327d6
commit 8231e28567
4 files changed
+108 -13

No files matched your search

+21 -13
View File
@@ -5,6 +5,17 @@ make
```
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: uses gets() - change to fgets() if possible
```
For more detailed information see [2006 birken in bugs.md](/bugs.md#2006-birken).
## To use:
```sh
@@ -15,10 +26,7 @@ make
### Try:
```sh
./birken < counter.tofu
./birken < adder.tofu
./birken < buffer.tofu
./birken < computer.tofu
./try.sh
```
etc.
@@ -30,22 +38,22 @@ Q: EDAMAME?
A: Electronic Design Automation - Mechanical Abstract Machine Emulator
What is TUFO? It's not a veggy friendly food, nor it is Verilog or
VHDL. It is not even Pascal!
What is TOFU? It's not a veggie friendly food, nor it is
[Verilog](https://en.wikipedia.org/wiki/Verilog) or
[VHDL](https://en.wikipedia.org/wiki/VHDL) It is not even
[Pascal](https://en.wikipedia.org/wiki/Pascal_(programming_language))!
NOTE: On some systems, file(1) claims one of the .tofu files is Pascal
NOTE: On some systems, `file(1)` claims one of the `.tofu` files is Pascal
source. :-)
It may not be the most readable hardware description language, but it is
one of the easiest 55 page long manual to learn. :-)
one of the easiest 55 page long manuals to learn. :-)
For a small but non-trivial design, try implementing a
[Linear Feedback Shift Register](http://en.wikipedia.org/wiki/LFSR)
And for those who are still confused:
> <http://en.wikipedia.org/wiki/Edamame>
> <http://en.wikipedia.org/wiki/Tofu>
And for those who are still confused, see <http://en.wikipedia.org/wiki/Edamame>
and <http://en.wikipedia.org/wiki/Tofu>.
## Author's remarks:
@@ -64,7 +72,7 @@ The primary obfuscation is the data structure chosen for parsing the
input file and for executing the simulation. Oh man... coding that
data structure gave me such a bad headache. But, I figure, who needs
more than a pair anyway? Subtle obfuscations abound. Bonus points go
out the one who discovers the hidden program within the source.
out to the one who discovers the hidden program within the source.
Note that the shape of the source is a wave, not a waveform.
+68
View File
@@ -0,0 +1,68 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC winner 2006/birken
#
# 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: ./birken < adder.tofu 2>/dev/null: "
./birken < adder.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < buffer.tofu 2>/dev/null: "
./birken < buffer.tofu 2>/dev/null
echo 1>&2
echo "NOTE: the next one has longer output." 1>&2
read -r -n 1 -p "Press any key to run: ./birken < computer.tofu 2>/dev/null: "
./birken < computer.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < counter.tofu 2>/dev/null: "
./birken < counter.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < divider.tofu 2>/dev/null: "
./birken < divider.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < lfsr.tofu 2>/dev/null: "
./birken < lfsr.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < memory.tofu 2>/dev/null: "
./birken < memory.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < multiplier.tofu 2>/dev/null: "
./birken < multiplier.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < multiplier2.tofu 2>/dev/null: "
./birken < multiplier2.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < oneline.tofu 2>/dev/null: "
./birken < oneline.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < shift.tofu 2>/dev/null: "
./birken < shift.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < zuse.tofu 2>/dev/null: "
./birken < zuse.tofu 2>/dev/null
echo 1>&2
read -r -n 1 -p "Press any key to run: ./birken < zuse2.tofu 2>/dev/null: "
./birken < zuse2.tofu 2>/dev/null
+17
View File
@@ -2305,6 +2305,23 @@ used decimal mode, or any of the "undocumented" instructions.
# 2006
## 2006 birken
### STATUS: uses gets() - change to fgets() if possible
### Source code: [2006/birken/birken.c](2006/birken/birken.c)
### Information: [2006/birken/README.md](2006/birken/README.md)
This entry uses `gets(3)` which is unsafe and provides annoying warnings, most
obnoxious in macOS as it shows it at runtime (redirecting `stderr` to
`/dev/null` will silence it). The following diff will almost work but it crashes
with at least `computer.tofu` input file:
```diff
12a13
#define gets(c) fgets((c),PI,stdin)&&(((c)[strlen((c))-1]='\0'),c!=NULL)
```
## 2006 borsanyi
### STATUS: INABIAF - please **DO NOT** fix
+2
View File
@@ -2952,6 +2952,8 @@ it.
Cody fixed a segfault in macOS with this entry. The problem was a missing `+1`
for strlen() with malloc(). This prevented it from working.
Cody also added the [try.sh](2006/birken/try.sh) script.
## [2006/borsanyi](2006/borsanyi/borsanyi.c) ([README.md](2006/borsanyi/README.md]))