Skip to content

Commit

Permalink
Merge pull request ioccc-src#2543 from xexyl/ant
Browse files Browse the repository at this point in the history
  • Loading branch information
lcn2 committed Jul 6, 2024
2 parents debbe2a + a4fb0a8 commit 0d49e5a
Show file tree
Hide file tree
Showing 39 changed files with 3,174 additions and 48 deletions.
24 changes: 24 additions & 0 deletions 1991/ant/.entry.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,30 @@
"display_via_github" : true,
"entry_text" : "original source code"
},
{
"file_path" : "deobfuscated/ant-c89.c",
"inventory_order" : 140,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "author provided deobfuscated code converted from K&R"
},
{
"file_path" : "deobfuscated/ant.c",
"inventory_order" : 140,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "author provided deobfuscated code"
},
{
"file_path" : "deobfuscated/Makefile",
"inventory_order" : 150,
"OK_to_edit" : true,
"display_as" : "c",
"display_via_github" : true,
"entry_text" : "author provided Makefile for deobfuscated code"
},
{
"file_path" : "1991_ant.tar.bz2",
"inventory_order" : 1415926535,
Expand Down
2 changes: 2 additions & 0 deletions 1991/ant/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
*.dSYM
ant
ant.alt
ant.alt2
ant.alt2-c89
ant.orig
hill
indent
Expand Down
29 changes: 26 additions & 3 deletions 1991/ant/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ OBJ= ${PROG}.o
DATA= README.md
TARGET= ${PROG} hill mole
#
ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ${PROG}.alt
ALT_OBJ= ${PROG}.alt.o deobfuscated/${PROG}.o
ALT_TARGET= ${PROG}.alt deobfuscated/${PROG}


#################
Expand Down Expand Up @@ -151,6 +151,29 @@ mole: ${PROG}.c hill
alt: data ${ALT_TARGET}
@${TRUE}

${PROG}.alt: ${PROG}.alt.c hill
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}

# We keep the deobfuscated source code and Makefile in deobfuscated/, and use
# that Makefile but then move the compiled programs to the entry's directory to
# keep both directories clean and to allow the deobfuscated Makefile and code to
# be used but not require the user to do:
#
# ./deobfuscated/ant
# ./deobfuscated/ant-c89
#
# but rather simply:
#
# ./ant.alt2
# ./ant.alt2-c89
#
# The alt2 is because this is the secondary alt.
deobfuscated/${PROG}: deobfuscated/${PROG}.c deobfuscated/${PROG}-c89.c
${MAKE} -C deobfuscated ant
${MV} -vf deobfuscated/ant ant.alt2
${MAKE} -C deobfuscated ant-c89
${MV} -vf deobfuscated/ant-c89 ant.alt2-c89

# data files
#
data: ${DATA}
Expand Down Expand Up @@ -217,7 +240,7 @@ clean:

clobber: clean
${RM} -f ${TARGET} ${ALT_TARGET}
${RM} -rf *.dSYM
${RM} -rf *.dSYM ant.alt ant.alt2 ant.alt2-c89
@-if [ -e sandwich ]; then \
${RM} -f sandwich; \
echo 'ate sandwich'; \
Expand Down
31 changes: 21 additions & 10 deletions 1991/ant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
make all
```

There is an [alternate version](#alternate-code) that might feel a bit more
familiar to vi(m) users.
There is an alternate version that might feel a bit more familiar to vi(m)
users. Additionally, the author provided deobfuscated versions including one for
C89. See [Alternate code](#alternate-code) below.


## To use:
Expand Down Expand Up @@ -33,12 +34,20 @@ program exit without doing anything.

## Alternate code:

This version changes the commands slightly so that to go to the first column you
should enter `0`, to go to the last column you should enter `$`, to quit you
should enter `q`, to go back a word you should enter `b` and to go forwards a
word you should enter `w`. Also, and perhaps most useful, rather than having to
hit ctrl-L (form-feed, `\f`) to get back to command mode you can use the usual
ESC (`\x1b`).
The author provided us with deobfuscated versions including one for C89. The two
C files in `deobfuscated`,
[deobfuscated/ant.c](%%REPO_URL%%/1991/ant/deobfuscated/ant.c) and
[deobfuscated/ant-c89.c](%%REPO_URL%%/1991/ant/deobfuscated/ant-c89.c) and the
[deobfuscated/Makefile](%%REPO_URL%%/1991/ant/deobfuscated/Makefile) will allow
you to look at them and compile them if you wish. These are exactly like the
original in every way, including in use, except they are deobfuscated.

The other version, [ant.alt.c](%%REPO_URL%%/1991/ant/ant.alt.c) changes the
commands slightly so that to go to the first column you should enter `0`, to go
to the last column you should enter `$`, to quit you should enter `q`, to go
back a word you should enter `b` and to go forwards a word you should enter `w`.
Also, and perhaps most useful, rather than having to hit ctrl-L (form-feed,
`\f`) to get back to command mode you can use the usual ESC (`\x1b`).

These will make it slightly less unwieldy for those familiar with vi(m); the
rest was unchanged.
Expand All @@ -53,8 +62,10 @@ rest was unchanged.

### Alternate use:

Use `ant.alt` as you would `ant` above with the changes in the input keys. See
the author's remarks for the remaining keys.
For the deobfuscated versions, use `ant.alt2` and `ant.alt2-c89` as you would
`ant` above; for the other one, `ant.alt`, use it as you would `ant` above but
with the changes in the input keys described above. See the author's remarks for
the remaining commands.


## Judges' remarks:
Expand Down
34 changes: 34 additions & 0 deletions 1991/ant/deobfuscated/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#
# Anthony's Editor
#
# IOCCC 1991
#
# Winner Best Utility
#

CFLAGS = -Os -Wno-deprecated-non-prototype

all: build

build: ant ant-c89

clean:
-rm -f ant ant-c89

# NOTE: some systems may need:
#
# old SYS V:
# cc ${CFLAGS} -DMODE=0600 -DBUF=32767 -o ant ant.c -lcurses
# ATARI ST:
# cc -DMODE=0 -DBUF=32767 -o ant.ttp ant.c curses.a
# PC class:
# wcl -mc -DMODE=0 -DBUF=32767 ant.c curses.lib
#
# This older version may generate lots of warnings with newer compilers.
#
ant: ant.c
${CC} ${CFLAGS} -DMODE=0600 -DBUF=32767 ant.c -o $@ -lcurses -ltermcap

# Mostly cosmetic changes to read like ANSI C 89.
ant-c89: ant-c89.c
${CC} ${CFLAGS} -DMODE=0600 ant-c89.c -o $@ -lcurses -ltermcap
Loading

0 comments on commit 0d49e5a

Please sign in to comment.