Add deobfuscated versions of 199[1-3]/ant

Anthony/@SirWumpus kindly provided these files. The source code and
their Makefiles are in a deobfuscated/ subdirectory (for each of the
three entries) but running make alt
from the entry directory works. It uses the deobfuscated version's
Makefile but copies the compiled binary to the entry's directory to keep
things clean (deobfuscated code separate from the entry) to simplify
using the deobfuscated versions.

Entries that had a test suite Makefile have a new one for the
deobfuscated code and a try.alt.sh script was added to 1992/ant and
1993/ant but the entry_text is a bit different than the usual to
indicate that it's the deobfuscated version.

It might be that the way this is done should be reorganised some but
that can be decided on later.

The entries from 2004 and 2005 have not yet been added because some
decisions have to be made as those are the ones with a configure script.

The manifest was updated and the .entry.json and index.html files were
updated. It is not clear yet if the inventory_order is right but that
will be looked at in the next day or two.

Thank you Anthony!
This commit is contained in:
Cody Boone Ferguson committed 2024-07-05 12:53:32 -07:00
1 parent 95efa5ada6
commit a4fb0a8c8c
39 files changed
+3174 -48

No files matched your search

+40
View File
@@ -41,6 +41,22 @@
"display_via_github" : true,
"entry_text" : "script to try entry"
},
{
"file_path" : "deobfuscated/ant.c",
"inventory_order" : 140,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "author provided deobfuscated code"
},
{
"file_path" : "deobfuscated/sleep.c",
"inventory_order" : 140,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "author provided code for those who need a nap"
},
{
"file_path" : "ant.README.txt",
"inventory_order" : 150,
@@ -57,6 +73,30 @@
"display_via_github" : true,
"entry_text" : "Makefile to demonstrate entry"
},
{
"file_path" : "deobfuscated/Makefile",
"inventory_order" : 150,
"OK_to_edit" : true,
"display_as" : "makefile",
"display_via_github" : true,
"entry_text" : "author provided Makefile for deobfuscated code"
},
{
"file_path" : "try.alt.sh",
"inventory_order" : 150,
"OK_to_edit" : true,
"display_as" : "shellscript",
"display_via_github" : true,
"entry_text" : "script to try deobfuscated code"
},
{
"file_path" : "ant.test.alt.mk",
"inventory_order" : 160,
"OK_to_edit" : true,
"display_as" : "makefile",
"display_via_github" : true,
"entry_text" : "Makefile to demonstrate deobfuscated code"
},
{
"file_path" : "1992_ant.tar.bz2",
"inventory_order" : 1415926535,
+3
View File
@@ -2,8 +2,11 @@
# sort with: ../../bin/sgi.sh
*.dSYM
am
am.alt
am.safe
am.safe.alt
ant
ant.alt
ant.orig
indent
indent.c
+33 -6
View File
@@ -117,8 +117,8 @@ OBJ= ${PROG}.o
DATA=
TARGET= ${PROG}
#
ALT_OBJ=
ALT_TARGET=
ALT_OBJ= deobfuscated/${PROG}.o
ALT_TARGET= deobfuscated/${PROG}
#################
@@ -146,9 +146,33 @@ am: ant
# alternative executable
#
alt: data ${ALT_TARGET}
alt: data ${PROG}.alt
@${TRUE}
# We keep the alternate code, the deobfuscated code, and its Makefile, in the
# deobfuscated directory but copy the compiled binaries to the entry directory,
# to keep both directories clean, separating the two. The reason we copy the
# binary to the entry directory is so one does not have to do:
#
# ./deobfuscated/ant
#
# but instead just:
#
# ./ant.alt
#
# while still using the Makefile provided with the deobfuscated code.
#
${PROG}.alt: deobfuscated/ant.c
${MAKE} -C deobfuscated ant
${CP} -v -f deobfuscated/ant ant.alt
am.alt: ant.alt
rm -f am.alt
ln deobfuscated/ant am.alt
cp am.alt am.safe.alt
cp am.safe.alt am.alt
rm -f am.safe.alt
# data files
#
data: ${DATA}
@@ -156,7 +180,7 @@ data: ${DATA}
# both all and alt
#
everything: all alt
everything: all alt am am.alt
@${TRUE}
@@ -216,7 +240,8 @@ clean:
clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET}
${RM} -rf *.dSYM
${RM} -f am am.safe
${RM} -f am am.safe am.alt am.safe.alt deobfuscated/ant ${PROG}.alt
${RM} -f node.* leaf.*
@-if [ -e sandwich ]; then \
${RM} -f sandwich; \
echo 'ate sandwich'; \
@@ -229,10 +254,12 @@ am_clean:
${RM} -f indent.c; \
fi
am_clobber: am_clean
rm -f am.safe
am_alt_clobber:
rm -f am.safe.alt
install:
@echo "Dr. Spock says that is not logical!"
@${TRUE}
+29
View File
@@ -5,6 +5,10 @@
```
The author provided us with an unobfuscated version. See [Alternate
code](#alternate-code) below.
## To use:
``` <!---sh-->
@@ -23,6 +27,31 @@ where `Makefile` is a Makefile to use and `rule` is an optional rule to use.
```
## Alternate code:
This version, [ant.c in deobfuscated/](%%REPO_URL%%/1992/ant/deobfuscated/ant.c), was provided by the
author in 2024, and is a deobfuscated version.
## Alternate build:
``` <!---sh-->
make alt
```
## Alternate use:
Use `ant.alt` as you would `ant` above.
## Try:
``` <!---sh-->
./try.alt.sh
```
## Judges' remarks:
Like much of POSIX, obfuscation has its place. Your task is to
+196
View File
@@ -0,0 +1,196 @@
#
# Test makefile for AM
#
#
# Allow for empty macros.
#
EMPTY=
#
# Allow for white space in macro assignment.
#
TEXT_1=no white space
TEXT_2 =left hand side
TEXT_3= right hand side
TEXT_4 = both sides
TEXT_5 = tabs boths sides
#
# Test pseudo targets.
#
all : print_macros repeat redefine many flags multiple split errors done
print_macros : empty t1 t2 t3 t4 t5 t.all
#
# Targets with no dependencies.
#
empty :
echo EMPTY='$(EMPTY)'
t1 :
echo TEXT_1='$(TEXT_1)'
t2 :
echo TEXT_2='$(TEXT_2)'
t3 :
echo TEXT_3='$(TEXT_3)'
t4 :
echo TEXT_4='$(TEXT_4)'
t5 :
echo TEXT_5='$(TEXT_5)'
t.all :
echo $(TEXT_1) $(TEXT_2) $(TEXT_3) $(TEXT_4) $(TEXT_5)
#
# Test redefinition of macros. AM allows redefinition and
# evaluates macros immediately.
#
TEXT_1 =text number 1
TEXT_2 = test macro split \
across lines \
three lines
TEXT_3 = test dollar macro '$$'
TEXT_4 = test dollar again "$$(TEXT_1)"
TEXT_5 = embedded macro '$(TEXT_1)'
redefine : r1 r2 r3 r4 r5
r1 :
echo TEXT_1='$(TEXT_1)'
r2 :
echo TEXT_2='$(TEXT_2)'
r3 :
echo TEXT_3='$(TEXT_3)'
r4 :
echo TEXT_4='$(TEXT_4)'
r5 :
echo TEXT_5='$(TEXT_5)'
#
# Try to update a prerequisite more than once. Subsequent occurrences
# should be ignored once a prerequisite has been updated.
#
repeat: t1 repeat.a t3
repeat.a : t2 t1
#
# Target with multi-line recipe.
#
many : leaf.1 leaf.2
echo Execute receipe with multiple commands.
ls -1 leaf.*
echo Last line of receipe for target 'many'.
leaf.1 :
touch leaf.1
leaf.2 :
touch leaf.2
#
# Test recipe line flags.
#
flags : silence ignore always combination
# Command not displayed before execution.
silence :
echo You should not see the 'ls' command printed.
@ls leaf.*
# Ignore errors from command.
ignore :
echo The 'ls' command should fail but not terminate AM.
-ls unknown
# This flag is ignored by AM since we don't support a silence option (-n).
always :
+echo The '+' flag is accepted and ignored.
combination:
-@echo The next displayed line should not be 'ls unknown'
@-ls unknown
@+-echo Combined flags test completed.
#
# Multiple targets.
#
multiple : node.2 node.5
node.1 node.2 node.3 : leaf.1 leaf.2
touch node.1 node.2 node.3
node.4 node.5 : node.2 leaf.3
touch node.4 node.5
leaf.3 :
touch leaf.3
#
# Test split lines.
#
split : node.6 leaf.4 split.cmd
echo Completed split line tests.
# Target dependencies split across lines.
node.6 : leaf.1 \
leaf.2 \
leaf.3
echo Test dependency list split across lines.
touch node.6
# Target list split across lines.
split.tar \
leaf.4 \
leaf.5 :
echo Test target list split across lines
touch leaf.4 leaf.5
# Command lines split across lines.
split.cmd:
echo Try splitting command \
lines across more \
than one line.
#
# Test AM error reports and exit statuses.
#
errors:
-./am.alt test.mk error.1
-./am.alt test.mk error.2
-./am.alt test.mk error.3
# Target that does not exist, has no dependencies, and no commands.
error.1:
# Target where dependency does not exist.
error.2: unknown
# Recipe command causes error.
error.3: t1 fail t2
fail:
ls -l unknown
#
#
#
done:
echo AM Test Complete
clean:
rm leaf.* node.*
+3 -3
View File
@@ -77,7 +77,7 @@ r5 :
echo TEXT_5='$(TEXT_5)'
#
# Try to update a prerequisite more than once. Subsequent occurences
# Try to update a prerequisite more than once. Subsequent occurrences
# should be ignored once a prerequisite has been updated.
#
repeat: t1 repeat.a t3
@@ -85,7 +85,7 @@ repeat.a : t2 t1
#
# Target with multi-line receipe.
# Target with multi-line recipe.
#
many : leaf.1 leaf.2
echo Execute receipe with multiple commands.
@@ -100,7 +100,7 @@ leaf.2 :
#
# Test receipe line flags.
# Test recipe line flags.
#
flags : silence ignore always combination
+22
View File
@@ -0,0 +1,22 @@
#
# Anthony's Editor
#
# IOCCC 1991
#
# Winner Best Utility
#
CFLAGS = -Os -Wno-deprecated-non-prototype -Wno-unsequenced
all: build
build: ant sleep
clean:
-rm -f ant
ant: ant.c
${CC} ${CFLAGS} ant.c -o $@
sleep: sleep.c
${CC} ${CFLAGS} sleep.c -o $@
+242
View File
@@ -0,0 +1,242 @@
/*
* am.c Anthony's Make
*
* Public Domain 1992 by Anthony Howe. All rights released.
*
*
* SYNOPSIS
*
* am <makefile> [target]
*
*
* REFERENCES
*
* [Mil87] Webb Miller, "A Software Tools Sampler", Prentic Hall, 87
* ISBN 0-13-822305-X, chaper 2
*
* [POSIX] POSIX.2 draft 11.2 MAKE
*/
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef RULES
#define RULES 500
#endif
#define next(p, i) (p += i, p += strspn(p, white), i = strcspn(p, white))
char *buf, line[BUFSIZ];
char *tar[RULES], *dep[RULES], *cmd[RULES], white[] = "\n\t ";
time_t mtime();
int target();
void update();
/*
* Return the modification time for file.
* If file does not exist then return zero.
*/
time_t
mtime(f)
char *f;
{
int j, x;
size_t i = 0;
struct stat s;
next(f, i);
x = f[i];
f[i] = '\0';
j = stat(f, &s);
f[i] = x;
return (j < 0 ? 0 : s.st_mtime);
}
/*
* Find first occurence of target f. All subsequent occurences
* are ignored. Return the rule number, zero (0) is the empty
* rule and indicates no target found.
*/
int
target(f)
char *f;
{
char *q;
size_t i = 0, j, k = 1;
next(f, i);
while ((q = tar[k]) != NULL) {
j = 0;
while (next(q, j) != 0) {
if (i == j && strncmp(f, q, i) == 0)
return (k);
}
++k;
}
return (0);
}
/*
* Try to update a file's dependencies, then the file itself.
* If the file does not exist, has no dependencies, and no
* known commands, then exit with an error.
*/
void
update(f)
char *f;
{
time_t t = mtime(f);
size_t i = 0, j = t == 0, k = target(f);
char *p = dep[k], *q = cmd[k];
if (next(p, i) == 0 && q != NULL && *q != '\t' && j) {
fprintf(stderr, "am: Don't know how to make '%s'.\n", f);
exit(1);
}
/* Try and update all out-of-date dependencies first. */
while (0 < i) {
update(p);
if (t < mtime(p))
j = 1;
next(p, i);
}
if (j && q != NULL && *q == '\t') {
/* Some systems do not record a file's modification times
* with enough precision. This sleep() guarantees that
* each file has a unique modification time.
*/
sleep(1);
while (*q++ == '\t') {
i = j = 1;
while (0 < strspn(q, "-+@")) {
if (*q == '@')
/* Be silent. */
i = 0;
if (*q++ == '-')
/* Ignore errors. */
j = 0;
}
if (i)
puts(q);
if (system(q) != 0 && j) {
fprintf(stderr, "am: Error making '%s'\n", f);
exit(1);
}
q += strlen(q) + 1;
}
cmd[k] = NULL;
}
}
int
main(argc, argv)
int argc;
char **argv;
{
FILE *f;
struct stat s;
size_t i, j, k;
char *m, *n, *p, *q, *r;
if (argc < 2) {
fprintf(stderr, "usage: am <makefile> [target]\n");
return (2);
}
if (stat(*++argv, &s) != 0 || (f = fopen(*argv, "r")) == NULL)
return (3);
/* Allocate room for expanded target rules. */
q = buf = malloc(2*s.st_size);
if (buf == NULL)
return (4);
/* Facts:
*
* o When a C program starts, all uninitialized data will be
* zero or NULL.
*
* o line[] contains the current makefile line and r points
* into line[]. line <= r < line + BUFSIZ
*
* o p points to the start of text copied from line[].
* q points to the next free storage location.
* buf <= p <= q <= buf + s.st_size;
*
* o m points to start of a temporarily stored macro definition.
*
* o i is the number of rules stored. 0 < i < RULES
*
* o When a C program terminates, all open files are closed and
* any allocated memory is freed.
*/
i = 1;
k = 0;
m = NULL;
/* The empty rule. */
*tar = *dep = *cmd = "";
while ((r = fgets(line, BUFSIZ, f)) != NULL) {
if (RULES <= i) {
fprintf(stderr,
"am: Number of target-rules exceeds %d.\n",
RULES
);
return (1);
}
if (k) {
*q++ = ' ';
r += strspn(r, white);
} else {
/* If a target list was saved and we've terminated
* the dependency list, then line[] may be the first
* command in the target recipe.
*/
if (tar[i] != NULL)
cmd[i++] = q;
if (m != NULL && putenv(m))
fprintf(stderr,
"am: No more environment space.\n");
m = NULL;
/* Skip comment or blank lines. */
if (*line == '#' || *line == '\n')
continue;
p = q;
}
while (!(k = *r == '\\' && r[1] == '\n') && *r != '\0') {
if (*r == '$') {
if (r[1] == '(') {
n = r+2;
r += strcspn(r, ")");
*r++ = '\0';
n = getenv(n);
if (n != NULL)
q = strcpy(q, n) + strlen(n);
continue;
}
if (*r == r[1])
++r;
}
if (*r == '=' && *line != '\t' && m == NULL) {
*q = '\0';
m = p;
j = 0;
q = next(m, j) + m;
*q++ = *r;
j = 1;
if (next(r, j) == 0)
*q++ = '\0';
continue;
}
if (*r == ':') {
tar[i] = p;
*r = '\0';
dep[i] = q+1;
}
if (*r == '\n')
*r = '\0';
*q++ = *r++;
}
}
fclose(f);
update(2 < argc ? *++argv : tar[1]);
return (0);
}
+18
View File
@@ -0,0 +1,18 @@
/*
* sleep.c
*/
#include <time.h>
void
sleep(secs)
unsigned secs;
{
clock_t start, now;
start = clock();
do
now = clock();
while ((now - start) / CLK_TCK < secs);
}
+16
View File
@@ -403,6 +403,8 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
<!-- BEFORE: 1st line of markdown file: 1992/ant/README.md -->
<h2 id="to-build">To build:</h2>
<pre><code> make all</code></pre>
<p>The author provided us with an unobfuscated version. See <a href="#alternate-code">Alternate
code</a> below.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./ant Makefile
@@ -410,6 +412,15 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
<p>where <code>Makefile</code> is a Makefile to use and <code>rule</code> is an optional rule to use.</p>
<h2 id="try">Try:</h2>
<pre><code> ./try.sh</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>This version, <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/deobfuscated/ant.c">ant.c in deobfuscated/</a>, was provided by the
author in 2024, and is a deobfuscated version.</p>
<h2 id="alternate-build">Alternate build:</h2>
<pre><code> make alt</code></pre>
<h2 id="alternate-use">Alternate use:</h2>
<p>Use <code>ant.alt</code> as you would <code>ant</code> above.</p>
<h2 id="try-1">Try:</h2>
<pre><code> ./try.alt.sh</code></pre>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>Like much of POSIX, obfuscation has its place. Your task is to
figure out where.</p>
@@ -447,8 +458,13 @@ P1003 subcommittee.</p>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/Makefile">Makefile</a> - entry Makefile</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.orig.c">ant.orig.c</a> - original source code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/try.sh">try.sh</a> - script to try entry</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/deobfuscated/ant.c">deobfuscated/ant.c</a> - author provided deobfuscated code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/deobfuscated/sleep.c">deobfuscated/sleep.c</a> - author provided code for those who need a nap</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.README.txt">ant.README.txt</a> - am man page</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.test.mk">ant.test.mk</a> - Makefile to demonstrate entry</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/deobfuscated/Makefile">deobfuscated/Makefile</a> - author provided Makefile for deobfuscated code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/try.alt.sh">try.alt.sh</a> - script to try deobfuscated code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.test.alt.mk">ant.test.alt.mk</a> - Makefile to demonstrate deobfuscated code</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env bash
#
# try.sh - demonstrate IOCCC entry 1992/ant 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
echo "$ ./ant.alt Makefile am.alt # build the tool itself" 1>&2
read -r -n 1 -p "Press any key to run: ./ant Makefile am: "
echo 1>&2
./ant.alt Makefile am.alt
echo 1>&2
echo "$ ./am.alt Makefile am_clobber # clobber everything except am" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./am.alt Makefile am_clobber # clobber everything except am
echo 1>&2
echo "$ ./am.alt ant.test.alt.mk # run the test Makefile with am" 1>&2
read -r -n 1 -p "Press any key to continue: "
echo 1>&2
./am.alt ant.test.alt.mk # run the test Makefile with am.alt