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:
1 parent
c9ca6b4150
commit
92139c55d7
53 files changed
+993
-1740
No files matched your search
+3
-19
@@ -26,7 +26,7 @@
|
||||
"entry_text" : "entry Makefile"
|
||||
},
|
||||
{
|
||||
"file_path" : "ant.alt.c",
|
||||
"file_path" : "ant.alt2.c",
|
||||
"inventory_order" : 40,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
@@ -42,28 +42,12 @@
|
||||
"entry_text" : "original source code"
|
||||
},
|
||||
{
|
||||
"file_path" : "deobfuscated/ant-c89.c",
|
||||
"file_path" : "ant.alt.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"
|
||||
"entry_text" : "author provided unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "1991_ant.tar.bz2",
|
||||
|
||||
+13
-22
@@ -119,8 +119,8 @@ OBJ= ${PROG}.o
|
||||
DATA= README.md
|
||||
TARGET= ${PROG} hill mole
|
||||
#
|
||||
ALT_OBJ= ${PROG}.alt.o deobfuscated/${PROG}.o
|
||||
ALT_TARGET= ${PROG}.alt deobfuscated/${PROG}
|
||||
ALT_OBJ= ${PROG}.alt.o ${PROG}.alt2.o
|
||||
ALT_TARGET= ${PROG}.alt ${PROG}.alt2
|
||||
|
||||
|
||||
#################
|
||||
@@ -154,25 +154,16 @@ alt: data ${ALT_TARGET}
|
||||
${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
|
||||
${PROG}.alt2: ${PROG}.alt2.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
hill.alt: README.md
|
||||
${RM} -f $@
|
||||
${CP} -f -v $? $@
|
||||
|
||||
mole.alt: ${PROG}.c hill
|
||||
${RM} -f $@
|
||||
${CAT} ${PROG}.c hill.alt > $@
|
||||
|
||||
# data files
|
||||
#
|
||||
@@ -240,7 +231,7 @@ clean:
|
||||
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
${RM} -rf *.dSYM ant.alt ant.alt2 ant.alt2-c89
|
||||
${RM} -rf *.dSYM ant.alt ant.alt2
|
||||
@-if [ -e sandwich ]; then \
|
||||
${RM} -f sandwich; \
|
||||
echo 'ate sandwich'; \
|
||||
|
||||
+17
-23
@@ -4,9 +4,9 @@
|
||||
make all
|
||||
```
|
||||
|
||||
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.
|
||||
The author provided an unobfuscated version and there is an alternate version
|
||||
that might feel a bit more familiar to vi(m) users. See [Alternate
|
||||
code](#alternate-code) below.
|
||||
|
||||
|
||||
## To use:
|
||||
@@ -34,23 +34,18 @@ program exit without doing anything.
|
||||
|
||||
## Alternate code:
|
||||
|
||||
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 author provided us with an unobfuscated version,
|
||||
[ant.alt.c](%%REPO_URL%%/1991/ant/ant.alt.c).
|
||||
|
||||
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.
|
||||
The other alternate version, [ant.alt2.c](%%REPO_URL%%/1991/ant/ant.alt2.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`); the author explains why this was not originally done in their remarks
|
||||
below. These slight modifications will make it slightly less unwieldy for those
|
||||
familiar with vi(m); the rest was unchanged.
|
||||
|
||||
|
||||
### Alternate build:
|
||||
@@ -62,10 +57,9 @@ rest was unchanged.
|
||||
|
||||
### Alternate use:
|
||||
|
||||
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.
|
||||
For the unobfuscated version, use `ant.alt` as you would `ant` above; for the
|
||||
other one, use `ant.alt2` 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:
|
||||
|
||||
+369
-26
@@ -1,28 +1,371 @@
|
||||
/*
|
||||
* Anthony's Editor
|
||||
*
|
||||
* Public Domain 1991, 2023 by Anthony Howe. All rights released.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
#define T isspace(*(t=Z(p)))&&
|
||||
#define V return
|
||||
#define _ while
|
||||
int d,i,j,m,n,p,q,x,y;char*c,b[BUF],*f,*g=b,*h,k[]="hjklbJKw0$tbixWRq",*t;
|
||||
char*Z(a){if(a<0)V b;V b+a+(b+a<g?0:h-g);}P(a)char*a;{V
|
||||
a-b-(a<h?0:h-g);}S(){p=0;}bf(){n=p=P(c);}Q(){q=1;}C(){clear();Y();}
|
||||
G(){t=Z(p);_(t<g)*--h= *--g;_(h<t)*g++= *h++;p=P(h);}B(){_(!T b<t)--p;_(T
|
||||
b<t)--p;}M(a){_(b<(t=Z(--a))&&*t-'\n');V
|
||||
b<t?++a:0;}N(a){_((t=Z(a++))<c&&*t-'\n');V
|
||||
t<c?a:P(c);}A(a,j){i=0;_((t=Z(a))<c&&*t-'\n'&&i<j){i+= *t-'\t'?1:8-(i&7);++a;}V
|
||||
a;}L(){0<p&&--p;}R(){p<P(c)&&++p;}U(){p=A(M(M(p)-1),x);}
|
||||
D(){p=A(N(p),x);}H(){p=M(p);}E(){p=N(p);L();}
|
||||
J(){m=p=M(n-1);_(0<y--)D();n=P(c);}K(){j=d;_(0<--j)m=M(m-1),U();}
|
||||
I(){G();_((j=getch())-'\x1b'){if(j-'\b')g-h&&(*g++=j-'\r'?j:'\n');else
|
||||
b<g&&--g;p=P(h);Y();}}X(){G();p=h<c?P(++h):p;}
|
||||
F(){j=p;p=0;G();write(i=creat(f,MODE),h,(int)(c-h));close(i);p=j;}W(){_(!T
|
||||
t<c)++p;_(T
|
||||
t<c)++p;}int(*z[])()={L,D,U,R,B,J,K,W,H,E,S,bf,I,X,F,C,Q,G};
|
||||
Y(){m=p<m?M(p):m;if(n<=p){m=N(p);i=m-P(c)?d:d-2;_(0<i--)m=M(m-1);}
|
||||
move(0,0);i=j=0;n=m;_(1){p-n||(y=i,x=j);t=Z(n);if(d<=i||c<=t)break;
|
||||
if(*t-'\r')addch(*t),j+= *t-'\t'?1:8-(j&7);if(*t=='\n'||COLS<=j)
|
||||
++i,j=0;++n;}clrtobot();++i<d&&mvaddstr(i,0,"<< EOF >>");move(y,x);
|
||||
refresh();}main(u,v)char**v;{h=c=b+BUF;if(u<2)V
|
||||
2;initscr();d=LINES;raw();noecho();idlok(stdscr,1);if(0<(i=open(f= *++v,0))){
|
||||
g+=read(i,b,BUF);g=g<b?b:g;close(i);}S();_(!q){Y();i=0;j=getch();
|
||||
_(k[i]&&j-k[i])++i;(*z[i])();}endwin();V 0;}
|
||||
#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;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
#include <ctype.h>
|
||||
#include <curses.h>
|
||||
#define T isspace(*(t=Z(p)))&&
|
||||
#define V return
|
||||
#define _ while
|
||||
int d,i,j,m,n,p,q,x,y;char*c,b[BUF],*f,*g=b,*h,k[]="hjklbJKw0$tbixWRq",*t;
|
||||
char*Z(a){if(a<0)V b;V b+a+(b+a<g?0:h-g);}P(a)char*a;{V
|
||||
a-b-(a<h?0:h-g);}S(){p=0;}bf(){n=p=P(c);}Q(){q=1;}C(){clear();Y();}
|
||||
G(){t=Z(p);_(t<g)*--h= *--g;_(h<t)*g++= *h++;p=P(h);}B(){_(!T b<t)--p;_(T
|
||||
b<t)--p;}M(a){_(b<(t=Z(--a))&&*t-'\n');V
|
||||
b<t?++a:0;}N(a){_((t=Z(a++))<c&&*t-'\n');V
|
||||
t<c?a:P(c);}A(a,j){i=0;_((t=Z(a))<c&&*t-'\n'&&i<j){i+= *t-'\t'?1:8-(i&7);++a;}V
|
||||
a;}L(){0<p&&--p;}R(){p<P(c)&&++p;}U(){p=A(M(M(p)-1),x);}
|
||||
D(){p=A(N(p),x);}H(){p=M(p);}E(){p=N(p);L();}
|
||||
J(){m=p=M(n-1);_(0<y--)D();n=P(c);}K(){j=d;_(0<--j)m=M(m-1),U();}
|
||||
I(){G();_((j=getch())-'\x1b'){if(j-'\b')g-h&&(*g++=j-'\r'?j:'\n');else
|
||||
b<g&&--g;p=P(h);Y();}}X(){G();p=h<c?P(++h):p;}
|
||||
F(){j=p;p=0;G();write(i=creat(f,MODE),h,(int)(c-h));close(i);p=j;}W(){_(!T
|
||||
t<c)++p;_(T
|
||||
t<c)++p;}int(*z[])()={L,D,U,R,B,J,K,W,H,E,S,bf,I,X,F,C,Q,G};
|
||||
Y(){m=p<m?M(p):m;if(n<=p){m=N(p);i=m-P(c)?d:d-2;_(0<i--)m=M(m-1);}
|
||||
move(0,0);i=j=0;n=m;_(1){p-n||(y=i,x=j);t=Z(n);if(d<=i||c<=t)break;
|
||||
if(*t-'\r')addch(*t),j+= *t-'\t'?1:8-(j&7);if(*t=='\n'||COLS<=j)
|
||||
++i,j=0;++n;}clrtobot();++i<d&&mvaddstr(i,0,"<< EOF >>");move(y,x);
|
||||
refresh();}main(u,v)char**v;{h=c=b+BUF;if(u<2)V
|
||||
2;initscr();d=LINES;raw();noecho();idlok(stdscr,1);if(0<(i=open(f= *++v,0))){
|
||||
g+=read(i,b,BUF);g=g<b?b:g;close(i);}S();_(!q){Y();i=0;j=getch();
|
||||
_(k[i]&&j-k[i])++i;(*z[i])();}endwin();V 0;}
|
||||
@@ -1,34 +0,0 @@
|
||||
#
|
||||
# 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
|
||||
@@ -1,371 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
@@ -1,364 +0,0 @@
|
||||
/*
|
||||
* 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);
|
||||
}
|
||||
+19
-26
@@ -403,9 +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 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>
|
||||
<p>The author provided an unobfuscated version and there is an alternate version
|
||||
that might feel a bit more familiar to vi(m) users. 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
|
||||
@@ -416,28 +416,23 @@ program exit without doing anything.</p>
|
||||
<pre><code> make mole
|
||||
./ant mole</code></pre>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<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>
|
||||
<p>The author provided us with an unobfuscated version,
|
||||
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">ant.alt.c</a>.</p>
|
||||
<p>The other alternate version, <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt2.c">ant.alt2.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>); the author explains why this was not originally done in their remarks
|
||||
below. These slight modifications 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>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>
|
||||
<p>For the unobfuscated version, use <code>ant.alt</code> as you would <code>ant</code> above; for the
|
||||
other one, use <code>ant.alt2</code> 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>
|
||||
@@ -548,11 +543,9 @@ ISBN 0-13-822305-X, chapter 5</p>
|
||||
<ul>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.c">ant.c</a> - entry source code</li>
|
||||
<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.alt2.c">ant.alt2.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&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>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">ant.alt.c</a> - author provided unobfuscated code</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
|
||||
Reference in new issue
Block a user