Updates to 1996/huffman - format + bugs + try.sh

The try.sh script runs the commands in the try section. It does not run
the spoiler command in the judges' remarks as that didn't feel like a
good idea.

The README.md has been typo and format checked.

Added to bugs.md to try and change to use fgets(3). In the meantime it
uses 2>/dev/null.
This commit is contained in:
Cody Boone Ferguson committed 2023-11-11 09:20:28 -08:00
1 parent 3ca67b08ff
commit 760e5ddd32
5 files changed
+75 -9

No files matched your search

+1 -1
View File
@@ -62,7 +62,7 @@ CDEFINE=
# Include files that are needed to compile
#
CINCLUDE=
CINCLUDE= -include stdio.h
# Optimization
#
+14 -8
View File
@@ -5,22 +5,28 @@ make all
```
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: uses gets() - change to fgets() if possible
```
For more detailed information see [1996 huffman in bugs.md](/bugs.md#1996-huffman).
## To use:
```sh
echo 'Huffman Decoding' | ./huffman
```
NOTE: this program uses `gets()` so you will likely get a warning when compiling
and/or running on modern systems.
### Try:
```sh
echo 'seeing or feeling is believing' | ./huffman
echo 'CC OR NOT CC' | ./huffman
echo 'CC OR NOT CC' | ./huffman | ./huffman
./try.sh
```
@@ -34,7 +40,7 @@ And for a misleading hint, consider who won! :-)
And if you really can't see what is going on, here is an extra spoiler:
```sh
./huffman < huffman.c
./huffman < huffman.c 2>/dev/null
```
This entry was very well received at the IOCCC BOF.
@@ -46,7 +52,7 @@ This filter program is really not obfuscated code. It compiles cleanly
with an ANSI C compiler and comes with user documentation that even a
blind person could read.
The program is a bidirectional filter with the output of the program\
The program is a bidirectional filter with the output of the program
suitable for its input. The output of this program, when used as input,
undoes the original program filtering.
+13
View File
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
make all >/dev/null || exit 1
echo "$ echo 'seeing or feeling is believing' | ./huffman" 1>&2
echo 'seeing or feeling is believing' | ./huffman 2>/dev/null
echo "$ echo 'CC OR NOT CC' | ./huffman" 1>&2
echo 'CC OR NOT CC' | ./huffman 2>/dev/null
echo "$ $ echo 'CC OR NOT CC' | ./huffman | ./huffman" 1>&2
echo 'CC OR NOT CC' | ./huffman 2>/dev/null | ./huffman 2>/dev/null
+41
View File
@@ -1382,6 +1382,47 @@ it was instead requiring a login / password.
Do you have an updated link? We welcome your help!
## 1996 huffman
### STATUS: uses gets() - change to fgets() if possible
### Source code: [1996/huffman/huffman.c](1996/huffman/huffman.c)
### Information: [1996/huffman/README.md](1996/huffman/README.md)
The changing to using `fgets(3)` in this entry is a bit more complicated. It can
almost be done except that some of the output of the
[try.sh](1996/huffman/try.sh) is wrong, especially the last one.
This diff almost does it but not quite:
```diff
diff --git i/1996/huffman/huffman.c w/1996/huffman/huffman.c
index a5745bc7f4fa28b834c004f4cf19633e40ad9165..5e5e5334f33f9dbd95c70eddece3189d9bcff5e9 100644
--- i/1996/huffman/huffman.c
+++ w/1996/huffman/huffman.c
@@ -1,15 +1,16 @@
#define x char
#define z else
#define w gets
+#define gets(b) ((b)[0]='\0',(fgets((b), 100, stdin)))
#define r if
#define u int
#define s main
#define v putchar
#define y while
#define t " A?B?K?L?CIF?MSP?E?H?O?R?DJG?NTQ?????U?V?????X???????Z????W??Y??"
- s ( ) { x* c , b[ 5 * 72 ]; u a, e , d [ 9
+ s ( ) { x* c , b[ 5 * 72 ]; u a, e , d [ 9
*9 *9 ] ; y (w ( b) ){ r ( 0 [ b] -7 *
5 ) { c = b ; y ( (* c - 6
* 7 )* * c )c = c+ 1 ; r (( -0 ) [ c ] && w ( b +
8 * 5* 3 ) && w (b +8 *5 * 6) )
{ a = 0; y ( a [ b ]
```
But since it does not for the time being it is advisable to just redirect stderr
to /dev/null (`2>/dev/null`).
## 1996 jonth
### STATUS: INABIAF - please **DO NOT** fix
+6
View File
@@ -1971,6 +1971,12 @@ either different output or the same output that we briefly pointed out.
BTW: it is perilous to try the patience of
[Gandalf](https://www.glyphweb.com/arda/g/gandalf.html). Go ahead, try it! :-)
## [1996/huffman](1996/huffman/huffman.c) ([README.md](1996/huffman/README.md]))
Cody added the [try.sh](1996/huffman/try.sh) script.
## [1996/jonth](1996/jonth/jonth.c) ([README.md](1996/jonth/README.md]))
Cody fixed this to not segfault under macOS. The problem was that the function