Merge pull request #1410 from xexyl/tomx-2000

This commit is contained in:
Landon Curt Noll authored and GitHub committed 2023-11-14 01:34:58 -07:00
commit a2e2f50b29
8 files changed
+125 -14

No files matched your search

+1
View File
@@ -1,4 +1,5 @@
tomx tomx
tomx.alt
mkentry mkentry
tomx.orig tomx.orig
prog.orig prog.orig
+5 -2
View File
@@ -111,8 +111,8 @@ OBJ= ${PROG}.o
DATA= DATA=
TARGET= ${PROG} TARGET= ${PROG}
# #
ALT_OBJ= ALT_OBJ= ${PROG}.alt.o
ALT_TARGET= ALT_TARGET= ${PROG}.alt
################# #################
@@ -135,6 +135,9 @@ ${PROG}: ${PROG}.c
alt: data ${ALT_TARGET} alt: data ${ALT_TARGET}
@${TRUE} @${TRUE}
${PROG}.alt: ${PROG}.alt.c
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS}
# data files # data files
# #
data: ${DATA} data: ${DATA}
+26 -11
View File
@@ -4,6 +4,9 @@
make make
``` ```
There is an alternate version that compiles [mkentry.c](mkentry.c). See
[alternate code](#alternate-code).
## To use: ## To use:
@@ -15,18 +18,29 @@ make
### Try: ### Try:
```sh ```sh
rm -f ./tomx ./try.sh
chmod +x ./tomx.c
./tomx.c
./tomx
``` ```
as well as:
## Alternate code:
This alternate code is based on the author's remarks with a slight fix so that
it will do what it once did, compile and run [mkentry.c](mkentry.c). You can use
it in a similar way as [tomx.c](tomx.c), both executing the source file and
using it as a Makefile and running the code ends up running `mkentry`.
### Alternate build:
```sh ```sh
rm -f ./tomx make alt
make -f tomx.c ```
./tomx
### Alternate try:
```sh
./try.alt.sh
``` ```
@@ -45,14 +59,15 @@ changes don't change the shell code or the Makefile.
This program works as a C source file, a Makefile and also as a shell This program works as a C source file, a Makefile and also as a shell
(`/bin/sh`) script. But unlike some other multi-language programs, this one is (`/bin/sh`) script. But unlike some other multi-language programs, this one is
NOT meant to print "Hello, world" in all 3 cases (At least in the true sense NOT meant to print `Hello, world` in all 3 cases (At least in the true sense
;-)). The C, make and shell code build upon each other to create a C program (?) ;-)). The C, Makefile and shell code build upon each other to create a C program (?)
which when executed as a shell script will compile itself through the C compiler which when executed as a shell script will compile itself through the C compiler
using a Makefile! - Pretty useful, Eh? using a Makefile! - Pretty useful, Eh?
Probably, this is the first entry ever to fully satisfy Rule #1 ("Your entry Probably, this is the first entry ever to fully satisfy Rule #1 ("Your entry
must be a complete program") in the strictest sense;-) must be a complete program") in the strictest sense;-)
### Top 5 reasons (IMHO) why this code is an entry for IOCCC ### Top 5 reasons (IMHO) why this code is an entry for IOCCC
1. A glance at the source itself will tell you that most of the 1. A glance at the source itself will tell you that most of the
@@ -67,7 +82,7 @@ C (But again, there was NO obfuscated make/shscript contest)
obfuscation should be in C and not elsewhere???. Mmmmm...). obfuscation should be in C and not elsewhere???. Mmmmm...).
3. Extending Argument #2... Obfuscation done in the C code 3. Extending Argument #2... Obfuscation done in the C code
(comments?) create obfuscated code for the other 2 languages. (comments?) creates obfuscated code for the other 2 languages.
This opens new possibilities to be explored in depth in future This opens new possibilities to be explored in depth in future
`IOCCC`s. `IOCCC`s.
+23
View File
@@ -0,0 +1,23 @@
#include <stdio.h>
#define true
true /*:all
CC=cc
PROG=mkentry
false :
make -f $0 $1
exit 0
all: $(PROG)
%:%.c
$(CC) $< -o $@
clean:
rm $(PROG)
.PHONY: /* true clean */
#undef true
#include "mkentry.c"
Regular → Executable
View File
File mode changed.
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
#
# try.sh - script to show 2000/tomx
echo "Using tomx.alt.c to compile mkentry.c directly:" 1>&2
echo "$ chmod +x tomx.alt.c" 1>&2
chmod +x tomx.alt.c
echo "$ rm -f mkentry" 1>&2
rm -f mkentry
echo "$ ./tomx.alt.c" 1>&2
./tomx.alt.c
echo 1>&2
echo "Using tomx.alt.c as a Makefile to compile mkentry.c:" 1>&2
echo "$ rm -f mkentry"
rm mkentry
echo "$ make -f tomx.alt.c" 1>&2
make -f tomx.alt.c
echo 1>&2
echo "Running mkentry via tomx.alt:" 1>&2
echo "$ ./tomx.alt" 1>&2
./tomx.alt
+34
View File
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
#
# try.sh - script to show 2000/tomx
if [[ ! -f "tomx" || ! -e "tomx" ]]; then
echo "Compiling tomx.c:" 1>&2
make all || exit 1
fi
echo "Running tomx:" 1>&2
echo "$ ./tomx" 1>&2
./tomx
echo 1>&2
echo "Using source code to compile tomx.c: " 1>&2
echo "$ rm -f tomx" 1>&2
rm -f tomx
echo "$ chmod +x tomx.c" 1>&2
chmod +x tomx.c
echo "$ ./tomx.c" 1>&2
./tomx.c
echo "Running tomx again:" 1>&2
echo "$ ./tomx" 1>&2
./tomx
echo 1>&2
echo "Using tomx.c as a Makefile:" 1>&2
echo "$ rm -f tomx" 1>&2
rm -f tomx
echo "$ make -f tomx.c" 1>&2
make -f tomx.c
echo "Running tomx again:" 1>&2
echo "$ ./tomx"
./tomx
+13 -1
View File
@@ -2248,7 +2248,8 @@ commands that we recommended.
Cody changed this entry to use `fgets()` instead of `gets()` to make it safer Cody changed this entry to use `fgets()` instead of `gets()` to make it safer
and to prevent annoying warnings from showing up at compiling, linking and/or and to prevent annoying warnings from showing up at compiling, linking and/or
runtime, the latter interspersed with the output of the program. runtime, the latter interspersed with the output of the program. This involved
changing the `K` arg to `gets(3)` to `&K` in `fgets(3)`.
Cody later improved the fix to use `gets()` by redefining `gets()` so that the Cody later improved the fix to use `gets()` by redefining `gets()` so that the
code looks like before. code looks like before.
@@ -2330,6 +2331,17 @@ the curses and the SDL versions as Cody does not have a DOS system to test the
other version in. other version in.
## [2000/tomx](2000/tomx/tomx.c) ([README.md](2000/tomx/README.md]))
Cody added the [alt code](2000/tomx/README.md#alternate-code) based on the
author's remarks with a fix for modern systems and he also added the two
scripts, [try.sh](2000/tomx/try.sh) and [try.alt.sh](2000/tomx/try.alt.sh) for
the main code and the alt code respectively.
And although the scripts do `chmod +x` on the source code (see the README.md for
details) the source code is now executable by default.
## [2001/anonymous](2001/anonymous/anonymous.c) ([README.md](2001/anonymous/README.md])) ## [2001/anonymous](2001/anonymous/anonymous.c) ([README.md](2001/anonymous/README.md]))
Cody fixed both the supplementary program and the program itself (both of which Cody fixed both the supplementary program and the program itself (both of which