Add 2015/mills2/try.sh, update bugs, formatting
The bugs.md has a INABIAF section for 2015/mills2. The README.md file has been format and typo checked.
This commit is contained in:
1 parent
267cbdfef3
commit
3adfc9a06a
4 files changed
+115
-31
No files matched your search
+38
-30
@@ -5,6 +5,17 @@ make
|
|||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
### Bugs and (Mis)features:
|
||||||
|
|
||||||
|
The current status of this entry is:
|
||||||
|
|
||||||
|
```
|
||||||
|
STATUS: INABIAF - please **DO NOT** fix
|
||||||
|
```
|
||||||
|
|
||||||
|
For more detailed information see [2015 mills2 in bugs.md](/bugs.md#2015-mills2).
|
||||||
|
|
||||||
|
|
||||||
## To use:
|
## To use:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -15,16 +26,7 @@ make
|
|||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
printf '000I\236\f\31H\260\240\301\203' > ioccc.Z
|
./try.sh
|
||||||
./prog ioccc.Z
|
|
||||||
|
|
||||||
dd bs=1k count=4096 < /dev/urandom > test1
|
|
||||||
compress < test1 > test1.Z
|
|
||||||
time ./prog test1.Z | cmp - test1
|
|
||||||
|
|
||||||
dd bs=1k count=4096 < /dev/zero > test2
|
|
||||||
compress < test2 > test2.Z
|
|
||||||
time ./prog test2.Z | cmp - test2
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@@ -32,11 +34,15 @@ time ./prog test2.Z | cmp - test2
|
|||||||
|
|
||||||
Without ASCII art, the source code of this entry would have been exactly 256
|
Without ASCII art, the source code of this entry would have been exactly 256
|
||||||
bytes. Compared to [1990/jaw](http://ioccc.org/years.html#1990_jaw), it is very
|
bytes. Compared to [1990/jaw](http://ioccc.org/years.html#1990_jaw), it is very
|
||||||
impressive, even taking into account the missing atob functionality. Now we wish
|
impressive, even taking into account the missing `atob` functionality. Now we wish
|
||||||
for a compress(1)-like compressor using a similar idea.
|
for a `compress(1)`-like compressor using a similar idea.
|
||||||
|
|
||||||
Why is the sad smiley on line 12 in that particular place?
|
Why is the sad smiley on line 12 in that particular place?
|
||||||
|
|
||||||
|
```c
|
||||||
|
c=0) :( O
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Author's remarks:
|
## Author's remarks:
|
||||||
|
|
||||||
@@ -46,16 +52,17 @@ This program is an implementation of the unix `zcat(1)` command for printing
|
|||||||
compressed files that have been created by the `compress(1)` command.
|
compressed files that have been created by the `compress(1)` command.
|
||||||
|
|
||||||
The adaptive [LZW](https://en.wikipedia.org/wiki/Lempel–Ziv–Welch) compression
|
The adaptive [LZW](https://en.wikipedia.org/wiki/Lempel–Ziv–Welch) compression
|
||||||
employed by `compress` usually requires a fairly large amount of memory to
|
employed by `compress(1)` usually requires a fairly large amount of memory to
|
||||||
build the decompression tables (in fact, `compress` has a command-line option
|
build the decompression tables (in fact, `compress(1)` has a command-line option
|
||||||
to control the size of the decompression tables, since some of the early
|
to control the size of the decompression tables, since some of the early systems
|
||||||
systems to which it was ported (*cough*MS-DOS*cough*) did not have enough
|
to which it was ported
|
||||||
memory to use the full 16-bit codes). This version has no large static or
|
(\*cough\*[MS-DOS](https://computerhistory.org/blog/microsoft-ms-dos-early-source-code/?key=microsoft-ms-dos-early-source-code)\*cough\*)
|
||||||
dynamic tables. It is able to decompress 16-bit files using a single function
|
did not have enough memory to use the full 16-bit codes). This version has no
|
||||||
and a few ints.
|
large static or dynamic tables. It is able to decompress 16-bit files using a
|
||||||
|
single function and a few `int`s.
|
||||||
|
|
||||||
To run the program, take an existing compressed file and pass it to the program
|
To run the program, take an existing compressed file and pass it to the program
|
||||||
on the command line. On the odd chance you don't have `compress` hanging about
|
on the command line. On the odd chance you don't have `compress(1)` hanging about
|
||||||
on your system, I've provided compressed copies of this year's IOCCC rules
|
on your system, I've provided compressed copies of this year's IOCCC rules
|
||||||
and guidelines files. To print them, just do
|
and guidelines files. To print them, just do
|
||||||
|
|
||||||
@@ -83,11 +90,11 @@ complicated by several issues:
|
|||||||
* Codes are at bit offsets within the stream, and must be extracted.
|
* Codes are at bit offsets within the stream, and must be extracted.
|
||||||
* As codes are added to the dictionary, the code word size grows, so finding
|
* As codes are added to the dictionary, the code word size grows, so finding
|
||||||
the offset to a particular code word is involved.
|
the offset to a particular code word is involved.
|
||||||
* The `compress` encoder reserves a code word that clears the coding tables.
|
* The `compress(1)` encoder reserves a code word that clears the coding tables.
|
||||||
When this is encountered, the computation of offsets and bit sizes reset.
|
When this is encountered, the computation of offsets and bit sizes reset.
|
||||||
* The `compress` decoder is designed to always read a block of eight code
|
* The `compress(1)` decoder is designed to always read a block of eight code
|
||||||
words at the same time, so that it need only read N bytes to get eight N-bit
|
words at the same time, so that it need only read `N` bytes to get eight
|
||||||
code words. When the "clear" code is encountered, the entire eight-word
|
`N-bit` code words. When the "clear" code is encountered, the entire eight-word
|
||||||
block is flushed (since the decoder didn't know the word size would change).
|
block is flushed (since the decoder didn't know the word size would change).
|
||||||
The program needs to account for this extra flushing.
|
The program needs to account for this extra flushing.
|
||||||
* The end of the stream is not explicitly marked; the encoder just pads out
|
* The end of the stream is not explicitly marked; the encoder just pads out
|
||||||
@@ -106,9 +113,9 @@ compressed data, it's likely to crash in an interesting manner.
|
|||||||
|
|
||||||
In particular, it doesn't look at the third byte of the header, which encodes
|
In particular, it doesn't look at the third byte of the header, which encodes
|
||||||
the maximum code word size and whether "block mode" was used when the encoder
|
the maximum code word size and whether "block mode" was used when the encoder
|
||||||
was run. If you use `compress` in its default mode, the maximum word size
|
was run. If you use `compress(1)` in its default mode, the maximum word size
|
||||||
will be 16 bits and "block mode" will be enabled. You are unlikely to find
|
will be 16 bits and "block mode" will be enabled. You are unlikely to find
|
||||||
any files that don't use "block mode", since all versions of `compress` after
|
any files that don't use "block mode", since all versions of `compress(1)` after
|
||||||
2.0 (circa 1984) use it by default and have no documented way to disable it.
|
2.0 (circa 1984) use it by default and have no documented way to disable it.
|
||||||
Reducing the bit depth is still possibly by using the `-b` flag. Modern
|
Reducing the bit depth is still possibly by using the `-b` flag. Modern
|
||||||
systems have no problem with the 200 KB or so needed for 16-bit decoder
|
systems have no problem with the 200 KB or so needed for 16-bit decoder
|
||||||
@@ -121,10 +128,11 @@ In the event that you don't supply an argument, or that argument doesn't name
|
|||||||
a readable file, the program will just silently exit. This is a feature.
|
a readable file, the program will just silently exit. This is a feature.
|
||||||
|
|
||||||
The program depends on having a little-endian system. On a big-endian system
|
The program depends on having a little-endian system. On a big-endian system
|
||||||
you will get a weird big-endian version of `compress`, which might have come to
|
you will get a weird big-endian version of `compress(1)`, which might have come
|
||||||
pass in an alternate universe where the vax on which `compress` was authored
|
to pass in an alternate universe where the
|
||||||
had been big-endian. Luckily for us, it wasn't, and neither are most of the
|
[VAX](https://en.wikipedia.org/wiki/VAX) on which `compress(1)` was authored had
|
||||||
systems you might want to compile this for.
|
been big-endian. Luckily for us, it wasn't, and neither are most of the systems
|
||||||
|
you might want to compile this for.
|
||||||
|
|
||||||
|
|
||||||
## Copyright and CC BY-SA 4.0 License:
|
## Copyright and CC BY-SA 4.0 License:
|
||||||
|
|||||||
Executable
+61
@@ -0,0 +1,61 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.sh - demonstrate IOCCC winner 2015/mills2
|
||||||
|
#
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
|
||||||
|
echo "$ printf '000I\236\f\31H\260\240\301\203' > ioccc.Z" 1>&2
|
||||||
|
printf '000I\236\f\31H\260\240\301\203' > ioccc.Z
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ ./prog ioccc.Z" 1>&2
|
||||||
|
./prog ioccc.Z
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ dd bs=512 count=128 < /dev/urandom > test1" 1>&2
|
||||||
|
dd bs=512 count=128 < /dev/urandom > test1
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ compress < test1 > test1.Z" 1>&2
|
||||||
|
compress < test1 > test1.Z
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ time ./prog test1.Z | cmp - test1" 1>&2
|
||||||
|
time ./prog test1.Z | cmp - test1
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ dd bs=512 count=128 < /dev/zero > test2" 1>&2
|
||||||
|
dd bs=512 count=128 < /dev/zero > test2
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ compress < test2 > test2.Z" 1>&2
|
||||||
|
compress < test2 > test2.Z
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
echo "$ time ./prog test2.Z | cmp - test2" 1>&2
|
||||||
|
time ./prog test2.Z | cmp - test2
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
|
||||||
|
echo "$ ./prog ioccc_guidelines.txt.Z" 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
./prog ioccc_guidelines.txt.Z | less -EXF
|
||||||
|
|
||||||
|
echo 1>&2
|
||||||
|
echo "$ ./prog ioccc_rules.txt.Z" 1>&2
|
||||||
|
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
|
||||||
|
echo 1>&2
|
||||||
|
./prog ioccc_rules.txt.Z | less -EXF
|
||||||
@@ -3059,7 +3059,17 @@ If you want to try and fix this (mis)feature, you are welcome to try.
|
|||||||
|
|
||||||
# 2015
|
# 2015
|
||||||
|
|
||||||
There are no known bugs and (Mis)features for entries in 2015.
|
|
||||||
|
## 2015 mills2
|
||||||
|
|
||||||
|
### STATUS: INABIAF - please **DO NOT** fix
|
||||||
|
### Source code: [2015/mills2/prog.c](2015/mills2/prog.c)
|
||||||
|
### Information: [2015/mills2/README.md](2015/mills2/README.md)
|
||||||
|
|
||||||
|
The program doesn't look at the header of files so if it's passed something hat
|
||||||
|
is not compressed data it's likely to crash.
|
||||||
|
|
||||||
|
The program depends on little endian systems.
|
||||||
|
|
||||||
|
|
||||||
# 2016
|
# 2016
|
||||||
|
|||||||
@@ -3813,6 +3813,11 @@ also involves good eye-hand coordination and playing games like this in the
|
|||||||
past).
|
past).
|
||||||
|
|
||||||
|
|
||||||
|
## [2015/mills2](2015/mills2/prog.c) ([README.md](2015/mills2/README.md))
|
||||||
|
|
||||||
|
[Cody](#cody) added the [try.sh](2015/mills2/try.sh) script.
|
||||||
|
|
||||||
|
|
||||||
## [2015/muth](2015/muth/prog.c) ([README.md](2015/muth/README.md))
|
## [2015/muth](2015/muth/prog.c) ([README.md](2015/muth/README.md))
|
||||||
|
|
||||||
[Cody](#cody) added the [try.sh](2015/muth/try.sh) script.
|
[Cody](#cody) added the [try.sh](2015/muth/try.sh) script.
|
||||||
|
|||||||
Reference in new issue
Block a user