Add 2019/diels-grabsch1/try.sh + other fixes
Add Shakespeare.txt from 2019/mills. This was used in the try commands (now try.sh) by doing cd ../mills ; make ; cd ../diels-grabsch1 but this is problematic because it requires that one has the same directory structure. Even more than that there's talk about having a tarball with each entry by itself so the text file has to be in this entry's directory too. The prog.c was reverted back to the original source code and the Makefile updated to have a -Wno- option. Originally the idea was to make the author's remarks true that even -Weverything of clang shows no warnings (which certainly did at the time) be true. I had the thought that it would be nice to keep CSILENCE empty. But this was bordering on going too far and more recent versions of clang have yet another dubious warning and it seems that that warning one cannot even prevent (but doing so here would obviously not be okay) so if that is silenced it would mean that CSILENCE is no longer empty anyway. This way is better anyway as the code is now the same. Of course the statement by the author that a certain paragraph in README.md is the same shape and size as prog.c is no longer true but that can't be helped. Format/typo check README.md file.
This commit is contained in:
1 parent
70b085933c
commit
4fc1683dc0
6 files changed
+40065
-19
No files matched your search
@@ -38,7 +38,7 @@ include ../../var.mk
|
||||
|
||||
# Common C compiler warnings to silence
|
||||
#
|
||||
CSILENCE=
|
||||
CSILENCE= -Wno-strict-prototypes
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
|
||||
@@ -15,15 +15,7 @@ make
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
dd bs=1024 count=2048 < /dev/zero | compress > ref.Z
|
||||
dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z
|
||||
cmp ref.Z dg1.Z
|
||||
|
||||
cd ../mills ; make ; cd ../diels-grabsch1
|
||||
compress < ../mills/Shakespeare.txt > ref.Z
|
||||
./prog < ../mills/Shakespeare.txt > dg1.Z
|
||||
cmp ref.Z dg1.Z # Oops, the files differ
|
||||
zcat < dg1.Z | cmp - ../mills/Shakespeare.txt # Decompresses correctly. What is going on?
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -34,9 +26,9 @@ to qualify for the Best Short Program award! That said, can you compress it down
|
||||
to a one-liner, still producing files in the UNIX compress format, albeit
|
||||
sacrificing the compression ratio?
|
||||
|
||||
Can you explain why the zero file compresses identically by the entry and the
|
||||
standard compress tool, but the text file compresses differently? The judges
|
||||
know. :)
|
||||
Can you explain why the `/dev/zero` file compresses identically by the entry and
|
||||
the standard `compress(1)` tool (see [try.sh](try.sh)), but the text file
|
||||
compresses differently? The judges know. :)
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
@@ -64,12 +56,15 @@ diff -s guidelines.txt guidelines2.txt
|
||||
|
||||
Of course you can also use [2015/mills2](/2015/mills2/mills2.c) instead of
|
||||
`zcat` to verify the output file. The achieved compression ratio roughly matches
|
||||
that of the classic Unix compress tool. And the source code is very
|
||||
that of the classic Unix `compress(1)` tool. And the source code is very
|
||||
compressed, too: It has exactly the same size as the paragraph you are reading
|
||||
right now. And exactly the same shape. Nevertheless, it is portable C99 code
|
||||
that runs on 32-bit and 64-bit platforms. It compiles without warnings on both
|
||||
GCC and Clang even with `-Wextra and -Weverything`.
|
||||
|
||||
> 2023 note: the above paragraph might not be true as far as number of bytes
|
||||
goes.
|
||||
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
||||
#include<stdio.h>
|
||||
int main(void){int a=0,b=a;long long c[178819],d=8,e=257,f,g,
|
||||
int main(){int a=0,b=a;long long c[178819],d=8,e=257,f,g,
|
||||
h,i=d-9;for(;a<178819;){c[a++]=i;}for(a*=53;a;a>>=8)putc\
|
||||
har(a);if((f=getchar())<0)return 0;for(;(g=getchar())>=0;
|
||||
){h=i=g<<8^f;g+=f<<8;a=e<(512<<a%8|(a<7))||f>256?a:a>6?15
|
||||
|
||||
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# try.sh - demonstrate IOCCC winner 2019/diels-grabsch1
|
||||
#
|
||||
|
||||
# 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 "$ dd bs=1024 count=2048 < /dev/zero | compress > ref.Z" 1>&2
|
||||
dd bs=1024 count=2048 < /dev/zero | compress > ref.Z
|
||||
echo 1>&2
|
||||
|
||||
echo "$ dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z" 1>&2
|
||||
dd bs=1024 count=2048 < /dev/zero | ./prog > dg1.Z
|
||||
echo 1>&2
|
||||
|
||||
echo "$ cmp ref.Z dg1.Z" 1>&2
|
||||
cmp ref.Z dg1.Z
|
||||
echo "Exit code of: cmp ref.Z dg1.Z: $?" 1>&2
|
||||
echo 1>&2
|
||||
|
||||
echo "$ compress < Shakespeare.txt > ref.Z" 1>&2
|
||||
compress < Shakespeare.txt > ref.Z
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./prog < Shakespeare.txt > dg1.Z" 1>&2
|
||||
./prog < Shakespeare.txt > dg1.Z
|
||||
echo 1>&2
|
||||
|
||||
echo "Notice how the files differ:" 1>&2
|
||||
echo "$ cmp ref.Z dg1.Z" 1>&2
|
||||
cmp ref.Z dg1.Z # Oops, the files differ
|
||||
echo "Exit code of: cmp ref.Z dg1.Z: $?" 1>&2
|
||||
echo 1>&2
|
||||
|
||||
echo "... and notice how this works fine:" 1>&2
|
||||
echo "$ zcat < dg1.Z | cmp - Shakespeare.txt" 1>&2
|
||||
zcat < dg1.Z | cmp - Shakespeare.txt
|
||||
echo "What happened?"
|
||||
+7
-4
@@ -4143,10 +4143,13 @@ bugs.md](/bugs.md#2019-ciura) for more details.
|
||||
|
||||
## <a name="2019_diels-grabsch1"></a>[2019/diels-grabsch1](/2019/diels-grabsch1/prog.c) ([README.md](/2019/diels-grabsch1/README.md]))
|
||||
|
||||
[Cody](#cody) made the author's statement that the entry compiles cleanly true by fixing
|
||||
`warning: a function declaration without a prototype is deprecated in all
|
||||
versions of C ` (in main()). Not strictly necessary but if he's making fixes he
|
||||
might as well.
|
||||
[Cody](#cody) added the [try.sh](/2019/diels-grabsch1/try.sh) script.
|
||||
|
||||
Cody also added the file [Shakespeare.txt](/2019/diels-grabsch1/Shakespeare.txt)
|
||||
from [2019/mills](/2019/mills/README.md) (after running `make`) so that one can
|
||||
not worry about having the entire winner tree (or at least the 2019 tree each
|
||||
winner in a subdirectory). This is more important as there is discussion of
|
||||
having tarballs for each individual entry as a convenience.
|
||||
|
||||
|
||||
## <a name="2019_diels-grabsch2"></a>[2019/diels-grabsch2](/2019/diels-grabsch2/prog.c) ([README.md](/2019/diels-grabsch2/README.md]))
|
||||
|
||||
Reference in new issue
Block a user