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>
|
||||
|
||||
+5
-13
@@ -42,15 +42,15 @@
|
||||
"entry_text" : "script to try entry"
|
||||
},
|
||||
{
|
||||
"file_path" : "deobfuscated/ant.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"
|
||||
"entry_text" : "author provided unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "deobfuscated/sleep.c",
|
||||
"file_path" : "sleep.c",
|
||||
"inventory_order" : 140,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
@@ -73,21 +73,13 @@
|
||||
"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"
|
||||
"entry_text" : "script to try unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "ant.test.alt.mk",
|
||||
@@ -95,7 +87,7 @@
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "makefile",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "Makefile to demonstrate deobfuscated code"
|
||||
"entry_text" : "Makefile to demonstrate unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "1992_ant.tar.bz2",
|
||||
|
||||
+7
-21
@@ -117,8 +117,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ= deobfuscated/${PROG}.o
|
||||
ALT_TARGET= deobfuscated/${PROG}
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
@@ -146,29 +146,15 @@ am: ant
|
||||
|
||||
# alternative executable
|
||||
#
|
||||
alt: data ${PROG}.alt
|
||||
alt: data ${ALT_TARGET}
|
||||
@${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
|
||||
${PROG}.alt: ${PROG}.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
am.alt: ant.alt
|
||||
rm -f am.alt
|
||||
ln deobfuscated/ant am.alt
|
||||
cp ant.alt am.alt
|
||||
cp am.alt am.safe.alt
|
||||
cp am.safe.alt am.alt
|
||||
rm -f am.safe.alt
|
||||
@@ -240,7 +226,7 @@ clean:
|
||||
clobber: clean
|
||||
${RM} -f ${TARGET} ${ALT_TARGET}
|
||||
${RM} -rf *.dSYM
|
||||
${RM} -f am am.safe am.alt am.safe.alt deobfuscated/ant ${PROG}.alt
|
||||
${RM} -f am am.safe am.alt am.safe.alt ${PROG}.alt
|
||||
${RM} -f node.* leaf.*
|
||||
@-if [ -e sandwich ]; then \
|
||||
${RM} -f sandwich; \
|
||||
|
||||
+2
-2
@@ -29,8 +29,8 @@ 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.
|
||||
This version, [ant.alt.c](%%REPO_URL%%/1992/ant/ant.alt.c), was provided by the
|
||||
author in 2024, and is an unobfuscated version.
|
||||
|
||||
|
||||
## Alternate build:
|
||||
|
||||
File renamed without changes.
@@ -1,22 +0,0 @@
|
||||
#
|
||||
# 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 $@
|
||||
+6
-7
@@ -413,8 +413,8 @@ code</a> below.</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>
|
||||
<p>This version, <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.alt.c">ant.alt.c</a>, was provided by the
|
||||
author in 2024, and is an unobfuscated version.</p>
|
||||
<h2 id="alternate-build">Alternate build:</h2>
|
||||
<pre><code> make alt</code></pre>
|
||||
<h2 id="alternate-use">Alternate use:</h2>
|
||||
@@ -458,13 +458,12 @@ 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.alt.c">ant.alt.c</a> - author provided unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/sleep.c">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>
|
||||
<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 unobfuscated 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 unobfuscated code</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
|
||||
File renamed without changes.
+4
-4
@@ -10,7 +10,7 @@ if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" alt >/dev/null || exit 1
|
||||
make clobber CC="$CC" alt >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
@@ -23,13 +23,13 @@ echo 1>&2
|
||||
|
||||
|
||||
|
||||
echo "$ ./am.alt Makefile am_clobber # clobber everything except am" 1>&2
|
||||
echo "$ ./am.alt Makefile am_alt_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
|
||||
./am.alt Makefile am_alt_clobber # clobber everything except am.alt
|
||||
echo 1>&2
|
||||
|
||||
echo "$ ./am.alt ant.test.alt.mk # run the test Makefile with am" 1>&2
|
||||
echo "$ ./am.alt ant.test.alt.mk # run the test Makefile with am.alt" 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
|
||||
+1
-1
@@ -10,7 +10,7 @@ if [[ -z "$CC" ]]; then
|
||||
CC="cc"
|
||||
fi
|
||||
|
||||
make CC="$CC" all >/dev/null || exit 1
|
||||
make clobber CC="$CC" all >/dev/null || exit 1
|
||||
|
||||
# clear screen after compilation so that only the entry is shown
|
||||
clear
|
||||
|
||||
+6
-22
@@ -50,20 +50,12 @@
|
||||
"entry_text" : "script to try entry"
|
||||
},
|
||||
{
|
||||
"file_path" : "deobfuscated/ant-c89.c",
|
||||
"file_path" : "ant.alt.c",
|
||||
"inventory_order" : 120,
|
||||
"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" : 120,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "author provided deobfuscated code"
|
||||
"entry_text" : "author provided unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "try.alt.sh",
|
||||
@@ -71,23 +63,15 @@
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "shellscript",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "script to try deobfuscated code"
|
||||
"entry_text" : "script to try unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "deobfuscated/Makefile",
|
||||
"file_path" : "test.alt.mk",
|
||||
"inventory_order" : 140,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "makefile",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "author provided Makefile for deobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "deobfuscated/test.mk",
|
||||
"inventory_order" : 140,
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "makefile",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "author provided test suite Makefile for deobfuscated code"
|
||||
"entry_text" : "author provided test suite Makefile for unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "ant.test.mk",
|
||||
@@ -111,7 +95,7 @@
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "makefile",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "test suite Makefile for deobfuscated code"
|
||||
"entry_text" : "test suite Makefile for unobfuscated code"
|
||||
},
|
||||
{
|
||||
"file_path" : "1993_ant.tar.bz2",
|
||||
|
||||
+4
-18
@@ -116,8 +116,8 @@ OBJ= ${PROG}.o
|
||||
DATA=
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ= deobfuscated/${PROG}.o
|
||||
ALT_TARGET= deobfuscated/${PROG}
|
||||
ALT_OBJ= ${PROG}.alt.o
|
||||
ALT_TARGET= ${PROG}.alt
|
||||
|
||||
|
||||
#################
|
||||
@@ -148,22 +148,8 @@ ag.txt: ${PROG}.txt
|
||||
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
|
||||
${PROG}.alt: ant.alt.c
|
||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
|
||||
|
||||
ag.alt: ${PROG}.alt
|
||||
${RM} -f $@
|
||||
|
||||
+3
-3
@@ -4,7 +4,7 @@
|
||||
make all
|
||||
```
|
||||
|
||||
The author provided a deobfuscated version. See [Alternate
|
||||
The author provided an unobfuscated version. See [Alternate
|
||||
code](#alternate-code) below.
|
||||
|
||||
|
||||
@@ -36,8 +36,8 @@ For more detailed information see [1993/ant in bugs.html](../../bugs.html#1993_a
|
||||
|
||||
## Alternate code:
|
||||
|
||||
The [ant.c in deobfuscated/](%%REPO_URL%%/1993/ant/deobfuscated/ant.c) is a
|
||||
deobfuscated version provided by the author. You can look at this code if you
|
||||
The [ant.alt.c](%%REPO_URL%%/1993/ant/ant.alt.c) is an
|
||||
unobfuscated version provided by the author. You can look at this code if you
|
||||
want some clues in how it works.
|
||||
|
||||
|
||||
|
||||
File renamed without changes.
@@ -10,7 +10,7 @@ PRG=./ant.alt
|
||||
all: ant.alt char word anchor literal wild closure option branch sub class
|
||||
|
||||
#
|
||||
# Built the entry
|
||||
# Build the entry
|
||||
#
|
||||
ant.alt: Makefile
|
||||
make -f Makefile ant.alt
|
||||
|
||||
@@ -10,7 +10,7 @@ PRG=./ant
|
||||
all: ant char word anchor literal wild closure option branch sub class
|
||||
|
||||
#
|
||||
# Built the entry
|
||||
# Build the entry
|
||||
#
|
||||
ant: Makefile
|
||||
make -f Makefile ant
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
CFLAGS= -Os -Wno-deprecated-non-prototype
|
||||
|
||||
all: build
|
||||
|
||||
build: ant ant-c89
|
||||
|
||||
clean:
|
||||
-rm -f ant ant-c89 *.out
|
||||
|
||||
# Original K&R version.
|
||||
ant$E: ant.c
|
||||
${CC} ${CFLAGS} ant.c -o $@
|
||||
|
||||
ant-c89$E: ant-c89.c
|
||||
${CC} ${CFLAGS} ant-c89.c -o $@
|
||||
|
||||
test: ant$E
|
||||
${MAKE} -f test.mk PRG=./ant >ant.out 2>&1
|
||||
|
||||
test-c89: ant-c89$E
|
||||
${MAKE} -f test.mk PRG=./ant-c89 >ant-c89.out 2>&1
|
||||
|
||||
# Make sure the old and revised versions behave the same.
|
||||
test-compare: build test test-c89
|
||||
sed -e 's/-c89//' ant-c89.out | diff -u ant.out -
|
||||
rm *.out
|
||||
|
||||
@@ -1,449 +0,0 @@
|
||||
/*
|
||||
* ag.c
|
||||
*
|
||||
* Anthony's Grep
|
||||
*
|
||||
* Public Domain 1992, 1993 by Anthony Howe. All rights released.
|
||||
*
|
||||
* Synopsis: ag <pattern> [files...]
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifndef ARRAY
|
||||
#define ARRAY 512
|
||||
#endif
|
||||
|
||||
#define EXIT_MATCH 0
|
||||
#define EXIT_NOMATCH 1
|
||||
#define EXIT_USAGE 2
|
||||
#define EXIT_ERROR 3
|
||||
|
||||
/*
|
||||
* Non-deterministic Finite-state Automaton
|
||||
*
|
||||
* An NFA is a directed graph whose nodes are called states. Each
|
||||
* state is either a labeled state denoting a literal value, or a
|
||||
* NIL state that has no label. Each state has at most two edges
|
||||
* leaving it. There is only one start state and one final state,
|
||||
* which may be the same state.
|
||||
*
|
||||
* Various state-structures can be represented by an array. These
|
||||
* structures have only one start point being the left most index,
|
||||
* and one end point being the right most index.
|
||||
*
|
||||
* a ...[a]...
|
||||
*
|
||||
* ab ...[a][b]...
|
||||
*
|
||||
* ^a [bol][a]...
|
||||
*
|
||||
* a$ ...[a][eol]
|
||||
*
|
||||
* a.b ...[a][wild][b]...
|
||||
* _
|
||||
* v \
|
||||
* a* ...[\][a][\]...
|
||||
* \____^
|
||||
*
|
||||
* a? ...[\][a]...
|
||||
* \___^
|
||||
* _______________
|
||||
* / v
|
||||
* a|b ...[\][a][/][stop][pass][b]...
|
||||
* \_____________^
|
||||
*
|
||||
* [a0-9] ...[class][a][0][1][2][3][4][5][6][7][8][9][stop]...
|
||||
*
|
||||
* [^a0-9] ...[nclass][a][0][1][2][3][4][5][6][7][8][9][stop]...
|
||||
*
|
||||
* _____________ _______________
|
||||
* / v/ v
|
||||
* a|b|c ...[\][a][/][stop][\][b][/][stop][pass][c]...
|
||||
* \_____________^\_____________^
|
||||
*
|
||||
* _ _______________
|
||||
* v \ / v
|
||||
* a*(b|c) ...[\][a][\][\][b][/][stop][pass][c]...
|
||||
* \____^ \_____________^
|
||||
*/
|
||||
|
||||
#define BOL ('\n')
|
||||
#define EOL ('\n')
|
||||
#define STOP ('\n')
|
||||
#define WILD (0)
|
||||
#define CLASS (-1)
|
||||
#define NCLASS (-2)
|
||||
#define PASS (-3)
|
||||
#define JUMP(n) (-4-(n))
|
||||
#define CHAR(c) (c)
|
||||
#define ISJUMP(x) ((x) <= PASS)
|
||||
#define ISCHAR(x) (0 <= (x))
|
||||
|
||||
/*
|
||||
* Special member that is contained in all sets. It is the location
|
||||
* of the WILD element that the pattern array is initialised with in
|
||||
* main(). Due to the way from() performs the pattern search, this
|
||||
* member is always the first member of a set and so can be used to
|
||||
* delimit sets.
|
||||
*/
|
||||
#define MEMBER 2
|
||||
|
||||
typedef int I;
|
||||
typedef char C;
|
||||
typedef void V;
|
||||
|
||||
I chr;
|
||||
I final;
|
||||
I nesting;
|
||||
I array[ARRAY], next;
|
||||
|
||||
/*
|
||||
* The number of states will always be related to the number of
|
||||
* unique sets in set[], which is less-than-equal-to next_set.
|
||||
* There is no need to bounds check dfa[][] since next_set
|
||||
* is bounds checked in from() and would cause an error well in
|
||||
* advance of overflowing the total number of possible states.
|
||||
*/
|
||||
I dfa[ARRAY][ARRAY];
|
||||
I set[ARRAY], new_set, next_set;
|
||||
|
||||
I new();
|
||||
I match();
|
||||
I inclass();
|
||||
I isfinal();
|
||||
V expr();
|
||||
V term();
|
||||
V factor();
|
||||
V literal();
|
||||
V from();
|
||||
|
||||
I
|
||||
main(argc, argv)
|
||||
I argc;
|
||||
C **argv;
|
||||
{
|
||||
I error;
|
||||
FILE *file;
|
||||
C *name, line[BUFSIZ+1];
|
||||
|
||||
if (--argc < 1) {
|
||||
fprintf(stderr, "usage: ag <pattern> [files...]\n");
|
||||
return (EXIT_USAGE);
|
||||
}
|
||||
|
||||
/* Initialise array[] = [pass][3][wild][1]... */
|
||||
new(PASS);
|
||||
new(JUMP(next+2));
|
||||
new(WILD);
|
||||
new(JUMP(next-1));
|
||||
|
||||
expr(&(*++argv));
|
||||
|
||||
*line = BOL;
|
||||
next_set = 1;
|
||||
error = EXIT_NOMATCH;
|
||||
do {
|
||||
name = "-";
|
||||
file = stdin;
|
||||
if (1 < argc && **++argv != '-') {
|
||||
if (NULL == (file = fopen(name = *argv, "r"))) {
|
||||
fprintf(stderr,
|
||||
"ag: Failed to open '%s'.\n", name);
|
||||
error = EXIT_ERROR;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
while (fgets(line+1, BUFSIZ, file) != NULL) {
|
||||
if (match(line)) {
|
||||
printf("%s:%s", name, line+1);
|
||||
error = EXIT_MATCH;
|
||||
}
|
||||
}
|
||||
fclose(file);
|
||||
} while (1 < --argc);
|
||||
return (error);
|
||||
}
|
||||
|
||||
/*
|
||||
* expr
|
||||
* term
|
||||
* expr | term
|
||||
*/
|
||||
V
|
||||
expr(p)
|
||||
C **p;
|
||||
{
|
||||
I i, j;
|
||||
i = new(PASS);
|
||||
term(p);
|
||||
while (**p == '|') {
|
||||
++*p;
|
||||
j = new(PASS);
|
||||
new(STOP);
|
||||
array[i] = JUMP(next);
|
||||
i = new(PASS);
|
||||
term(p);
|
||||
array[j] = JUMP(next);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* term
|
||||
* factor
|
||||
* term factor
|
||||
*/
|
||||
V
|
||||
term(p)
|
||||
C **p;
|
||||
{
|
||||
while (**p != '|' && (0 == nesting || **p != ')') && **p != '\0')
|
||||
factor(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* factor
|
||||
* ^
|
||||
* $
|
||||
* literal
|
||||
* ( expr )
|
||||
* factor *
|
||||
*/
|
||||
V
|
||||
factor(p)
|
||||
C **p;
|
||||
{
|
||||
I i = new(PASS);
|
||||
if (**p == '^') {
|
||||
++*p;
|
||||
new(BOL);
|
||||
} else if (**p == '$') {
|
||||
++*p;
|
||||
new(EOL);
|
||||
} else if (**p == '(') {
|
||||
++*p;
|
||||
++nesting;
|
||||
expr(p);
|
||||
if (**p != ')') {
|
||||
fprintf(stderr, "ag: Missing ')'.\n");
|
||||
exit(EXIT_ERROR);
|
||||
}
|
||||
--nesting;
|
||||
++*p;
|
||||
} else {
|
||||
literal(p);
|
||||
}
|
||||
if (**p == '*') {
|
||||
++*p;
|
||||
array[i] = JUMP(next);
|
||||
new(JUMP(i+1));
|
||||
} else if (**p == '?') {
|
||||
++*p;
|
||||
array[i] = JUMP(next);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* literal
|
||||
* .
|
||||
* class
|
||||
* character
|
||||
* \ character
|
||||
*
|
||||
* class
|
||||
* [ ] ]
|
||||
* [ range ]
|
||||
* [ ] range ]
|
||||
* [ ^ range ]
|
||||
* [ ^ ] range ]
|
||||
*
|
||||
* range
|
||||
* -
|
||||
* character
|
||||
* range character
|
||||
* character_low - character_hi
|
||||
* range character_low - character_hi
|
||||
*/
|
||||
V
|
||||
literal(p)
|
||||
C **p;
|
||||
{
|
||||
I i, j;
|
||||
if (**p == '.') {
|
||||
new(WILD);
|
||||
} else if (**p == '[') {
|
||||
++*p;
|
||||
i = new(CLASS);
|
||||
if (**p == '^') {
|
||||
++*p;
|
||||
array[i] = NCLASS;
|
||||
}
|
||||
if (**p == ']') {
|
||||
++*p;
|
||||
new(CHAR(']'));
|
||||
}
|
||||
while ((i = **p) != ']') {
|
||||
if ((*p)[1] == '-' && i < (j = (*p)[2])) {
|
||||
while (i <= j)
|
||||
new(CHAR(i++));
|
||||
*p += 3;
|
||||
} else {
|
||||
new(CHAR(i));
|
||||
++*p;
|
||||
}
|
||||
}
|
||||
new(STOP);
|
||||
} else {
|
||||
if (**p == '\\')
|
||||
++*p;
|
||||
new(CHAR(**p));
|
||||
}
|
||||
++*p;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate an element from the pool of free elements. The
|
||||
* global variable 'next' points to the next free element in
|
||||
* the pool. Return the allocated element's index.
|
||||
*/
|
||||
I
|
||||
new(c)
|
||||
I c;
|
||||
{
|
||||
if (ARRAY <= next) {
|
||||
fprintf(stderr, "ag: Pattern too long.\n");
|
||||
exit(EXIT_ERROR);
|
||||
}
|
||||
array[next] = c;
|
||||
return (next++);
|
||||
}
|
||||
|
||||
/*
|
||||
* Find all labeled elements reachable from element 'p' and add to
|
||||
* the global set 'new_set' those that are labeled with global 'chr'.
|
||||
* 'final' is true if the final state can be reached.
|
||||
*/
|
||||
V
|
||||
from(p)
|
||||
I p;
|
||||
{
|
||||
I i = new_set;
|
||||
if (next <= p)
|
||||
return;
|
||||
if (ISJUMP(array[p])) {
|
||||
if (array[p] != PASS)
|
||||
from(JUMP(array[p]));
|
||||
from(p+1);
|
||||
} else if (WILD == array[p] || array[p] == CHAR(chr) || inclass(&p)) {
|
||||
/* If element 'p' already a member of set 't' then return. */
|
||||
while (i < next_set)
|
||||
if (set[i++] == p)
|
||||
return;
|
||||
/* Can we reach the final state from here? */
|
||||
final = isfinal(p+1);
|
||||
|
||||
if (ARRAY <= next_set) {
|
||||
fprintf(stderr, "ag: Out of space.\n");
|
||||
exit(EXIT_ERROR);
|
||||
}
|
||||
/* Add element 'p' to set 't'. */
|
||||
set[next_set++] = p;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If element pointed to by 'p' is CLASS, return true if 'c' is in
|
||||
* the class. If the element is NCLASS, return true if 'c' is not
|
||||
* in the class. Pass back the end of the character class in 'p'.
|
||||
*/
|
||||
I
|
||||
inclass(p)
|
||||
I *p;
|
||||
{
|
||||
I i = 0, j = 0;
|
||||
if (array[*p] == CLASS || (j = array[*p] == NCLASS)) {
|
||||
while (array[++*p] != STOP)
|
||||
if (array[*p] == CHAR(chr))
|
||||
i = 1;
|
||||
}
|
||||
return (i ^ j);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if the end point (final state) can be reached
|
||||
* from element 'p' without crossing any labeled elements.
|
||||
*/
|
||||
I
|
||||
isfinal(p)
|
||||
I p;
|
||||
{
|
||||
return (
|
||||
final || p == next || (
|
||||
ISJUMP(array[p]) && (
|
||||
(array[p] != PASS && isfinal(JUMP(array[p])))
|
||||
|| isfinal(p+1)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return true if the given string matches. The search string must
|
||||
* be of the form "\ntext\n\0" in order to handle line anchoring.
|
||||
*/
|
||||
I
|
||||
match(p)
|
||||
C *p;
|
||||
{
|
||||
I state, i, j, k;
|
||||
final = state = 0;
|
||||
while (*p != '\0' && 0 <= state) {
|
||||
if (0 < (i = dfa[state][*p])) {
|
||||
/* Transition on known DFA state. */
|
||||
state = i;
|
||||
} else {
|
||||
/* Perform lazy DFA evaluation from NFA.
|
||||
*
|
||||
* Compute new_set, which represents a transition
|
||||
* from the current state's set on character *p.
|
||||
* dfa[state]['\0'] contains the set[] index for
|
||||
* the current state.
|
||||
*/
|
||||
chr = *p;
|
||||
i = dfa[state]['\0'];
|
||||
j = new_set = next_set;
|
||||
do
|
||||
from(set[i++]+1);
|
||||
while (set[i] != MEMBER);
|
||||
|
||||
/* Determine if this is a known set or not. */
|
||||
i = k = 0;
|
||||
while (i < new_set) {
|
||||
if (set[i] == MEMBER) {
|
||||
j = new_set;
|
||||
++k;
|
||||
}
|
||||
if (set[i++] == set[j]) {
|
||||
if (next_set <= ++j) {
|
||||
j = new_set;
|
||||
if (set[i] == MEMBER) {
|
||||
/* Known set found. */
|
||||
next_set = new_set;
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
j = new_set;
|
||||
}
|
||||
}
|
||||
if (new_set < next_set)
|
||||
/* New set found. */
|
||||
dfa[++k]['\0'] = new_set;
|
||||
state = dfa[state][*p] = final ? -1 : k;
|
||||
}
|
||||
++p;
|
||||
}
|
||||
return (state < 0);
|
||||
}
|
||||
|
||||
+7
-9
@@ -403,7 +403,7 @@ Location: <a href="../../location.html#CA">CA</a> - <em>Canada</em></li>
|
||||
<!-- BEFORE: 1st line of markdown file: 1993/ant/README.md -->
|
||||
<h2 id="to-build">To build:</h2>
|
||||
<pre><code> make all</code></pre>
|
||||
<p>The author provided a deobfuscated version. See <a href="#alternate-code">Alternate
|
||||
<p>The author provided an unobfuscated version. See <a href="#alternate-code">Alternate
|
||||
code</a> below.</p>
|
||||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||||
<p>The current status of this entry is:</p>
|
||||
@@ -415,8 +415,8 @@ code</a> below.</p>
|
||||
<h2 id="try">Try:</h2>
|
||||
<pre><code> ./try.sh</code></pre>
|
||||
<h2 id="alternate-code">Alternate code:</h2>
|
||||
<p>The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/deobfuscated/ant.c">ant.c in deobfuscated/</a> is a
|
||||
deobfuscated version provided by the author. You can look at this code if you
|
||||
<p>The <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/ant.alt.c">ant.alt.c</a> is an
|
||||
unobfuscated version provided by the author. You can look at this code if you
|
||||
want some clues in how it works.</p>
|
||||
<h2 id="alternate-build">Alternate build:</h2>
|
||||
<p>If you wish to build this deobfuscated version, you can do so like:</p>
|
||||
@@ -472,14 +472,12 @@ more information.</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/ant.orig.c">ant.orig.c</a> - original source code</li>
|
||||
<li><a href="ant.txt">ant.txt</a> - ag man page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/try.sh">try.sh</a> - script to try entry</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/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/1993/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/1993/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/1993/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/1993/ant/deobfuscated/test.mk">deobfuscated/test.mk</a> - author provided test suite Makefile for deobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/ant.alt.c">ant.alt.c</a> - author provided unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/try.alt.sh">try.alt.sh</a> - script to try unobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/test.alt.mk">test.alt.mk</a> - author provided test suite Makefile for unobfuscated code</li>
|
||||
<li><a href="ants.txt">ants.txt</a> - lyrics of the Ants Go Marching song</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/ant.test.mk">ant.test.mk</a> - test suite Makefile</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/ant.alt.test.mk">ant.alt.test.mk</a> - test suite Makefile for deobfuscated code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/ant.alt.test.mk">ant.alt.test.mk</a> - test suite Makefile for unobfuscated code</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
|
||||
@@ -13,13 +13,13 @@ all: char word anchor literal wild closure option branch sub class
|
||||
#
|
||||
|
||||
empty:
|
||||
$(PRG) '' test.mk
|
||||
$(PRG) '' test.alt.mk
|
||||
|
||||
char:
|
||||
$(PRG) 'q' test.mk
|
||||
$(PRG) 'q' test.alt.mk
|
||||
|
||||
word:
|
||||
$(PRG) 'simple' test.mk
|
||||
$(PRG) 'simple' test.alt.mk
|
||||
|
||||
#
|
||||
# Test meta characters.
|
||||
@@ -28,28 +28,28 @@ word:
|
||||
anchor: anchor1 anchor2 anchor3 anchor4 anchor5
|
||||
|
||||
anchor1:
|
||||
$(PRG) '^anchor1' test.mk
|
||||
$(PRG) '^anchor1' test.alt.mk
|
||||
|
||||
anchor2:
|
||||
$(PRG) 'Grep$$' test.mk
|
||||
$(PRG) 'Grep$$' test.alt.mk
|
||||
|
||||
#
|
||||
# Find all empty lines.
|
||||
#
|
||||
anchor3:
|
||||
$(PRG) '^$$' test.mk
|
||||
$(PRG) '^$$' test.alt.mk
|
||||
|
||||
#
|
||||
# This is valid but will never match.
|
||||
#
|
||||
anchor4:
|
||||
-$(PRG) 'x^a' test.mk
|
||||
-$(PRG) 'x^a' test.alt.mk
|
||||
|
||||
#
|
||||
# This is valid but will never match.
|
||||
#
|
||||
anchor5:
|
||||
-$(PRG) 'mk$$x' test.mk
|
||||
-$(PRG) 'mk$$x' test.alt.mk
|
||||
|
||||
literal: literal1 literal2
|
||||
|
||||
@@ -57,13 +57,13 @@ literal: literal1 literal2
|
||||
# Every line with a dollar-sign.
|
||||
#
|
||||
literal1:
|
||||
$(PRG) '\$$' test.mk
|
||||
$(PRG) '\$$' test.alt.mk
|
||||
|
||||
#
|
||||
# Every line with a backslash.
|
||||
#
|
||||
literal2:
|
||||
$(PRG) '\\' test.mk
|
||||
$(PRG) '\\' test.alt.mk
|
||||
|
||||
#
|
||||
# wild #1#
|
||||
@@ -71,7 +71,7 @@ literal2:
|
||||
# wild #%#
|
||||
#
|
||||
wild:
|
||||
$(PRG) '#.#' test.mk
|
||||
$(PRG) '#.#' test.alt.mk
|
||||
|
||||
#
|
||||
# closure !!
|
||||
@@ -79,7 +79,7 @@ wild:
|
||||
# closure !xxxxxx!
|
||||
#
|
||||
closure:
|
||||
$(PRG) 'closure !x*!' test.mk
|
||||
$(PRG) 'closure !x*!' test.alt.mk
|
||||
|
||||
#
|
||||
# option ++
|
||||
@@ -91,45 +91,45 @@ closure:
|
||||
option: option1 option2
|
||||
|
||||
option1:
|
||||
$(PRG) '+b?+' test.mk
|
||||
$(PRG) '+b?+' test.alt.mk
|
||||
|
||||
option2:
|
||||
$(PRG) '+.?+' test.mk
|
||||
$(PRG) '+.?+' test.alt.mk
|
||||
|
||||
branch: branch1 branch2 branch3 branch4 branch5 branch6
|
||||
|
||||
branch1:
|
||||
$(PRG) 'q|simple' test.mk
|
||||
$(PRG) 'q|simple' test.alt.mk
|
||||
|
||||
#
|
||||
# This pattern should be the same as '(^all)|(Public)|(Grep$)'.
|
||||
#
|
||||
branch2:
|
||||
$(PRG) '^all|Public|Grep$$' test.mk
|
||||
$(PRG) '^all|Public|Grep$$' test.alt.mk
|
||||
|
||||
#
|
||||
# This pattern should generate the same results as branch2.
|
||||
#
|
||||
branch3:
|
||||
$(PRG) 'Grep$|^all|Public' test.mk
|
||||
$(PRG) 'Grep$|^all|Public' test.alt.mk
|
||||
|
||||
#
|
||||
# Null expression between start of pattern and vertical-line.
|
||||
#
|
||||
branch4:
|
||||
$(PRG) '|Grep' test.mk
|
||||
$(PRG) '|Grep' test.alt.mk
|
||||
|
||||
#
|
||||
# Null expression between vertical-line and end of pattern.
|
||||
#
|
||||
branch5:
|
||||
$(PRG) 'Grep|' test.mk
|
||||
$(PRG) 'Grep|' test.alt.mk
|
||||
|
||||
#
|
||||
# Null expression between vertical-line and vertical-line.
|
||||
#
|
||||
branch6:
|
||||
$(PRG) 'all||Grep' test.mk
|
||||
$(PRG) 'all||Grep' test.alt.mk
|
||||
|
||||
#
|
||||
# sub aabcbcbcxx
|
||||
@@ -144,49 +144,49 @@ sub: sub0 sub1 sub2 sub3 sub4 sub5 lparen1 lparen2 rparen1 rparen2
|
||||
# Null sub-expressions.
|
||||
#
|
||||
sub0:
|
||||
$(PRG) 's()u()b()' test.mk
|
||||
$(PRG) 's()u()b()' test.alt.mk
|
||||
|
||||
sub1:
|
||||
$(PRG) '#(1|%)#' test.mk
|
||||
$(PRG) '#(1|%)#' test.alt.mk
|
||||
|
||||
sub2:
|
||||
$(PRG) 'aa((bc)*|g)xx' test.mk
|
||||
$(PRG) 'aa((bc)*|g)xx' test.alt.mk
|
||||
|
||||
#
|
||||
# Null expression between the left-parenthesis and the vertical-line.
|
||||
#
|
||||
sub3:
|
||||
$(PRG) '#(|1)#' test.mk
|
||||
$(PRG) '#(|1)#' test.alt.mk
|
||||
|
||||
#
|
||||
# Null expression between the vertical-line and the right-parenthesis.
|
||||
#
|
||||
sub4:
|
||||
$(PRG) '#(1|)#' test.mk
|
||||
$(PRG) '#(1|)#' test.alt.mk
|
||||
|
||||
#
|
||||
# Null expression between the vertical-line and the right-parenthesis.
|
||||
#
|
||||
sub5:
|
||||
$(PRG) '#(%||1)#' test.mk
|
||||
$(PRG) '#(%||1)#' test.alt.mk
|
||||
|
||||
#
|
||||
# Missing left-parenthesis generates an error.
|
||||
#
|
||||
lparen1:
|
||||
-$(PRG) 'left ( only' test.mk
|
||||
-$(PRG) 'left ( only' test.alt.mk
|
||||
|
||||
lparen2:
|
||||
$(PRG) 'left \( only' test.mk
|
||||
$(PRG) 'left \( only' test.alt.mk
|
||||
|
||||
#
|
||||
# Right-parenthesis without preceding left parenthesis should be a literal.
|
||||
#
|
||||
rparen1:
|
||||
-$(PRG) 'right ) only' test.mk
|
||||
-$(PRG) 'right ) only' test.alt.mk
|
||||
|
||||
rparen2:
|
||||
$(PRG) 'right \) only' test.mk
|
||||
$(PRG) 'right \) only' test.alt.mk
|
||||
|
||||
#
|
||||
# 12345678
|
||||
@@ -208,26 +208,26 @@ rparen2:
|
||||
class: class1 class2 class3 class4 class5 class6 class7 class8
|
||||
|
||||
class1:
|
||||
$(PRG) '=[09]=' test.mk
|
||||
$(PRG) '=[09]=' test.alt.mk
|
||||
|
||||
class2:
|
||||
$(PRG) '=[^09]=' test.mk
|
||||
$(PRG) '=[^09]=' test.alt.mk
|
||||
|
||||
class3:
|
||||
$(PRG) '=[]]=' test.mk
|
||||
$(PRG) '=[]]=' test.alt.mk
|
||||
|
||||
class4:
|
||||
$(PRG) '=[^]]=' test.mk
|
||||
$(PRG) '=[^]]=' test.alt.mk
|
||||
|
||||
class5:
|
||||
$(PRG) '=[0-9]=' test.mk
|
||||
$(PRG) '=[0-9]=' test.alt.mk
|
||||
|
||||
class6:
|
||||
$(PRG) '=[^0-9]=' test.mk
|
||||
$(PRG) '=[^0-9]=' test.alt.mk
|
||||
|
||||
class7:
|
||||
-$(PRG) '=[3-1]=' test.mk
|
||||
-$(PRG) '=[3-1]=' test.alt.mk
|
||||
|
||||
class8:
|
||||
$(PRG) '=[-13]=' test.mk
|
||||
$(PRG) '=[-13]=' test.alt.mk
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "deobfuscated and formatted source code"
|
||||
"entry_text" : "unobfuscated and formatted source code"
|
||||
},
|
||||
{
|
||||
"file_path" : "1995_garry.tar.bz2",
|
||||
|
||||
@@ -474,7 +474,7 @@ variables by their binary representation, e.g.:</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1995/garry/garry.data">garry.data</a> - modified README.md for input to program</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1995/garry/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/1995/garry/try.sh">try.sh</a> - script to try entry</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1995/garry/garry.fmt.c">garry.fmt.c</a> - deobfuscated and formatted source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1995/garry/garry.fmt.c">garry.fmt.c</a> - unobfuscated and formatted source code</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
<ul>
|
||||
|
||||
+20
-12
@@ -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",
|
||||
|
||||
@@ -8,5 +8,6 @@ indent.o
|
||||
makeholes
|
||||
prog
|
||||
prog.alt
|
||||
prog.alt2
|
||||
prog.orig
|
||||
war-and-peace.txt
|
||||
+10
-3
@@ -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
@@ -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
|
||||
|
||||
@@ -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
@@ -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,6 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
# Assume a POSIX compliant shell.
|
||||
|
||||
make all || exit 1
|
||||
PROG="./prog"
|
||||
|
||||
args=$(getopt 'f:w' "$@")
|
||||
|
||||
Executable
+137
@@ -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.
Executable
+95
@@ -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
@@ -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
|
||||
@@ -103,7 +103,7 @@
|
||||
"OK_to_edit" : true,
|
||||
"display_as" : "c",
|
||||
"display_via_github" : true,
|
||||
"entry_text" : "deobfuscated source code"
|
||||
"entry_text" : "unobfuscated source code"
|
||||
},
|
||||
{
|
||||
"file_path" : "obfuscation/tmpl.txt",
|
||||
|
||||
@@ -459,7 +459,7 @@ render for a larger terminal window? How about adding more glyphs?</p>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/obfuscation/gen.rb">obfuscation/gen.rb</a> - ruby code to compose items and prog.c in artistic way</li>
|
||||
<li><a href="obfuscation/glyphs.txt">obfuscation/glyphs.txt</a> - glyphs data for deobfuscation/gen.rb</li>
|
||||
<li><a href="obfuscation/index.html">obfuscation/index.html</a> - deobfuscation information web page</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/obfuscation/prog.c">obfuscation/prog.c</a> - deobfuscated source code</li>
|
||||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2020/endoh2/obfuscation/prog.c">obfuscation/prog.c</a> - unobfuscated source code</li>
|
||||
<li><a href="obfuscation/tmpl.txt">obfuscation/tmpl.txt</a> - template for deobfuscation/gen.rb output</li>
|
||||
</ul>
|
||||
<h2 id="secondary-files">Secondary files</h2>
|
||||
|
||||
@@ -2949,6 +2949,25 @@ takes care to warn about this issue after printing an incorrect big-endian
|
||||
result. Error messages become garbled, though.</p></li>
|
||||
</ul>
|
||||
<p>–</p>
|
||||
<div id="2015_howe">
|
||||
<h2 id="howe">2015/howe</h2>
|
||||
</div>
|
||||
<h3 id="status-known-bug---please-help-us-fix-12">STATUS: known bug - please help us fix</h3>
|
||||
<p>The test scripts do not seem to work properly with bash but this would be ideal
|
||||
as not all systems have a compatible shell (they assume a POSIX compliant
|
||||
shell). One, with bash, might see:</p>
|
||||
<pre><code> ./prog-test.sh
|
||||
<<< A='1' B='1'
|
||||
prog: : No such file or directory
|
||||
>>> got=0 expect=0 -OK-
|
||||
<<< A='1' B='A'
|
||||
prog: : No such file or directory
|
||||
>>> got=0 expect=2 FAIL</code></pre>
|
||||
<p>It would appear that the variable passed to the command in the function,
|
||||
<code>distance</code>, is empty.</p>
|
||||
<p>The same problem exists in the
|
||||
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/prog.alt-test.sh">prog.alt-test.sh</a>, particularly
|
||||
because it is the same thing as the other, just updated to use <code>prog.alt</code>.</p>
|
||||
<div id="2015_mills2">
|
||||
<h2 id="mills2">2015/mills2</h2>
|
||||
</div>
|
||||
@@ -3028,7 +3047,7 @@ fixing the syntax error in the generated <code>ioccc.json</code> file.</p>
|
||||
<div id="2018_mills">
|
||||
<h2 id="mills-1">2018/mills</h2>
|
||||
</div>
|
||||
<h3 id="status-known-bug---please-help-us-fix-12">STATUS: known bug - please help us fix</h3>
|
||||
<h3 id="status-known-bug---please-help-us-fix-13">STATUS: known bug - please help us fix</h3>
|
||||
<h3 id="source-code-2018millsprog.c">Source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2018/mills/prog.c">2018/mills/prog.c</a></h3>
|
||||
<h3 id="information-2018millsindex.html">Information: <a href="2018/mills/index.html">2018/mills/index.html</a></h3>
|
||||
<p>After exiting the program (with ctrl-e) if you try running it again you will
|
||||
|
||||
@@ -3690,6 +3690,7 @@ they will properly get:
|
||||
<hr style="width:10%;text-align:left;margin-left:0">
|
||||
|
||||
|
||||
|
||||
<div id="2015_hou">
|
||||
## 2015/hou
|
||||
</div>
|
||||
@@ -3722,6 +3723,33 @@ result. Error messages become garbled, though.
|
||||
|
||||
--
|
||||
|
||||
<div id="2015_howe">
|
||||
## 2015/howe
|
||||
</div>
|
||||
|
||||
### STATUS: known bug - please help us fix
|
||||
|
||||
The test scripts do not seem to work properly with bash but this would be ideal
|
||||
as not all systems have a compatible shell (they assume a POSIX compliant
|
||||
shell). One, with bash, might see:
|
||||
|
||||
``` <!---sh-->
|
||||
./prog-test.sh
|
||||
<<< A='1' B='1'
|
||||
prog: : No such file or directory
|
||||
>>> got=0 expect=0 -OK-
|
||||
<<< A='1' B='A'
|
||||
prog: : No such file or directory
|
||||
>>> got=0 expect=2 FAIL
|
||||
```
|
||||
|
||||
It would appear that the variable passed to the command in the function,
|
||||
`distance`, is empty.
|
||||
|
||||
The same problem exists in the
|
||||
[prog.alt-test.sh](%%REPO_URL%%/2015/howe/prog.alt-test.sh), particularly
|
||||
because it is the same thing as the other, just updated to use `prog.alt`.
|
||||
|
||||
|
||||
<div id="2015_mills2">
|
||||
## 2015/mills2
|
||||
|
||||
+21
-26
@@ -1409,30 +1409,24 @@ been fixed so that if one passes no arg it will still likely crash.</p>
|
||||
<h3 id="winning-entry-source-code-ant.c">Winning entry source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.c">ant.c</a></h3>
|
||||
</div>
|
||||
<p>The author, <a href="authors.html#Anthony_C_Howe">Anthony C Howe</a>, provided a
|
||||
deobfuscated version which was put in by <a href="#cody">Cody</a> with thanks to Anthony!
|
||||
The <code>deobfuscated</code> directory has the code and Makefile. The entry’s Makefile was
|
||||
updated to compile the alt code, if <code>make alt</code> is used, but in a way that keeps
|
||||
both directories clean (the deobfuscated version will not be in the entry’s
|
||||
directory and vice versa) but also allowing one to just do <code>./ant.alt2</code> (see
|
||||
below for why <code>alt2</code>). There are two versions here,
|
||||
<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> along
|
||||
with the <code>Makefile</code>. The latter C file was converted from <code>K&R</code> by Anthony (the
|
||||
other one did not compile without a few fixes made by Cody).</p>
|
||||
<p><a href="#cody">Cody</a> also added <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">alternate code</a> that
|
||||
unobfuscated version which was put in by <a href="#cody">Cody</a> with thanks to Anthony!
|
||||
This was put in as <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">ant.alt.c</a>. There were two
|
||||
versions, one which was converted from <code>K&R</code> and worked without modification and
|
||||
another which Cody had to slightly modify to get it to work in modern systems.
|
||||
But since only one was needed the one that worked already was used.</p>
|
||||
<p><a href="#cody">Cody</a> also added <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt2.c">another version</a> that
|
||||
will be a bit easier to use for those familiar with vim in the following ways
|
||||
(we don’t want vi users to also not be able to use it or exit it, now do we ?
|
||||
:-) ):</p>
|
||||
<ul>
|
||||
<li>Use <code>0</code> to go to first column.</li>
|
||||
<li>Use <code>$</code> to go to last column.</li>
|
||||
<li>Hit ESC to go back to command mode (instead of form-feed, ctrl-L).</li>
|
||||
<li>Hit ESC to go back to command mode (instead of form-feed, ctrl-L like the original).</li>
|
||||
<li>Use <code>w</code> to go forwards one word.</li>
|
||||
<li>Use <code>b</code> to go backwards one word.</li>
|
||||
<li>Use <code>q</code> to exit.</li>
|
||||
</ul>
|
||||
<p>The other keys were left unchanged.</p>
|
||||
<p>(As this was done first it was left as <code>alt</code> and not changed to <code>alt2</code>.)</p>
|
||||
<div id="1991_brnstnd">
|
||||
<h2 id="winning-entry-1991brnstnd">Winning entry: <a href="1991/brnstnd/index.html">1991/brnstnd</a></h2>
|
||||
<h3 id="winning-entry-source-code-brnstnd.c">Winning entry source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/brnstnd/brnstnd.c">brnstnd.c</a></h3>
|
||||
@@ -1704,12 +1698,9 @@ rule where a line was not ended with a <code>\</code> but should have been.</p>
|
||||
necessary to include <code>time.h</code> so Cody did this as well as this exists in other
|
||||
systems too.</p>
|
||||
<p>Cody also added the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/try.sh">try.sh</a> script.</p>
|
||||
<p>The author, <a href="authors.html#Anthony_C_Howe">Anthony C Howe</a>, provided a
|
||||
deobfuscated version that Cody added in, with thanks to Anthony! The source code
|
||||
and the <code>Makefile</code> as well as <code>sleep.c</code> are in the <code>deobfuscated/</code> directory.
|
||||
The entry’s Makefile was updated in a way that keeps the deobfuscated code
|
||||
separate from the entry’s code but which allows one to use the deobfuscated
|
||||
Makefile when compiling the alt code (via <code>make alt</code>). For this version,
|
||||
<p>The author, <a href="authors.html#Anthony_C_Howe">Anthony C Howe</a>, provided an
|
||||
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/ant.alt.c">unobfuscated version</a> that Cody added in, with
|
||||
thanks to Anthony! For this version,
|
||||
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1992/ant/try.alt.sh">try.alt.sh</a> was added and an alternate test
|
||||
Makefile (along the lines of the author’s provided test Makefile) was added,
|
||||
updated to use <code>ant.alt</code>.</p>
|
||||
@@ -1878,13 +1869,12 @@ encourage you to try the original without two args :-)</p>
|
||||
</div>
|
||||
<p><a href="#cody">Cody</a> added the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/ant/try.sh">try.sh</a> script and a data file,
|
||||
<a href="1993/ant/ants.txt">ants.txt</a>, full of ants for the script.</p>
|
||||
<p>The author, <a href="authors.html#Anthony_C_Howe">Anthony C Howe</a>, provided a
|
||||
deobfuscated version that Cody added in, with thanks to Anthony! The source code
|
||||
(which might have had to be fixed to compile with modern compilers whereas the
|
||||
<code>-c89</code> version was converted from <code>K&R</code> and worked without any fixes) and its
|
||||
Makefile was put in the <code>deobfuscated</code> subdirectory to keep them separate. The
|
||||
entry’s Makefile was updated so that it uses the deobfuscated version’s Makefile
|
||||
but allowing one to run <code>./ant.alt</code>.</p>
|
||||
<p>The author, <a href="authors.html#Anthony_C_Howe">Anthony C Howe</a>, provided an
|
||||
unobfuscated version that Cody added in, with thanks to Anthony! The source code
|
||||
This was put in as <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1991/ant/ant.alt.c">ant.alt.c</a>. There were two
|
||||
versions, one which was converted from <code>K&R</code> and worked without modification and
|
||||
another which Cody had to slightly modify to get it to work in modern systems.
|
||||
But since only one was needed the one that worked already was used.</p>
|
||||
<div id="1993_cmills">
|
||||
<h2 id="winning-entry-1993cmills">Winning entry: <a href="1993/cmills/index.html">1993/cmills</a></h2>
|
||||
<h3 id="winning-entry-source-code-cmills.c-1">Winning entry source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/1993/cmills/cmills.c">cmills.c</a></h3>
|
||||
@@ -4207,6 +4197,11 @@ and Peace text file, fixed the <a href="https://github.com/ioccc-src/temp-test-i
|
||||
resulted in standard input errors in piping to <code>bc(1)</code>) and added the
|
||||
<a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/cc.1">cc.1</a> man page as not all systems have it (in fact it’s
|
||||
<code>gcc(1)</code> from Rocky Linux).</p>
|
||||
<p>The author, <a href="authors.html#Anthony_C_Howe">Anthony C Howe</a>, provided an
|
||||
unobfuscated version that Cody added in, with thanks to Anthony! As the author
|
||||
had already provided an alternate version (which was actually the original
|
||||
entry), this was put in <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/prog.alt2.c">prog.alt2.c</a>. This
|
||||
addition prompted the <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/howe/try.alt.sh">try.alt.sh</a> script.</p>
|
||||
<div id="2015_mills1">
|
||||
<h2 id="winning-entry-2015mills1">Winning entry: <a href="2015/mills1/index.html">2015/mills1</a></h2>
|
||||
<h3 id="winning-entry-source-code-prog.c-19">Winning entry source code: <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2015/mills1//prog.c">prog.c</a></h3>
|
||||
|
||||
+26
-27
@@ -1461,33 +1461,26 @@ Cody also added the [try.sh](%%REPO_URL%%/1990/westley/try.sh) script.
|
||||
|
||||
|
||||
The author, [Anthony C Howe](authors.html#Anthony_C_Howe), provided a
|
||||
deobfuscated version which was put in by [Cody](#cody) with thanks to Anthony!
|
||||
The `deobfuscated` directory has the code and Makefile. The entry's Makefile was
|
||||
updated to compile the alt code, if `make alt` is used, but in a way that keeps
|
||||
both directories clean (the deobfuscated version will not be in the entry's
|
||||
directory and vice versa) but also allowing one to just do `./ant.alt2` (see
|
||||
below for why `alt2`). There are two versions here,
|
||||
[deobfuscated/ant.c](%%REPO_URL%%/1991/ant/deobfuscated/ant.c) and
|
||||
[deobfuscated/ant-c89.c](%%REPO_URL%%/1991/ant/deobfuscated/ant-c89.c) along
|
||||
with the `Makefile`. The latter C file was converted from `K&R` by Anthony (the
|
||||
other one did not compile without a few fixes made by Cody).
|
||||
unobfuscated version which was put in by [Cody](#cody) with thanks to Anthony!
|
||||
This was put in as [ant.alt.c](%%REPO_URL%%/1991/ant/ant.alt.c). There were two
|
||||
versions, one which was converted from `K&R` and worked without modification and
|
||||
another which Cody had to slightly modify to get it to work in modern systems.
|
||||
But since only one was needed the one that worked already was used.
|
||||
|
||||
[Cody](#cody) also added [alternate code](%%REPO_URL%%/1991/ant/ant.alt.c) that
|
||||
[Cody](#cody) also added [another version](%%REPO_URL%%/1991/ant/ant.alt2.c) that
|
||||
will be a bit easier to use for those familiar with vim in the following ways
|
||||
(we don't want vi users to also not be able to use it or exit it, now do we ?
|
||||
:-) ):
|
||||
|
||||
- Use `0` to go to first column.
|
||||
- Use `$` to go to last column.
|
||||
- Hit ESC to go back to command mode (instead of form-feed, ctrl-L).
|
||||
- Hit ESC to go back to command mode (instead of form-feed, ctrl-L like the original).
|
||||
- Use `w` to go forwards one word.
|
||||
- Use `b` to go backwards one word.
|
||||
- Use `q` to exit.
|
||||
|
||||
The other keys were left unchanged.
|
||||
|
||||
(As this was done first it was left as `alt` and not changed to `alt2`.)
|
||||
|
||||
|
||||
<div id="1991_brnstnd">
|
||||
## Winning entry: [1991/brnstnd](1991/brnstnd/index.html)
|
||||
@@ -1888,12 +1881,9 @@ systems too.
|
||||
|
||||
Cody also added the [try.sh](%%REPO_URL%%/1992/ant/try.sh) script.
|
||||
|
||||
The author, [Anthony C Howe](authors.html#Anthony_C_Howe), provided a
|
||||
deobfuscated version that Cody added in, with thanks to Anthony! The source code
|
||||
and the `Makefile` as well as `sleep.c` are in the `deobfuscated/` directory.
|
||||
The entry's Makefile was updated in a way that keeps the deobfuscated code
|
||||
separate from the entry's code but which allows one to use the deobfuscated
|
||||
Makefile when compiling the alt code (via `make alt`). For this version,
|
||||
The author, [Anthony C Howe](authors.html#Anthony_C_Howe), provided an
|
||||
[unobfuscated version](%%REPO_URL%%/1992/ant/ant.alt.c) that Cody added in, with
|
||||
thanks to Anthony! For this version,
|
||||
[try.alt.sh](%%REPO_URL%%/1992/ant/try.alt.sh) was added and an alternate test
|
||||
Makefile (along the lines of the author's provided test Makefile) was added,
|
||||
updated to use `ant.alt`.
|
||||
@@ -2122,13 +2112,12 @@ encourage you to try the original without two args :-)
|
||||
[Cody](#cody) added the [try.sh](%%REPO_URL%%/1993/ant/try.sh) script and a data file,
|
||||
[ants.txt](1993/ant/ants.txt), full of ants for the script.
|
||||
|
||||
The author, [Anthony C Howe](authors.html#Anthony_C_Howe), provided a
|
||||
deobfuscated version that Cody added in, with thanks to Anthony! The source code
|
||||
(which might have had to be fixed to compile with modern compilers whereas the
|
||||
`-c89` version was converted from `K&R` and worked without any fixes) and its
|
||||
Makefile was put in the `deobfuscated` subdirectory to keep them separate. The
|
||||
entry's Makefile was updated so that it uses the deobfuscated version's Makefile
|
||||
but allowing one to run `./ant.alt`.
|
||||
The author, [Anthony C Howe](authors.html#Anthony_C_Howe), provided an
|
||||
unobfuscated version that Cody added in, with thanks to Anthony! The source code
|
||||
This was put in as [ant.alt.c](%%REPO_URL%%/1991/ant/ant.alt.c). There were two
|
||||
versions, one which was converted from `K&R` and worked without modification and
|
||||
another which Cody had to slightly modify to get it to work in modern systems.
|
||||
But since only one was needed the one that worked already was used.
|
||||
|
||||
|
||||
<div id="1993_cmills">
|
||||
@@ -5397,6 +5386,16 @@ resulted in standard input errors in piping to `bc(1)`) and added the
|
||||
[cc.1](%%REPO_URL%%/2015/howe/cc.1) man page as not all systems have it (in fact it's
|
||||
`gcc(1)` from Rocky Linux).
|
||||
|
||||
The author, [Anthony C Howe](authors.html#Anthony_C_Howe), provided an
|
||||
unobfuscated version that Cody added in, with thanks to Anthony! As the author
|
||||
had already provided an alternate version (which was actually the original
|
||||
entry), this was put in [prog.alt2.c](%%REPO_URL%%/2015/howe/prog.alt2.c). This
|
||||
addition prompted the [try.alt.sh](%%REPO_URL%%/2015/howe/try.alt.sh) script.
|
||||
|
||||
The fact there are alternate versions necessitated the
|
||||
[prog.alt-test.sh](%%REPO_URL%%/2015/howe/prog.alt-test.sh) which Cody added as
|
||||
well.
|
||||
|
||||
|
||||
<div id="2015_mills1">
|
||||
## Winning entry: [2015/mills1](2015/mills1/index.html)
|
||||
|
||||
+16
-20
@@ -570,11 +570,9 @@
|
||||
1990,westley,index.html,4294967295,false,html,false,this web page
|
||||
1991,ant,ant.c,20,true,c,true,entry source code
|
||||
1991,ant,Makefile,30,true,makefile,true,entry Makefile
|
||||
1991,ant,ant.alt.c,40,true,c,true,alternate source code
|
||||
1991,ant,ant.alt2.c,40,true,c,true,alternate source code
|
||||
1991,ant,ant.orig.c,50,false,c,true,original source code
|
||||
1991,ant,deobfuscated/ant.c,140,true,c,true,author provided deobfuscated code
|
||||
1991,ant,deobfuscated/ant-c89.c,140,true,c,true,author provided deobfuscated code converted from K&R
|
||||
1991,ant,deobfuscated/Makefile,150,true,c,true,author provided Makefile for deobfuscated code
|
||||
1991,ant,ant.alt.c,140,true,c,true,author provided unobfuscated code
|
||||
1991,ant,1991_ant.tar.bz2,1415926535,false,tbz2,false,download entry tarball
|
||||
1991,ant,README.md,4000000000,true,markdown,true,markdown source for this web page
|
||||
1991,ant,.entry.json,4000000000,true,json,true,entry summary and manifest in JSON
|
||||
@@ -712,13 +710,12 @@
|
||||
1992,ant,Makefile,30,true,makefile,true,entry Makefile
|
||||
1992,ant,ant.orig.c,50,false,c,true,original source code
|
||||
1992,ant,try.sh,100,true,shellscript,true,script to try entry
|
||||
1992,ant,deobfuscated/ant.c,140,true,c,true,author provided deobfuscated code
|
||||
1992,ant,deobfuscated/sleep.c,140,true,c,true,author provided code for those who need a nap
|
||||
1992,ant,ant.alt.c,140,true,c,true,author provided unobfuscated code
|
||||
1992,ant,sleep.c,140,true,c,true,author provided code for those who need a nap
|
||||
1992,ant,ant.README.txt,150,true,text,true,am man page
|
||||
1992,ant,ant.test.mk,150,true,makefile,true,Makefile to demonstrate entry
|
||||
1992,ant,deobfuscated/Makefile,150,true,makefile,true,author provided Makefile for deobfuscated code
|
||||
1992,ant,try.alt.sh,150,true,shellscript,true,script to try deobfuscated code
|
||||
1992,ant,ant.test.alt.mk,160,true,makefile,true,Makefile to demonstrate deobfuscated code
|
||||
1992,ant,try.alt.sh,150,true,shellscript,true,script to try unobfuscated code
|
||||
1992,ant,ant.test.alt.mk,160,true,makefile,true,Makefile to demonstrate unobfuscated code
|
||||
1992,ant,1992_ant.tar.bz2,1415926535,false,tbz2,false,download entry tarball
|
||||
1992,ant,README.md,4000000000,true,markdown,true,markdown source for this web page
|
||||
1992,ant,.entry.json,4000000000,true,json,true,entry summary and manifest in JSON
|
||||
@@ -848,14 +845,12 @@
|
||||
1993,ant,ant.orig.c,50,false,c,true,original source code
|
||||
1993,ant,ant.txt,100,true,text,false,ag man page
|
||||
1993,ant,try.sh,100,true,shellscript,true,script to try entry
|
||||
1993,ant,deobfuscated/ant.c,120,true,c,true,author provided deobfuscated code
|
||||
1993,ant,deobfuscated/ant-c89.c,120,true,c,true,author provided deobfuscated code converted from K&R
|
||||
1993,ant,try.alt.sh,130,true,shellscript,true,script to try deobfuscated code
|
||||
1993,ant,deobfuscated/Makefile,140,true,makefile,true,author provided Makefile for deobfuscated code
|
||||
1993,ant,deobfuscated/test.mk,140,true,makefile,true,author provided test suite Makefile for deobfuscated code
|
||||
1993,ant,ant.alt.c,120,true,c,true,author provided unobfuscated code
|
||||
1993,ant,try.alt.sh,130,true,shellscript,true,script to try unobfuscated code
|
||||
1993,ant,test.alt.mk,140,true,makefile,true,author provided test suite Makefile for unobfuscated code
|
||||
1993,ant,ants.txt,150,false,text,false,lyrics of the Ants Go Marching song
|
||||
1993,ant,ant.test.mk,150,true,makefile,true,test suite Makefile
|
||||
1993,ant,ant.alt.test.mk,160,true,makefile,true,test suite Makefile for deobfuscated code
|
||||
1993,ant,ant.alt.test.mk,160,true,makefile,true,test suite Makefile for unobfuscated code
|
||||
1993,ant,1993_ant.tar.bz2,1415926535,false,tbz2,false,download entry tarball
|
||||
1993,ant,README.md,4000000000,true,markdown,true,markdown source for this web page
|
||||
1993,ant,.entry.json,4000000000,true,json,true,entry summary and manifest in JSON
|
||||
@@ -1158,7 +1153,7 @@
|
||||
1995,garry,garry.data,100,true,text,true,modified README.md for input to program
|
||||
1995,garry,try.alt.sh,100,true,shellscript,true,script to try alternate code
|
||||
1995,garry,try.sh,100,true,shellscript,true,script to try entry
|
||||
1995,garry,garry.fmt.c,150,true,c,true,deobfuscated and formatted source code
|
||||
1995,garry,garry.fmt.c,150,true,c,true,unobfuscated and formatted source code
|
||||
1995,garry,1995_garry.tar.bz2,1415926535,false,tbz2,false,download entry tarball
|
||||
1995,garry,README.md,4000000000,true,markdown,true,markdown source for this web page
|
||||
1995,garry,.entry.json,4000000000,true,json,true,entry summary and manifest in JSON
|
||||
@@ -3527,12 +3522,13 @@
|
||||
2015,howe,prog.orig.c,50,false,c,true,original source code
|
||||
2015,howe,avgtime.sh,100,true,shellscript,true,support script
|
||||
2015,howe,makeholes.c,100,true,c,true,C code to add random holes to a file
|
||||
2015,howe,prog.alt-test.sh,100,true,shellscript,true,script to run test suite with alternate code
|
||||
2015,howe,prog-test.sh,100,true,shellscript,true,script to run test suite
|
||||
2015,howe,try.alt.sh,100,true,shellscript,true,script to try alternate code
|
||||
2015,howe,try.sh,100,true,shellscript,true,script to try entry
|
||||
2015,howe,cc.1,159,true,man,true,cc man page
|
||||
2015,howe,deobfuscated/Makefile,200,true,makefile,true,deobfuscated Makefile
|
||||
2015,howe,deobfuscated/err.h,210,true,c,true,deobfuscated err.h header file
|
||||
2015,howe,deobfuscated/prog.c,210,true,c,true,deobfuscated source code
|
||||
2015,howe,err.h,210,true,c,true,unobfuscated err.h header file
|
||||
2015,howe,prog.alt2.c,210,true,c,true,unobfuscated source code
|
||||
2015,howe,war-and-peace.txt,250,true,text,false,War and Peace translated to English
|
||||
2015,howe,2015_howe.tar.bz2,1415926535,false,tbz2,false,download entry tarball
|
||||
2015,howe,README.md,4000000000,true,markdown,true,markdown source for this web page
|
||||
@@ -4121,7 +4117,7 @@
|
||||
2020,endoh2,obfuscation/gen.rb,200,true,ruby,true,ruby code to compose items and prog.c in artistic way
|
||||
2020,endoh2,obfuscation/glyphs.txt,200,true,text,false,glyphs data for deobfuscation/gen.rb
|
||||
2020,endoh2,obfuscation/index.html,200,true,html,false,deobfuscation information web page
|
||||
2020,endoh2,obfuscation/prog.c,200,true,c,true,deobfuscated source code
|
||||
2020,endoh2,obfuscation/prog.c,200,true,c,true,unobfuscated source code
|
||||
2020,endoh2,obfuscation/tmpl.txt,200,true,text,false,template for deobfuscation/gen.rb output
|
||||
2020,endoh2,2020_endoh2.tar.bz2,1415926535,false,tbz2,false,download entry tarball
|
||||
2020,endoh2,README.md,4000000000,true,markdown,true,markdown source for this web page
|
||||
|
||||
|
Binary file not shown.
+9
-13
@@ -574,11 +574,9 @@
|
||||
1991/ant/Makefile
|
||||
1991/ant/README.md
|
||||
1991/ant/ant.alt.c
|
||||
1991/ant/ant.alt2.c
|
||||
1991/ant/ant.c
|
||||
1991/ant/ant.orig.c
|
||||
1991/ant/deobfuscated/Makefile
|
||||
1991/ant/deobfuscated/ant-c89.c
|
||||
1991/ant/deobfuscated/ant.c
|
||||
1991/ant/index.html
|
||||
1991/brnstnd/.entry.json
|
||||
1991/brnstnd/.gitignore
|
||||
@@ -714,14 +712,13 @@
|
||||
1992/ant/Makefile
|
||||
1992/ant/README.md
|
||||
1992/ant/ant.README.txt
|
||||
1992/ant/ant.alt.c
|
||||
1992/ant/ant.c
|
||||
1992/ant/ant.orig.c
|
||||
1992/ant/ant.test.alt.mk
|
||||
1992/ant/ant.test.mk
|
||||
1992/ant/deobfuscated/Makefile
|
||||
1992/ant/deobfuscated/ant.c
|
||||
1992/ant/deobfuscated/sleep.c
|
||||
1992/ant/index.html
|
||||
1992/ant/sleep.c
|
||||
1992/ant/try.alt.sh
|
||||
1992/ant/try.sh
|
||||
1992/buzzard.1/.entry.json
|
||||
@@ -848,17 +845,15 @@
|
||||
1993/ant/1993_ant.tar.bz2
|
||||
1993/ant/Makefile
|
||||
1993/ant/README.md
|
||||
1993/ant/ant.alt.c
|
||||
1993/ant/ant.alt.test.mk
|
||||
1993/ant/ant.c
|
||||
1993/ant/ant.orig.c
|
||||
1993/ant/ant.test.mk
|
||||
1993/ant/ant.txt
|
||||
1993/ant/ants.txt
|
||||
1993/ant/deobfuscated/Makefile
|
||||
1993/ant/deobfuscated/ant-c89.c
|
||||
1993/ant/deobfuscated/ant.c
|
||||
1993/ant/deobfuscated/test.mk
|
||||
1993/ant/index.html
|
||||
1993/ant/test.alt.mk
|
||||
1993/ant/try.alt.sh
|
||||
1993/ant/try.sh
|
||||
1993/cmills/.entry.json
|
||||
@@ -3528,15 +3523,16 @@
|
||||
2015/howe/README.md
|
||||
2015/howe/avgtime.sh
|
||||
2015/howe/cc.1
|
||||
2015/howe/deobfuscated/Makefile
|
||||
2015/howe/deobfuscated/err.h
|
||||
2015/howe/deobfuscated/prog.c
|
||||
2015/howe/err.h
|
||||
2015/howe/index.html
|
||||
2015/howe/makeholes.c
|
||||
2015/howe/prog-test.sh
|
||||
2015/howe/prog.alt-test.sh
|
||||
2015/howe/prog.alt.c
|
||||
2015/howe/prog.alt2.c
|
||||
2015/howe/prog.c
|
||||
2015/howe/prog.orig.c
|
||||
2015/howe/try.alt.sh
|
||||
2015/howe/try.sh
|
||||
2015/howe/war-and-peace.txt
|
||||
2015/mills1/.entry.json
|
||||
|
||||
@@ -574,11 +574,9 @@
|
||||
1991/ant/Makefile
|
||||
1991/ant/README.md
|
||||
1991/ant/ant.alt.c
|
||||
1991/ant/ant.alt2.c
|
||||
1991/ant/ant.c
|
||||
1991/ant/ant.orig.c
|
||||
1991/ant/deobfuscated/Makefile
|
||||
1991/ant/deobfuscated/ant-c89.c
|
||||
1991/ant/deobfuscated/ant.c
|
||||
1991/ant/index.html
|
||||
1991/brnstnd/.entry.json
|
||||
1991/brnstnd/.gitignore
|
||||
@@ -714,14 +712,13 @@
|
||||
1992/ant/Makefile
|
||||
1992/ant/README.md
|
||||
1992/ant/ant.README.txt
|
||||
1992/ant/ant.alt.c
|
||||
1992/ant/ant.c
|
||||
1992/ant/ant.orig.c
|
||||
1992/ant/ant.test.alt.mk
|
||||
1992/ant/ant.test.mk
|
||||
1992/ant/deobfuscated/Makefile
|
||||
1992/ant/deobfuscated/ant.c
|
||||
1992/ant/deobfuscated/sleep.c
|
||||
1992/ant/index.html
|
||||
1992/ant/sleep.c
|
||||
1992/ant/try.alt.sh
|
||||
1992/ant/try.sh
|
||||
1992/buzzard.1/.entry.json
|
||||
@@ -848,17 +845,15 @@
|
||||
1993/ant/1993_ant.tar.bz2
|
||||
1993/ant/Makefile
|
||||
1993/ant/README.md
|
||||
1993/ant/ant.alt.c
|
||||
1993/ant/ant.alt.test.mk
|
||||
1993/ant/ant.c
|
||||
1993/ant/ant.orig.c
|
||||
1993/ant/ant.test.mk
|
||||
1993/ant/ant.txt
|
||||
1993/ant/ants.txt
|
||||
1993/ant/deobfuscated/Makefile
|
||||
1993/ant/deobfuscated/ant-c89.c
|
||||
1993/ant/deobfuscated/ant.c
|
||||
1993/ant/deobfuscated/test.mk
|
||||
1993/ant/index.html
|
||||
1993/ant/test.alt.mk
|
||||
1993/ant/try.alt.sh
|
||||
1993/ant/try.sh
|
||||
1993/cmills/.entry.json
|
||||
@@ -3528,15 +3523,16 @@
|
||||
2015/howe/README.md
|
||||
2015/howe/avgtime.sh
|
||||
2015/howe/cc.1
|
||||
2015/howe/deobfuscated/Makefile
|
||||
2015/howe/deobfuscated/err.h
|
||||
2015/howe/deobfuscated/prog.c
|
||||
2015/howe/err.h
|
||||
2015/howe/index.html
|
||||
2015/howe/makeholes.c
|
||||
2015/howe/prog-test.sh
|
||||
2015/howe/prog.alt-test.sh
|
||||
2015/howe/prog.alt.c
|
||||
2015/howe/prog.alt2.c
|
||||
2015/howe/prog.c
|
||||
2015/howe/prog.orig.c
|
||||
2015/howe/try.alt.sh
|
||||
2015/howe/try.sh
|
||||
2015/howe/war-and-peace.txt
|
||||
2015/mills1/.entry.json
|
||||
|
||||
@@ -369,10 +369,8 @@
|
||||
1991/ant/Makefile
|
||||
1991/ant/README.md
|
||||
1991/ant/ant.alt.c
|
||||
1991/ant/ant.alt2.c
|
||||
1991/ant/ant.c
|
||||
1991/ant/deobfuscated/Makefile
|
||||
1991/ant/deobfuscated/ant-c89.c
|
||||
1991/ant/deobfuscated/ant.c
|
||||
1991/brnstnd/.entry.json
|
||||
1991/brnstnd/.gitignore
|
||||
1991/brnstnd/Makefile
|
||||
@@ -465,12 +463,11 @@
|
||||
1992/ant/Makefile
|
||||
1992/ant/README.md
|
||||
1992/ant/ant.README.txt
|
||||
1992/ant/ant.alt.c
|
||||
1992/ant/ant.c
|
||||
1992/ant/ant.test.alt.mk
|
||||
1992/ant/ant.test.mk
|
||||
1992/ant/deobfuscated/Makefile
|
||||
1992/ant/deobfuscated/ant.c
|
||||
1992/ant/deobfuscated/sleep.c
|
||||
1992/ant/sleep.c
|
||||
1992/ant/try.alt.sh
|
||||
1992/ant/try.sh
|
||||
1992/buzzard.1/.entry.json
|
||||
@@ -556,14 +553,12 @@
|
||||
1993/ant/.gitignore
|
||||
1993/ant/Makefile
|
||||
1993/ant/README.md
|
||||
1993/ant/ant.alt.c
|
||||
1993/ant/ant.alt.test.mk
|
||||
1993/ant/ant.c
|
||||
1993/ant/ant.test.mk
|
||||
1993/ant/ant.txt
|
||||
1993/ant/deobfuscated/Makefile
|
||||
1993/ant/deobfuscated/ant-c89.c
|
||||
1993/ant/deobfuscated/ant.c
|
||||
1993/ant/deobfuscated/test.mk
|
||||
1993/ant/test.alt.mk
|
||||
1993/ant/try.alt.sh
|
||||
1993/ant/try.sh
|
||||
1993/cmills/.entry.json
|
||||
@@ -2498,13 +2493,14 @@
|
||||
2015/howe/README.md
|
||||
2015/howe/avgtime.sh
|
||||
2015/howe/cc.1
|
||||
2015/howe/deobfuscated/Makefile
|
||||
2015/howe/deobfuscated/err.h
|
||||
2015/howe/deobfuscated/prog.c
|
||||
2015/howe/err.h
|
||||
2015/howe/makeholes.c
|
||||
2015/howe/prog-test.sh
|
||||
2015/howe/prog.alt-test.sh
|
||||
2015/howe/prog.alt.c
|
||||
2015/howe/prog.alt2.c
|
||||
2015/howe/prog.c
|
||||
2015/howe/try.alt.sh
|
||||
2015/howe/try.sh
|
||||
2015/howe/war-and-peace.txt
|
||||
2015/mills1/.entry.json
|
||||
|
||||
Reference in new issue
Block a user