Merge pull request #1793 from xexyl/sicherman85-alt
This commit is contained in:
6 files changed
+77
-61
No files matched your search
@@ -132,18 +132,15 @@ all: data ${TARGET}
|
|||||||
clean clobber install love haste waste maker easter_egg \
|
clean clobber install love haste waste maker easter_egg \
|
||||||
sandwich supernova deep_magic magic charon pluto
|
sandwich supernova deep_magic magic charon pluto
|
||||||
|
|
||||||
${PROG}: ${PROG}.c ${PROG}.alt2.c
|
${PROG}: ${PROG}.c ${PROG}.alt.c
|
||||||
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} || \
|
${CC} ${CFLAGS} $< -o $@ ${LDFLAGS} || \
|
||||||
${CC} ${CFLAGS} ${PROG}.alt2.c -o $@ ${LDFLAGS}
|
${CC} ${CFLAGS} ${PROG}.alt.c -o $@ ${LDFLAGS}
|
||||||
|
|
||||||
# alternative executable
|
# alternative executable
|
||||||
#
|
#
|
||||||
alt: data ${ALT_TARGET}
|
alt: data ${ALT_TARGET}
|
||||||
@${TRUE}
|
@${TRUE}
|
||||||
|
|
||||||
${PROG}.alt: ${PROG}.alt.c
|
|
||||||
${CC} ${CFLAGS} -traditional-cpp $< -o $@ ${LDFLAGS}
|
|
||||||
|
|
||||||
# data files
|
# data files
|
||||||
#
|
#
|
||||||
data: ${DATA}
|
data: ${DATA}
|
||||||
|
|||||||
+19
-18
@@ -4,14 +4,9 @@
|
|||||||
make all
|
make all
|
||||||
```
|
```
|
||||||
|
|
||||||
There is an alternate version for those with an old enough compiler or one that
|
There is another version that will be compiled in case the first fails. This
|
||||||
accepts `-traditional-cpp`. The second alt version will be compiled in the case
|
should happen automatically. See [Alternate code](#alternate-code) below for
|
||||||
that you have a compiler that does not support 1 arg only in `main()`. For
|
more details on it.
|
||||||
instance clang has a number of defects and some versions say that `main()` can
|
|
||||||
only have 0, 2 or 3 args. The versions that have this that we know about do
|
|
||||||
support 1 arg but in case this is ever changed the
|
|
||||||
[sicherman.alt2.c](sicherman.alt2.c) is provided. See [Alternate
|
|
||||||
code](#alternate-code) below for details on the alt code, the original entry.
|
|
||||||
|
|
||||||
|
|
||||||
## To use:
|
## To use:
|
||||||
@@ -20,34 +15,40 @@ code](#alternate-code) below for details on the alt code, the original entry.
|
|||||||
./sicherman < file
|
./sicherman < file
|
||||||
|
|
||||||
echo foo | ./sicherman
|
echo foo | ./sicherman
|
||||||
|
|
||||||
|
./sicherman
|
||||||
|
# type or paste some text, making sure to hit enter after each line typed
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Try:
|
### Try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./sicherman < sicherman.c
|
./try.sh
|
||||||
|
|
||||||
echo IOCCC | ./sicherman
|
|
||||||
|
|
||||||
./sicherman < sicherman.c | ./sicherman
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Alternate code:
|
## Alternate code:
|
||||||
|
|
||||||
The [sicherman.alt.c](sicherman.alt.c) is the original entry and requires either
|
The [sicherman.alt.c](sicherman.alt.c) is a slight change in the fixed version
|
||||||
an old enough compiler or a compiler that supports `-traditional-cpp`. If you have such
|
(fixed so it does not require `-traditional-cpp`) in that it has two args to
|
||||||
a compiler you can try this version.
|
`main()` as some compilers object to certain number of args in `main()`. This
|
||||||
|
will be built in the case of the [sicherman.c](sicherman.c) failing to compile.
|
||||||
|
In this case it'll be compiled to `sicherman` to simplify it for the larger
|
||||||
|
audience.
|
||||||
|
|
||||||
|
|
||||||
### Alternate build:
|
### Alternate build:
|
||||||
|
|
||||||
|
Although this will be built if the original fails to compile you can do it
|
||||||
|
manually like:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make alt
|
make alt
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
In this case it will be built as `sicherman.alt`.
|
||||||
|
|
||||||
|
|
||||||
### Alternate use:
|
### Alternate use:
|
||||||
|
|
||||||
@@ -59,7 +60,7 @@ make alt
|
|||||||
### Alternate try:
|
### Alternate try:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./sicherman.alt < README.md | ./sicherman.alt
|
./try.alt.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,22 +2,25 @@
|
|||||||
#define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n')
|
#define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n')
|
||||||
#define C_C _|_
|
#define C_C _|_
|
||||||
#define b *
|
#define b *
|
||||||
#define C /b/
|
#define c /**/
|
||||||
#define V _C_C(
|
#define v _C_C(
|
||||||
main(C,V)
|
char _,__;
|
||||||
char **V;
|
main(
|
||||||
/* C program. (If you don't
|
/* C program. (If you don't
|
||||||
* understand it look it
|
* understand it look it
|
||||||
*/ up.) (In the C Manual)
|
* up.) (In the */C, Manual)
|
||||||
|
char **Manual;
|
||||||
{
|
{
|
||||||
char _,__;
|
char _,__;
|
||||||
while (read(0,&__,1) & write((_=(_=C_C_(__),C)),
|
while (read(0,&__,1) & write((_=(_=C_C_(__),
|
||||||
_C_,1)) _=C-V+subr(&V);
|
v))?__:__-_+'\b'b'\b'|((_-52)%('\b'b'\b'+~
|
||||||
|
' '&'\t'b'\n')+1),1),&_,1))_=c-v+subr(&v));
|
||||||
}
|
}
|
||||||
|
|
||||||
subr(C)
|
subr(C)
|
||||||
char *C;
|
char *C;
|
||||||
{
|
{
|
||||||
C="Lint says "argument Manual isn't used." What's that
|
C="Lint says \"argument Manual isn't used.\" What's that\
|
||||||
mean?"; while (write((read(C_C('"'-'/*"'/*"*/))?__:__-_+
|
mean?"; while (write((read(('"'-'/*"'))?__:__-_+
|
||||||
'\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1));
|
'\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1));
|
||||||
}
|
}
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
#define C_C_(_)~' '&_
|
|
||||||
#define _C_C(_)('\b'b'\b'>=C_C>'\t'b'\n')
|
|
||||||
#define C_C _|_
|
|
||||||
#define b *
|
|
||||||
#define c /**/
|
|
||||||
#define v _C_C(
|
|
||||||
char _,__;
|
|
||||||
main(
|
|
||||||
/* C program. (If you don't
|
|
||||||
* understand it look it
|
|
||||||
* up.) (In the */C, Manual)
|
|
||||||
char **Manual;
|
|
||||||
{
|
|
||||||
char _,__;
|
|
||||||
while (read(0,&__,1) & write((_=(_=C_C_(__),
|
|
||||||
v))?__:__-_+'\b'b'\b'|((_-52)%('\b'b'\b'+~
|
|
||||||
' '&'\t'b'\n')+1),1),&_,1))_=c-v+subr(&v));
|
|
||||||
}
|
|
||||||
|
|
||||||
subr(C)
|
|
||||||
char *C;
|
|
||||||
{
|
|
||||||
C="Lint says \"argument Manual isn't used.\" What's that\
|
|
||||||
mean?"; while (write((read(('"'-'/*"'))?__:__-_+
|
|
||||||
'\b'b'\b'|((_-52)%('\b'b'\b'+C_C_('\t'b'\n'))+1),1),&_,1));
|
|
||||||
}
|
|
||||||
Executable
+36
@@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# try.alt.sh - demonstrate IOCCC winner 1985/sicherman.alt 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" all >/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: ./sicherman.alt < sicherman.alt.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./sicherman.alt < sicherman.alt.c
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: echo IOCCC | ./sicherman.alt: "
|
||||||
|
echo 1>&2
|
||||||
|
echo IOCCC | ./sicherman.alt
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sicherman.alt: "
|
||||||
|
echo 1>&2
|
||||||
|
./sicherman.alt < sicherman.alt.c | ./sicherman.alt
|
||||||
|
echo 1>&2
|
||||||
|
|
||||||
|
read -r -n 1 -p "Press any key to run: ./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c: "
|
||||||
|
echo 1>&2
|
||||||
|
./sicherman.alt < sicherman.alt.c | ./sicherman.alt | diff -s - sicherman.alt.c
|
||||||
+7
-2
@@ -326,9 +326,14 @@ case as `c`.
|
|||||||
|
|
||||||
Additional code was added in case the fix cannot be compiled by some compilers
|
Additional code was added in case the fix cannot be compiled by some compilers
|
||||||
should they object to `main()` having only one arg. This version will
|
should they object to `main()` having only one arg. This version will
|
||||||
automatically be compiled if the entry fails to compile for some reason.
|
automatically be compiled if the entry fails to compile for some reason but one
|
||||||
|
can compile it manually as `make alt` in which case it'll be compiled as
|
||||||
|
`sicherman.alt` (if it's done because [sicherman.c](/1985/sicherman/sicherman.c)
|
||||||
|
fails to compile it will be built as `sicherman` as part of the `sicherman`
|
||||||
|
rule).
|
||||||
|
|
||||||
Cody also added the [try.sh](/1985/sicherman/try.sh) script.
|
Cody also added the [try.sh](/1985/sicherman/try.sh) and
|
||||||
|
[try.alt.sh](/1985/sicherman/try.alt.sh) scripts.
|
||||||
|
|
||||||
|
|
||||||
# <a name="1986"></a>1986
|
# <a name="1986"></a>1986
|
||||||
|
|||||||
Reference in new issue
Block a user