Move 199[1-3]/ant and 2015/howe alt code

The unobfuscated code, which was put in deobfuscated/, has been turned
into alt code. In one case the already existing alt code was made alt2
and the unobfuscated code was alt. In the case of the ones with two C
files there, the one that did not require modification (to compile in
modern systems) were used as those are original.

In a few cases these changes suggested additional files: a test suite
Makefile for the alt code, a try.alt.sh script and maybe some other
things besides.

The bug status was updated for 2015/howe with a known bug: in particular
the test scripts do not work (at least not completely).

In the manifest all references (except for a file name that has not been
renamed - at least not yet) of 'deobfuscated' to 'unobfuscated': a minor
detail that might not matter much but it sounds ever so slightly better
(maybe). These other entries that had an entry_text change were
1995/garry and 2020/endoh2. Rebuilt .entry.json and index.html files for
this (and in the case of the moved code the index.html files also had to
be changed for that in addition to the Makefiles).
This commit is contained in:
Cody Boone Ferguson committed 2024-07-07 09:53:56 -07:00
1 parent c9ca6b4150
commit 92139c55d7
53 files changed
+993 -1740

No files matched your search

+20 -12
View File
@@ -65,6 +65,22 @@
"display_via_github" : true,
"entry_text" : "script to run test suite"
},
{
"file_path" : "prog.alt-test.sh",
"inventory_order" : 100,
"OK_to_edit" : true,
"display_as" : "shellscript",
"display_via_github" : true,
"entry_text" : "script to run test suite with alternate code"
},
{
"file_path" : "try.alt.sh",
"inventory_order" : 100,
"OK_to_edit" : true,
"display_as" : "shellscript",
"display_via_github" : true,
"entry_text" : "script to try alternate code"
},
{
"file_path" : "try.sh",
"inventory_order" : 100,
@@ -82,28 +98,20 @@
"entry_text" : "cc man page"
},
{
"file_path" : "deobfuscated/Makefile",
"inventory_order" : 200,
"OK_to_edit" : true,
"display_as" : "makefile",
"display_via_github" : true,
"entry_text" : "deobfuscated Makefile"
},
{
"file_path" : "deobfuscated/err.h",
"file_path" : "err.h",
"inventory_order" : 210,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "deobfuscated err.h header file"
"entry_text" : "unobfuscated err.h header file"
},
{
"file_path" : "deobfuscated/prog.c",
"file_path" : "prog.alt2.c",
"inventory_order" : 210,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "deobfuscated source code"
"entry_text" : "unobfuscated source code"
},
{
"file_path" : "war-and-peace.txt",
+1
View File
@@ -8,5 +8,6 @@ indent.o
makeholes
prog
prog.alt
prog.alt2
prog.orig
war-and-peace.txt
+10 -3
View File
@@ -112,11 +112,11 @@ PROG= prog
#
OBJ= ${PROG}.o
CSRC= ${PROG}.o
DATA= deobfuscated/Makefile deobfuscated/err.h deobfuscated/prog.c
DATA=
TARGET= ${PROG}
#
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
ALT_OBJ= ${PROG}.alt.o ${PROG}.alt2.o
ALT_TARGET= ${PROG}.alt ${PROG}.alt2
#################
@@ -148,6 +148,13 @@ alt: data ${ALT_TARGET}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
${PROG}.alt2: ${PROG}.alt2.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
# Test suite for alt code
test.alt: makeholes prog.alt-test.sh ${TARGET}
${SHELL} ./prog.alt-test.sh
# data files
#
data: ${DATA}
+30 -7
View File
@@ -4,8 +4,20 @@
make
```
There is an alternate version provided. See [Alternate code](#alternate-code)
below.
There are two alternate versions provided by the author. See [Alternate
code](#alternate-code) and the author's remarks below for more details.
### Bugs and (Mis)features:
The current status of this entry is:
```
STATUS: known bug - please help us fix
```
For more detailed information see [2015/howe in bugs.html](../../bugs.html#2015_howe).
## To use:
@@ -27,11 +39,15 @@ below.
## Alternate code:
This alternate version does not use a 64-bit FNV hash. This was the original
entry but was changed to be the alt version.
entry but was changed to be the alt version. Later, in 2024, the author provided
an unobfuscated version which is in
[prog.alt2.c](%%REPO_URL%%/2015/howe/prog.alt2.c).
### Alternate build:
To build these versions:
``` <!---sh-->
make alt
```
@@ -39,7 +55,14 @@ entry but was changed to be the alt version.
### Alternate use:
Use `prog.alt` as you would `prog` above.
Use `prog.alt` and/or `prog.alt2` as you would `prog` above.
### Alternate try:
``` <!---sh-->
./try.alt.sh
```
## Judges' remarks:
@@ -55,9 +78,9 @@ Is this code a bug or a feature? :-) Or is this an attempt to corrupt the
programming of our youth? Should we heed Kyle's mom words that she uttered
during a South Park P.T.A. Meeting?
"We must stop dirty (C) language from getting to our children's ears!"
[Blame Canada](https://www.youtube.com/watch?v=bOR38552MJA)
> "We must stop dirty (C) language from getting to our children's ears!"
>
> [Blame Canada](https://www.youtube.com/watch?v=bOR38552MJA)
Or should we teach our youth to understand the intricacies of this code?
Ying Tong Iddle I Po! We suggest you read the source for yourself, which
-69
View File
@@ -1,69 +0,0 @@
.POSIX :
.SUFFIXES :
A = .a
O = .o
.SUFFIXES : .c .h .i $O $A
########################################################################
### No further configuration beyond this point.
########################################################################
top_srcdir := ..
CC := gcc
CFLAGS := -g -O2 -std=c99 -Wall -pedantic -Wno-char-subscripts
LDFLAGS :=
# Assume a POSIX compliant shell.
#
# On Linux
# /bin/sh = /bin/bash
#
# On NetBSD
# /bin/ksh
# /usr/pkg/bin/bash
#
# On OpenBSD
# /bin/ksh = /bin/pdksh
#
SHELL := /bin/ksh
W64CC := i686-w64-mingw32-gcc
W64CFLAGS := -I. -Os -s -std=c99 -Wno-char-subscripts
ZIP := README.txt prog-w64.exe prog-test.sh avgtime.sh makeholes-w64.exe
.c$O :
${CC} ${CFLAGS} -c $<
.c$E :
$(CC) $(CFLAGS) $(LDFLAGS) -o$* $<
$O :
$(LD) $(LDFLAGS) -o$* $*$O
.c.i:
${CC} -E ${CFLAGS} $*.c >$*.i
########################################################################
all: build
build: prog
clean:
-rm prog *.exe *.i *$O *.tmp *.rej *.orig *.core *.out 2>/dev/null
distclean: clean
prog: prog.c
${CC} ${CFLAGS} ${LDFLAGS} -o$@ prog.c
prog-w64: err.h prog.c
${W64CC} ${W64CFLAGS} ${LDFLAGS} -o$@ prog.c
test:
${SHELL} ${top_srcdir}/prog-test.sh
test-w64:
${SHELL} ${top_srcdir}/prog-test.sh -w
File renamed without changes.
+19 -7
View File
@@ -403,8 +403,12 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
<!-- BEFORE: 1st line of markdown file: 2015/howe/README.md -->
<h2 id="to-build">To build:</h2>
<pre><code> make</code></pre>
<p>There is an alternate version provided. See <a href="#alternate-code">Alternate code</a>
below.</p>
<p>There are two alternate versions provided by the author. See <a href="#alternate-code">Alternate
code</a> and the author’s remarks below for more details.</p>
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
<p>The current status of this entry is:</p>
<pre><code> STATUS: known bug - please help us fix</code></pre>
<p>For more detailed information see <a href="../../bugs.html#2015_howe">2015/howe in bugs.html</a>.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./prog file1 file2
@@ -413,11 +417,16 @@ below.</p>
<pre><code> ./try.sh</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>This alternate version does not use a 64-bit FNV hash. This was the original
entry but was changed to be the alt version.</p>
entry but was changed to be the alt version. Later, in 2024, the author provided
an unobfuscated version which is in
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/prog.alt2.c">prog.alt2.c</a>.</p>
<h3 id="alternate-build">Alternate build:</h3>
<p>To build these versions:</p>
<pre><code> make alt</code></pre>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>prog.alt</code> as you would <code>prog</code> above.</p>
<p>Use <code>prog.alt</code> and/or <code>prog.alt2</code> as you would <code>prog</code> above.</p>
<h3 id="alternate-try">Alternate try:</h3>
<pre><code> ./try.alt.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>This is the best use of the FNV that we have seen in the IOCCC so far!
The output, when used without <code>-d</code>, is compatible with POSIX <code>diff(1)</code> and
@@ -427,8 +436,10 @@ entries have been submitted.</p>
<p>Is this code a bug or a feature? :-) Or is this an attempt to corrupt the
programming of our youth? Should we heed Kyle’s mom words that she uttered
during a South Park P.T.A. Meeting?</p>
<blockquote>
<p>“We must stop dirty (C) language from getting to our children’s ears!”</p>
<p><a href="https://www.youtube.com/watch?v=bOR38552MJA">Blame Canada</a></p>
</blockquote>
<p>Or should we teach our youth to understand the intricacies of this code?
Ying Tong Iddle I Po! We suggest you read the source for yourself, which
might be easier than the academic papers it was inspired by.</p>
@@ -521,12 +532,13 @@ Comm. of ACM, Vol. 18, June 1975, pages 341-343<br>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/prog.orig.c">prog.orig.c</a> - original source code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/avgtime.sh">avgtime.sh</a> - support script</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/makeholes.c">makeholes.c</a> - C code to add random holes to a file</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/prog.alt-test.sh">prog.alt-test.sh</a> - script to run test suite with alternate code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/prog-test.sh">prog-test.sh</a> - script to run test suite</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/try.alt.sh">try.alt.sh</a> - script to try alternate code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/try.sh">try.sh</a> - script to try entry</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/cc.1">cc.1</a> - cc man page</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/deobfuscated/Makefile">deobfuscated/Makefile</a> - deobfuscated Makefile</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/deobfuscated/err.h">deobfuscated/err.h</a> - deobfuscated err.h header file</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/deobfuscated/prog.c">deobfuscated/prog.c</a> - deobfuscated source code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/err.h">err.h</a> - unobfuscated err.h header file</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/prog.alt2.c">prog.alt2.c</a> - unobfuscated source code</li>
<li><a href="war-and-peace.txt">war-and-peace.txt</a> - War and Peace translated to English</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
+1
View File
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
# Assume a POSIX compliant shell.
make all || exit 1
PROG="./prog"
args=$(getopt 'f:w' "$@")
+137
View File
@@ -0,0 +1,137 @@
#!/usr/bin/env bash
# Assume a POSIX compliant shell.
make alt || exit 1
PROG="./prog.alt"
args=$(getopt 'f:w' "$@")
status="$?"
if [[ $status -ne 0 ]]; then
echo "usage: prog.alt-test.sh [-w][-f flags]"
exit 2
fi
set -- "$args"
while [[ $# -gt 0 ]]; do
case "$1" in
-w)
PROG="./prog-w64"
;;
-f)
flags=$2; shift
;;
--)
shift; break
;;
*)
;;
esac
shift
done
function distance
{
typeset A="$1"; shift
typeset B="$1"; shift
typeset expect="$1"; shift
printf "%s" "$A" | sed -e 's/./&\
/g' >"$A.tmp"
printf "%s" "$B" | sed -e 's/./&\
/g' >"$B.tmp"
echo "<<< A='$A' B='$B' $*"
typeset dist
dist=$("$PROG" -d "$@" "$A.tmp" "$B.tmp" | tr -d '\r')
printf '>>> got=%d expect=%d ' "$dist" "$expect"
if [[ "$dist" -ne "$expect" ]]; then
echo FAIL
return 1
fi
echo -OK-
return 0
}
function dif
{
typeset A="$1"; shift
typeset B="$1"; shift
typeset expect="$1"; shift
echo "==== $A $B"
"$PROG" "$A" "$B" | tee patch.tmp
typeset ex=$?
if [[ "$expect" -eq 0 ]]; then
printf "got=%d expect=%d " "$ex" "$expect"
if [[ $expect -ne $ex ]]; then
echo FAIL
return 1
fi
echo -OK-
return 0
fi
printf "forward patch "
cp "$A" copy.tmp
if ! patch -f -s copy.tmp patch.tmp ; then
echo FAIL
return 1
fi
echo -OK-
printf "forward compare "
if ! cmp "$B" copy.tmp ; then
echo FAIL
return 1
fi
echo -OK-
printf "reverse patch "
if ! patch -R -f -s copy.tmp patch.tmp ; then
echo FAIL
return 1
fi
echo -OK-
printf "reverse compare "
if ! cmp "$A" copy.tmp ; then
echo FAIL
return 1
fi
echo -OK-
return 0
}
distance "1" "1" 0 "$flags"
distance "1" "A" 2 "$flags"
distance "123" "ABCDE" 8 "$flags"
distance "ABCDE" "123" 8 "$flags"
distance "ABD" "ABCD" 1 "$flags"
distance "ABCD" "ABD" 1 "$flags"
distance "ABCD" "ACDBECFD" 4 "$flags"
distance "ABCDEF" "ABXYEFCD" 6 "$flags"
distance "ABCDEFGHIJK" "ABCEFGIJKDEFGHIJK" 6 "$flags"
distance "ABCABBA" "CBABAC" 5 "$flags"
distance "ACEBDABBABED" "ACBDEACBED" 6 "$flags"
touch EMPTY.tmp
dif 1.tmp 1.tmp 0
dif EMPTY.tmp 123.tmp 1
dif 123.tmp EMPTY.tmp 1
dif ABCD.tmp ACDBECFD.tmp 1
dif ACDBECFD.tmp ABCD.tmp 1
dif 123.tmp ABCDE.tmp 1
dif ABCDE.tmp 123.tmp 1
# Note that prog and diff(1) have same edit distance,
# but differ in the output.
dif CBABAC.tmp ABCABBA.tmp 1
dif ABCABBA.tmp CBABAC.tmp 1
rm copy.tmp* 2>/dev/null
echo DONE
File renamed without changes.
+95
View File
@@ -0,0 +1,95 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC entry 2015/howe alt code
#
# 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" alt >/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: ./prog.alt prog.alt.c prog.c: "
echo 1>&2
./prog.alt prog.alt.c prog.c
echo 1>&2
read -r -n 1 -p "Press any key to run: make test (space = next page, q = quit): "
echo 1>&2
make test | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: ./prog.alt -d ABXYEFCD.tmp ACDBECFD.tmp: "
echo 1>&2
./prog.alt -d ABXYEFCD.tmp ACDBECFD.tmp
echo 1>&2
read -r -n 1 -p "Press any key to run: ./prog.alt ABXYEFCD.tmp ACDBECFD.tmp: "
echo 1>&2
./prog.alt ABXYEFCD.tmp ACDBECFD.tmp
echo 1>&2
rm -f curds.tmp whey.tmp
read -r -n 1 -p "Press any key to run: cp -vf cc.1 curds.tmp: "
echo 1>&2
cp -vf cc.1 curds.tmp
echo 1>&2
read -r -n 1 -p "Press any key to run: cp -vf cc.1 whey.tmp: "
echo 1>&2
cp -vf cc.1 whey.tmp
read -r -n 1 -p "Press any key to run: chmod -v 666 whey.tmp: "
echo 1>&2
chmod -v 666 whey.tmp
echo 1>&2
if [[ ! -x makeholes ]]; then
read -r -n 1 -p "Press any key to run: make makeholes: "
echo 1>&2
make makeholes
echo 1>&2
fi
read -r -n 1 -p "Press any key to run: ./makeholes -n 1000 whey.tmp: "
echo 1>&2
./makeholes -n 1000 whey.tmp
echo 1>&2
read -r -n 1 -p "Press any key to run: ./prog.alt curds.tmp whey.tmp (space = next page, q = quit): "
echo 1>&2
./prog.alt curds.tmp whey.tmp | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: ./avgtime.sh 100 ./prog.alt curds.tmp whey.tmp: "
echo 1>&2
./avgtime.sh 100 ./prog.alt curds.tmp whey.tmp
echo 1>&2
read -r -n 1 -p "Press any key to run: cp -vf war-and-peace.txt nuked.tmp: "
echo 1>&2
cp -vf war-and-peace.txt nuked.tmp
echo 1>&2
read -r -n 1 -p "Press any key to run: ./makeholes -c'~' -n 1000 nuked.tmp: "
echo 1>&2
./makeholes -c'~' -n 1000 nuked.tmp
echo 1>&2
echo "$ ./prog.alt war-and-peace.txt nuked.tmp" 1>&2
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./prog.alt war-and-peace.txt nuked.tmp | less -rEXFK
echo 1>&2
echo "$ ./avgtime.sh 100 ./prog.alt war-and-peace.txt nuked.tmp" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./avgtime.sh 100 ./prog.alt war-and-peace.txt nuked.tmp
echo 1>&2
+4 -2
View File
@@ -82,12 +82,14 @@ echo 1>&2
./makeholes -c'~' -n 1000 nuked.tmp
echo 1>&2
read -r -n 1 -p "Press any key to run: ./prog war-and-peace.txt nuked.tmp (space = next page, q = quit): "
echo "$ ./prog war-and-peace.txt nuked.tmp" 1>&2
read -r -n 1 -p "Press any key to continue (space = next page, q = quit): "
echo 1>&2
./prog war-and-peace.txt nuked.tmp | less -rEXFK
echo 1>&2
read -r -n 1 -p "Press any key to run: ./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp: "
echo "$ ./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./avgtime.sh 100 ./prog war-and-peace.txt nuked.tmp
echo 1>&2