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

+24
View File
@@ -41,6 +41,30 @@
"display_via_github" : true,
"entry_text" : "original source code"
},
{
"file_path" : "deobfuscated/ant-c89.c",
"inventory_order" : 140,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "author provided deobfuscated code converted from K&R"
},
{
"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/Makefile",
"inventory_order" : 150,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "author provided Makefile for deobfuscated code"
},
{
"file_path" : "1991_ant.tar.bz2",
"inventory_order" : 1415926535,
+2
View File
@@ -3,6 +3,8 @@
*.dSYM
ant
ant.alt
ant.alt2
ant.alt2-c89
ant.orig
hill
indent
+26 -3
View File
@@ -119,8 +119,8 @@ OBJ= ${PROG}.o
DATA= README.md
TARGET= ${PROG} hill mole
#
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
ALT_OBJ= ${PROG}.alt.o deobfuscated/${PROG}.o
ALT_TARGET= ${PROG}.alt deobfuscated/${PROG}
#################
@@ -151,6 +151,29 @@ mole: ${PROG}.c hill
alt: data ${ALT_TARGET}
@${TRUE}
${PROG}.alt: ${PROG}.alt.c hill
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
# We keep the deobfuscated source code and Makefile in deobfuscated/, and use
# that Makefile but then move the compiled programs to the entry's directory to
# keep both directories clean and to allow the deobfuscated Makefile and code to
# be used but not require the user to do:
#
# ./deobfuscated/ant
# ./deobfuscated/ant-c89
#
# but rather simply:
#
# ./ant.alt2
# ./ant.alt2-c89
#
# The alt2 is because this is the secondary alt.
deobfuscated/${PROG}: deobfuscated/${PROG}.c deobfuscated/${PROG}-c89.c
${MAKE} -C deobfuscated ant
${MV} -vf deobfuscated/ant ant.alt2
${MAKE} -C deobfuscated ant-c89
${MV} -vf deobfuscated/ant-c89 ant.alt2-c89
# data files
#
data: ${DATA}
@@ -217,7 +240,7 @@ clean:
clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET}
${RM} -rf *.dSYM
${RM} -rf *.dSYM ant.alt ant.alt2 ant.alt2-c89
@-if [ -e sandwich ]; then \
${RM} -f sandwich; \
echo 'ate sandwich'; \
+21 -10
View File
@@ -4,8 +4,9 @@
make all
```
There is an [alternate version](#alternate-code) that might feel a bit more
familiar to vi(m) users.
There is an alternate version that might feel a bit more familiar to vi(m)
users. Additionally, the author provided deobfuscated versions including one for
C89. See [Alternate code](#alternate-code) below.
## To use:
@@ -33,12 +34,20 @@ program exit without doing anything.
## Alternate code:
This version changes the commands slightly so that to go to the first column you
should enter `0`, to go to the last column you should enter `$`, to quit you
should enter `q`, to go back a word you should enter `b` and to go forwards a
word you should enter `w`. Also, and perhaps most useful, rather than having to
hit ctrl-L (form-feed, `\f`) to get back to command mode you can use the usual
ESC (`\x1b`).
The author provided us with deobfuscated versions including one for C89. The two
C files in `deobfuscated`,
[deobfuscated/ant.c](%%REPO_URL%%/1991/ant/deobfuscated/ant.c) and
[deobfuscated/ant-c89.c](%%REPO_URL%%/1991/ant/deobfuscated/ant-c89.c) and the
[deobfuscated/Makefile](%%REPO_URL%%/1991/ant/deobfuscated/Makefile) will allow
you to look at them and compile them if you wish. These are exactly like the
original in every way, including in use, except they are deobfuscated.
The other version, [ant.alt.c](%%REPO_URL%%/1991/ant/ant.alt.c) changes the
commands slightly so that to go to the first column you should enter `0`, to go
to the last column you should enter `$`, to quit you should enter `q`, to go
back a word you should enter `b` and to go forwards a word you should enter `w`.
Also, and perhaps most useful, rather than having to hit ctrl-L (form-feed,
`\f`) to get back to command mode you can use the usual ESC (`\x1b`).
These will make it slightly less unwieldy for those familiar with vi(m); the
rest was unchanged.
@@ -53,8 +62,10 @@ rest was unchanged.
### Alternate use:
Use `ant.alt` as you would `ant` above with the changes in the input keys. See
the author's remarks for the remaining keys.
For the deobfuscated versions, use `ant.alt2` and `ant.alt2-c89` as you would
`ant` above; for the other one, `ant.alt`, use it as you would `ant` above but
with the changes in the input keys described above. See the author's remarks for
the remaining commands.
## Judges' remarks:
+34
View File
@@ -0,0 +1,34 @@
#
# Anthony's Editor
#
# IOCCC 1991
#
# Winner Best Utility
#
CFLAGS = -Os -Wno-deprecated-non-prototype
all: build
build: ant ant-c89
clean:
-rm -f ant ant-c89
# NOTE: some systems may need:
#
# old SYS V:
# cc ${CFLAGS} -DMODE=0600 -DBUF=32767 -o ant ant.c -lcurses
# ATARI ST:
# cc -DMODE=0 -DBUF=32767 -o ant.ttp ant.c curses.a
# PC class:
# wcl -mc -DMODE=0 -DBUF=32767 ant.c curses.lib
#
# This older version may generate lots of warnings with newer compilers.
#
ant: ant.c
${CC} ${CFLAGS} -DMODE=0600 -DBUF=32767 ant.c -o $@ -lcurses -ltermcap
# Mostly cosmetic changes to read like ANSI C 89.
ant-c89: ant-c89.c
${CC} ${CFLAGS} -DMODE=0600 ant-c89.c -o $@ -lcurses -ltermcap
+371
View File
@@ -0,0 +1,371 @@
/*
* Anthony's Editor
*
* Public Domain 1991, 2023 by Anthony Howe. All rights released.
*/
#include <ctype.h>
#include <curses.h>
#include <fcntl.h>
#include <limits.h>
#include <unistd.h>
#ifndef BUF
# define BUF (USHRT_MAX)
#endif
#define TABWIDTH 8
#define TABSTOP(col) (TABWIDTH - ((col) & (TABWIDTH-1)))
static int done;
static int row, col;
static int here, page, epage;
static char buf[BUF];
static char *ebuf;
static char *gap = buf;
static char *egap;
static char *filename;
/*
* The following assertions must be maintained.
*
* o buf <= gap <= egap <= ebuf
* If gap == egap then the buffer is full.
*
* o point = ptr(here) and point < gap or egap <= point
*
* o page <= here < epage
*
* o 0 <= here <= pos(ebuf) <= BUF
*
*
* Memory representation of the file:
*
* low buf -->+----------+
* | front |
* | of file |
* gap -->+----------+<-- character not in file
* | hole |
* egap -->+----------+<-- character in file
* | back |
* | of file |
* high ebuf -->+----------+<-- character not in file
*
*
* point & gap
*
* The Point is the current cursor position while the Gap is the
* position where the last edit operation took place. The Gap is
* ment to be the cursor but to avoid shuffling characters while
* the cursor moves it is easier to just move a pointer and when
* something serious has to be done then you move the Gap to the
* Point.
*/
char *
ptr(int offset)
{
if (offset < 0) {
return buf;
}
return buf+offset + (buf+offset < gap ? 0 : egap-gap);
}
int
pos(char *pointer)
{
return pointer-buf - (pointer < egap ? 0 : egap-gap);
}
void
top(void)
{
here = 0;
}
void
bottom(void)
{
epage = here = pos(ebuf);
}
void
quit(void)
{
done = 1;
}
void
movegap(void)
{
char *p = ptr(here);
while (p < gap) {
*--egap = *--gap;
}
while (egap < p) {
*gap++ = *egap++;
}
here = pos(egap);
}
int
prevline(int offset)
{
char *p;
while (buf < (p = ptr(--offset)) && *p != '\n') {
;
}
return buf < p ? ++offset : 0;
}
int
nextline(int offset)
{
char *p;
while ((p = ptr(offset++)) < ebuf && *p != '\n') {
;
}
return p < ebuf ? offset : pos(ebuf);
}
int
adjust(int offset, int column)
{
char *p;
int i = 0;
while ((p = ptr(offset)) < ebuf && *p != '\n' && i < column) {
i += *p == '\t' ? TABSTOP(i) : 1;
++offset;
}
return offset;
}
void
display(void)
{
char *p;
int i, j;
if (here < page) {
page = prevline(here);
}
if (epage <= here) {
page = nextline(here);
i = page == pos(ebuf) ? LINES-2 : LINES;
while (0 < i--) {
page = prevline(page-1);
}
}
move(0, 0);
clrtobot();
i = j = 0;
epage = page;
for (;;) {
if (here == epage) {
row = i;
col = j;
}
p = ptr(epage);
if (LINES <= i || ebuf <= p) {
break;
}
if (*p != '\r') {
/* Handle tab expansion ourselves. Differences
* between historical Curses and NCurses 2021
* WRT tab handling I can't suss just yet.
*
* Historical Curses addch() would handle tab
* expansion as I recall while (current 2021)
* NCurses does not by default it seems.
*/
if (*p == '\t') {
j += TABSTOP(j);
move(i, j);
} else {
addch(*p);
j++;
}
}
if (*p == '\n' || COLS <= j) {
++i;
j = 0;
}
++epage;
}
if (++i < LINES) {
mvaddstr(i, 0, "~EOF~");
}
move(row, col);
refresh();
}
void
redraw(void)
{
clear();
display();
}
void
left(void)
{
if (0 < here) {
--here;
}
}
void
right(void)
{
if (here < pos(ebuf)) {
++here;
}
}
void
up(void)
{
here = adjust(prevline(prevline(here)-1), col);
}
void
down(void)
{
here = adjust(nextline(here), col);
}
void
lnbegin(void)
{
here = prevline(here);
}
void
lnend(void)
{
here = nextline(here);
left();
}
void
wleft(void)
{
char *p;
while (!isspace(*(p = ptr(here))) && buf < p) {
--here;
}
while (isspace(*(p = ptr(here))) && buf < p) {
--here;
}
}
void
pgdown(void)
{
page = here = prevline(epage-1);
while (0 < row--){
down();
}
epage = pos(ebuf);
}
void
pgup(void)
{
int i = LINES;
while (0 < --i) {
page = prevline(page-1);
up();
}
}
void
wright(void)
{
char *p;
while (!isspace(*(p = ptr(here))) && p < ebuf) {
++here;
}
while (isspace(*(p = ptr(here))) && p < ebuf) {
++here;
}
}
void
insert(void)
{
int ch;
movegap();
while ((ch = getch()) != '\e' && ch != '\f') {
if (ch == '\b') {
if (buf < gap) {
--gap;
}
} else if (gap < egap) {
*gap++ = ch == '\r' ? '\n' : ch;
}
here = pos(egap);
display();
}
}
void
delete(void)
{
movegap();
if (egap < ebuf) {
here = pos(++egap);
}
}
void
file(void)
{
int i;
int j = here;
here = 0;
movegap();
(void) write(i = creat(filename, MODE), egap, (int)(ebuf-egap));
(void) close(i);
here = j;
}
static char key[] = "hjklHJKL[]tbixWRQ";
static void (*func[])(void) = {
left, down, up, right,
wleft, pgdown, pgup, wright,
lnbegin, lnend, top, bottom,
insert, delete, file, redraw, quit, movegap
};
int
main(int argc, char **argv)
{
int ch, i;
egap = ebuf = buf + BUF;
if (argc < 2) {
return 2;
}
initscr();
raw();
noecho();
idlok(stdscr, 1);
if (0 < (i = open(filename = *++argv, 0))) {
gap += read(i, buf, BUF);
if (gap < buf) {
gap = buf;
}
(void) close(i);
}
top();
while (!done) {
display();
ch = getch();
for (i = 0; key[i] != '\0' && ch != key[i]; i++) {
;
}
(*func[i])();
}
endwin();
return 0;
}
+364
View File
@@ -0,0 +1,364 @@
/*
* ae.c Anthony's Editor IOCCC '91
*
* Public Domain 1991 by Anthony Howe. All rights released.
*/
#include <ctype.h>
#include <curses.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
int done;
int row, col;
int idx, page, epage;
char buf[BUF];
char *ebuf;
char *gap = buf;
char *egap;
char *filename;
/*
* The following assertions must be maintained.
*
* o buf <= gap <= egap <= ebuf
* If gap == egap then the buffer is full.
*
* o point = ptr(idx) and point < gap or egap <= point
*
* o page <= idx < epage
*
* o 0 <= idx <= pos(ebuf) <= BUF
*
*
* Memory representation of the file:
*
* low buf -->+----------+
* | front |
* | of file |
* gap -->+----------+<-- character not in file
* | hole |
* egap -->+----------+<-- character in file
* | back |
* | of file |
* high ebuf -->+----------+<-- character not in file
*
*
* point & gap
*
* The Point is the current cursor position while the Gap is the
* position where the last edit operation took place. The Gap is
* ment to be the cursor but to avoid shuffling characters while
* the cursor moves it is easier to just move a pointer and when
* something serious has to be done then you move the Gap to the
* Point.
*/
int adjust();
int nextline();
int pos();
int prevline();
char *ptr();
void bottom();
void delete();
void display();
void down();
void file();
void insert();
void left();
void lnbegin();
void lnend();
void movegap();
void pgdown();
void pgup();
void redraw();
void right();
void quit();
void top();
void up();
void wleft();
void wright();
char key[] = "hjklHJKL[]tbixWRQ";
void (*func[])() = {
left, down, up, right,
wleft, pgdown, pgup, wright,
lnbegin, lnend, top, bottom,
insert, delete, file, redraw, quit, movegap
};
char *
ptr(offset)
int offset;
{
if (offset < 0)
return (buf);
return (buf+offset + (buf+offset < gap ? 0 : egap-gap));
}
int
pos(pointer)
char *pointer;
{
return (pointer-buf - (pointer < egap ? 0 : egap-gap));
}
void
top()
{
idx = 0;
}
void
bottom()
{
epage = idx = pos(ebuf);
}
void
quit()
{
done = 1;
}
void
redraw()
{
clear();
display();
}
void
movegap()
{
char *p = ptr(idx);
while (p < gap)
*--egap = *--gap;
while (egap < p)
*gap++ = *egap++;
idx = pos(egap);
}
int
prevline(offset)
int offset;
{
char *p;
while (buf < (p = ptr(--offset)) && *p != '\n')
;
return (buf < p ? ++offset : 0);
}
int
nextline(offset)
int offset;
{
char *p;
while ((p = ptr(offset++)) < ebuf && *p != '\n')
;
return (p < ebuf ? offset : pos(ebuf));
}
int
adjust(offset, column)
int offset, column;
{
char *p;
int i = 0;
while ((p = ptr(offset)) < ebuf && *p != '\n' && i < column) {
i += *p == '\t' ? 8-(i&7) : 1;
++offset;
}
return (offset);
}
void
left()
{
if (0 < idx)
--idx;
}
void
right()
{
if (idx < pos(ebuf))
++idx;
}
void
up()
{
idx = adjust(prevline(prevline(idx)-1), col);
}
void
down()
{
idx = adjust(nextline(idx), col);
}
void
lnbegin()
{
idx = prevline(idx);
}
void
lnend()
{
idx = nextline(idx);
left();
}
void
wleft()
{
char *p;
while (!isspace(*(p = ptr(idx))) && buf < p)
--idx;
while (isspace(*(p = ptr(idx))) && buf < p)
--idx;
}
void
pgdown()
{
page = idx = prevline(epage-1);
while (0 < row--)
down();
epage = pos(ebuf);
}
void
pgup()
{
int i = LINES;
while (0 < --i) {
page = prevline(page-1);
up();
}
}
void
wright()
{
char *p;
while (!isspace(*(p = ptr(idx))) && p < ebuf)
++idx;
while (isspace(*(p = ptr(idx))) && p < ebuf)
++idx;
}
void
insert()
{
int ch;
movegap();
while ((ch = getch()) != '\f') {
if (ch == '\b') {
if (buf < gap)
--gap;
} else if (gap < egap) {
*gap++ = ch == '\r' ? '\n' : ch;
}
idx = pos(egap);
display();
}
}
void
delete()
{
movegap();
if (egap < ebuf)
idx = pos(++egap);
}
void
file()
{
int i;
int j = idx;
idx = 0;
movegap();
write(i = creat(filename, MODE), egap, (int)(ebuf-egap));
close(i);
idx = j;
}
void
display()
{
char *p;
int i, j;
if (idx < page)
page = prevline(idx);
if (epage <= idx) {
page = nextline(idx);
i = page == pos(ebuf) ? LINES-2 : LINES;
while (0 < i--)
page = prevline(page-1);
}
move(0, 0);
i = j = 0;
epage = page;
while (1) {
if (idx == epage) {
row = i;
col = j;
}
p = ptr(epage);
if (LINES <= i || ebuf <= p)
break;
if (*p != '\r') {
addch(*p);
j += *p == '\t' ? 8-(j&7) : 1;
}
if (*p == '\n' || COLS <= j) {
++i;
j = 0;
}
++epage;
}
clrtobot();
if (++i < LINES)
mvaddstr(i, 0, "<< EOF >>");
move(row, col);
refresh();
}
int
main(argc, argv)
int argc;
char **argv;
{
int ch, i;
egap = ebuf = buf + BUF;
if (argc < 2)
return (2);
initscr();
raw();
noecho();
idlok(stdscr, 1);
if (0 < (i = open(filename = *++argv, 0))) {
gap += read(i, buf, BUF);
if (gap < buf)
gap = buf;
close(i);
}
top();
while (!done) {
display();
i = 0;
ch = getch();
while (key[i] != '\0' && ch != key[i])
++i;
(*func[i])();
}
endwin();
return (0);
}
+23 -10
View File
@@ -403,8 +403,9 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
<!-- BEFORE: 1st line of markdown file: 1991/ant/README.md -->
<h2 id="to-build">To build:</h2>
<pre><code> make all</code></pre>
<p>There is an <a href="#alternate-code">alternate version</a> that might feel a bit more
familiar to vi(m) users.</p>
<p>There is an alternate version that might feel a bit more familiar to vi(m)
users. Additionally, the author provided deobfuscated versions including one for
C89. See <a href="#alternate-code">Alternate code</a> below.</p>
<h2 id="to-use">To use:</h2>
<pre><code> ./ant some_file</code></pre>
<p>NOTE: the file must already exist and not specifying any arg will make the
@@ -415,19 +416,28 @@ program exit without doing anything.</p>
<pre><code> make mole
./ant mole</code></pre>
<h2 id="alternate-code">Alternate code:</h2>
<p>This version changes the commands slightly so that to go to the first column you
should enter <code>0</code>, to go to the last column you should enter <code>$</code>, to quit you
should enter <code>q</code>, to go back a word you should enter <code>b</code> and to go forwards a
word you should enter <code>w</code>. Also, and perhaps most useful, rather than having to
hit ctrl-L (form-feed, <code>\f</code>) to get back to command mode you can use the usual
ESC (<code>\x1b</code>).</p>
<p>The author provided us with deobfuscated versions including one for C89. The two
C files in <code>deobfuscated</code>,
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/deobfuscated/ant.c">deobfuscated/ant.c</a> and
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/deobfuscated/ant-c89.c">deobfuscated/ant-c89.c</a> and the
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/deobfuscated/Makefile">deobfuscated/Makefile</a> will allow
you to look at them and compile them if you wish. These are exactly like the
original in every way, including in use, except they are deobfuscated.</p>
<p>The other version, <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">ant.alt.c</a> changes the
commands slightly so that to go to the first column you should enter <code>0</code>, to go
to the last column you should enter <code>$</code>, to quit you should enter <code>q</code>, to go
back a word you should enter <code>b</code> and to go forwards a word you should enter <code>w</code>.
Also, and perhaps most useful, rather than having to hit ctrl-L (form-feed,
<code>\f</code>) to get back to command mode you can use the usual ESC (<code>\x1b</code>).</p>
<p>These will make it slightly less unwieldy for those familiar with vi(m); the
rest was unchanged.</p>
<h3 id="alternate-build">Alternate build:</h3>
<pre><code> make alt</code></pre>
<h3 id="alternate-use">Alternate use:</h3>
<p>Use <code>ant.alt</code> as you would <code>ant</code> above with the changes in the input keys. See
the author’s remarks for the remaining keys.</p>
<p>For the deobfuscated versions, use <code>ant.alt2</code> and <code>ant.alt2-c89</code> as you would
<code>ant</code> above; for the other one, <code>ant.alt</code>, use it as you would <code>ant</code> above but
with the changes in the input keys described above. See the author’s remarks for
the remaining commands.</p>
<h2 id="judges-remarks">Judges’ remarks:</h2>
<p>The author was kind enough to supply a list of references below,
in case you are still confused after read the source! :-)</p>
@@ -540,6 +550,9 @@ ISBN 0-13-822305-X, chapter 5</p>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/Makefile">Makefile</a> - entry Makefile</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">ant.alt.c</a> - alternate source code</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/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/1991/ant/deobfuscated/ant-c89.c">deobfuscated/ant-c89.c</a> - author provided deobfuscated code converted from K&amp;R</li>
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/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/1991/ant/deobfuscated/Makefile">deobfuscated/Makefile</a> - author provided Makefile for deobfuscated code</li>
</ul>
<h2 id="secondary-files">Secondary files</h2>
<ul>