diff --git a/2006/birken/README.md b/2006/birken/README.md index 29cdf748d..8f1eb658d 100644 --- a/2006/birken/README.md +++ b/2006/birken/README.md @@ -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: - -> -> +And for those who are still confused, see +and . ## 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. diff --git a/2006/birken/try.sh b/2006/birken/try.sh new file mode 100755 index 000000000..f1b0e856b --- /dev/null +++ b/2006/birken/try.sh @@ -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 diff --git a/bugs.md b/bugs.md index 176016891..847724e9b 100644 --- a/bugs.md +++ b/bugs.md @@ -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 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 46661e7e4..d51fac310 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -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]))