diff --git a/1996/huffman/Makefile b/1996/huffman/Makefile index 5e22ec87d..4ae91bdc9 100644 --- a/1996/huffman/Makefile +++ b/1996/huffman/Makefile @@ -62,7 +62,7 @@ CDEFINE= # Include files that are needed to compile # -CINCLUDE= +CINCLUDE= -include stdio.h # Optimization # diff --git a/1996/huffman/README.md b/1996/huffman/README.md index 63d12eefe..7ebcce892 100644 --- a/1996/huffman/README.md +++ b/1996/huffman/README.md @@ -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. diff --git a/1996/huffman/try.sh b/1996/huffman/try.sh new file mode 100755 index 000000000..4af978da4 --- /dev/null +++ b/1996/huffman/try.sh @@ -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 diff --git a/bugs.md b/bugs.md index 25f2c4905..f8b8a46f2 100644 --- a/bugs.md +++ b/bugs.md @@ -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 diff --git a/thanks-for-fixes.md b/thanks-for-fixes.md index 421fc6a3e..0edfe2945 100644 --- a/thanks-for-fixes.md +++ b/thanks-for-fixes.md @@ -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