Merge pull request #1264 from xexyl/1984-mullender-updates
Minor updates to 1984/mullender
This commit is contained in:
9 files changed
+141
-64
No files matched your search
@@ -19,7 +19,7 @@ make all
|
||||
The original version of this entry was added, by request,
|
||||
in order to show the code that was turned into the
|
||||
[tattoo](https://web.archive.org/web/20070120220721/https://thomasscovell.com/tattoo.php),
|
||||
as the alternate code. See below in the tattoo side-by-side with the code.
|
||||
as the alternate code. See below for the tattoo side-by-side with the code.
|
||||
|
||||
### Alternate build:
|
||||
|
||||
@@ -41,8 +41,8 @@ The author was too embarrassed that they could write such trash, so I
|
||||
promised to protect their identity. I will say that the author of this
|
||||
program has a well known connection with the C programming language.
|
||||
|
||||
This program is a unique variation on the age old "Hello, world"
|
||||
program. What reads like a read may be written like a write!
|
||||
This program is a unique variation on the age old "hello, world!" program. What
|
||||
reads like a read may be written like a write!
|
||||
|
||||
In 2005 someone by the name of Thomas Scovell got a tattoo of this entry. See
|
||||
his [web
|
||||
@@ -77,12 +77,11 @@ Landon Curt Noll, the one who told the author about the tattoo, wrote back:
|
||||
|
||||
### Regrets:
|
||||
|
||||
Landon Curt Noll wrote that the author, if they had to do it over again, regrets not
|
||||
making the program a one-liner and not moving the `int i` into an arg of main
|
||||
(so that the line would have started with main). On the other hand the author
|
||||
likes the "two line look" and the way `hell o` was split. :-) And they like the
|
||||
fact that it ends in a smily face: `;}`
|
||||
|
||||
Landon Curt Noll wrote that the author regrets not making the program a
|
||||
one-liner and not moving the `int i` into an arg of main (so that the line would
|
||||
have started with main). On the other hand the author likes the "two line look"
|
||||
and the way `hell o` was split. :-) And they like the fact that it ends in a
|
||||
smily face: `;}`.
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hello, world!\\
|
||||
n",'/'/'/'));}read(j,i,p)void*i;{write(j/p+p,i---j,(int)i/(int)i);}
|
||||
int i;main(){for(;i["]<i;++i){--i;}"];read('-'-'-',i+++"hell\
|
||||
o, world!\n",'/'/'/'));}read(j,i,p)void*i;{write(j/p+p,i---j,(int)i/(int)i);}
|
||||
@@ -70,7 +70,8 @@ which is probably not as uncommon as you think :-).
|
||||
# wait for 500 microseconds and see what happens
|
||||
```
|
||||
|
||||
What happens if you hit enter after it reaches the end of the line? Why?
|
||||
What happens if you hit enter after it reaches the end of the line? Why? What
|
||||
happens after some time of waiting?
|
||||
|
||||
|
||||
## Original code:
|
||||
@@ -165,8 +166,8 @@ make gentab
|
||||
./gentab gentab > g.c
|
||||
```
|
||||
|
||||
NOTE: it is highly unlikely that you will be able to compile and run the output
|
||||
of `gentab` but it should at least compile.
|
||||
NOTE: it is highly unlikely that you will be able to run the output of `gentab`
|
||||
but it should at least compile.
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
@@ -40,7 +40,7 @@ include ../../var.mk
|
||||
#
|
||||
CSILENCE= -Wno-error -Wno-implicit-function-declaration -Wno-format-security \
|
||||
-Wno-int-to-pointer-cast -Wno-int-conversion -Wno-unused-parameter \
|
||||
-Wno-incompatible-pointer-types
|
||||
-Wno-incompatible-pointer-types -Wno-implicit-int -Wno-unused-value
|
||||
|
||||
# Common C compiler warning flags
|
||||
#
|
||||
|
||||
+22
-19
@@ -1,9 +1,6 @@
|
||||
# Best Flow Control
|
||||
|
||||
Mark Schnitzius
|
||||
ISX Corporation
|
||||
1280 West Peachtree St. Apt. 1507
|
||||
Atlanta, GA 30309
|
||||
US
|
||||
<http://computronium.org/ioccc.html>
|
||||
|
||||
@@ -29,29 +26,35 @@ For more detailed information see [1998 schnitzi in bugs.md](/bugs.md#1998-schni
|
||||
## To use:
|
||||
|
||||
```sh
|
||||
./schnitzi 5 > sort.c
|
||||
./schnitzi n > sort.c
|
||||
make sort
|
||||
./sort
|
||||
# enter three numbers, space separated
|
||||
|
||||
echo x y z | ./sort
|
||||
```
|
||||
|
||||
where `n` and `x`, `y` and `z` are numbers.
|
||||
|
||||
|
||||
## Try:
|
||||
|
||||
```sh
|
||||
./schnitzi 3 > sort.c
|
||||
make sort
|
||||
echo 123 > data
|
||||
echo 234 >> data
|
||||
echo 413 >> data
|
||||
echo 134 >> data
|
||||
echo 324 >> data
|
||||
./sort < data
|
||||
./try.sh
|
||||
```
|
||||
|
||||
### INABIAF - it's not a bug it's a feature :-)
|
||||
What happens if at the command line you don't specify `n` numbers that the
|
||||
program expects? For instance try:
|
||||
|
||||
NOTE: the larger the number given to the program the longer the output becomes
|
||||
and quite substantially so. Doing `./schnitzi 9` will actually print 771999
|
||||
lines!
|
||||
```sh
|
||||
./schnitzi 5 > sort.c
|
||||
make sort
|
||||
|
||||
# try running the next command four or five times:
|
||||
echo 2 5 3 1 | ./sort
|
||||
```
|
||||
|
||||
Why does this happen?
|
||||
|
||||
|
||||
## Judges' remarks:
|
||||
@@ -81,9 +84,9 @@ the letter 'e'.
|
||||
|
||||
The IOCCC has been no stranger to this concept. Several winning entries from
|
||||
years past have accomplished interesting feats while completely avoiding the use
|
||||
of certain C constructs thought to be essential (e.g. 1988's
|
||||
[robison.c](//1988/robison/robison.c)). If you have to ask why they would do it
|
||||
this way, then this contest just isn't for you.
|
||||
of certain C constructs thought to be essential (e.g.
|
||||
[1988/robison.c](/1988/robison/robison.c)). If you have to ask why they would
|
||||
do it this way, then this contest just isn't for you.
|
||||
|
||||
In continuing with this fine tradition, this program suggests to the ANSI
|
||||
committee some new practical simplifications for the C language. For instance,
|
||||
|
||||
@@ -52,6 +52,8 @@ void x_(){ O=g; *r=y[k-2]; _=r; j=o_; }
|
||||
void d (){ O=g; *r=y[k]; _=r; k=k+1; m=k<z; w=_t; l=p_; j=p; }
|
||||
void y_(){ O=g; *r=x[17][1]+k; _=r; j=q_; }
|
||||
void r_(){ O=_b; _=x[17]; s=(char**)_d; s=s+1; i=*s; q=0; }
|
||||
main(int v,char **V){ if (V[1]) {if(atoi(V[1])!=0) {
|
||||
main(int v,char **V){
|
||||
((V[1]&&((atoi(V[1])>0&&atoi(V[1])<27)||(exit(1),1))));
|
||||
q=0; O=r_; _d=V;
|
||||
x: (O)(); goto x; }}}
|
||||
x: (O)(); goto x; }
|
||||
|
||||
Executable
+67
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
make all || exit 1
|
||||
|
||||
echo "$ ./schnitzi 3 > sort.c" 1>&2
|
||||
./schnitzi 3 > sort.c
|
||||
|
||||
echo "Compiling sort.c:" 1>&2
|
||||
make sort >/dev/null || exit 1
|
||||
|
||||
echo "...built sort." 1>&2
|
||||
|
||||
echo "Creating data:" 1>&2
|
||||
|
||||
echo "$ echo 234 > data" 1>&2
|
||||
echo 234 > data
|
||||
|
||||
echo "$ echo 413 >> data" 1>&2
|
||||
echo 413 >> data
|
||||
|
||||
echo "$ echo 123 >> data" 1>&2
|
||||
echo 123 >> data
|
||||
|
||||
echo "Sorting data:" 1>&2
|
||||
echo "$ ./sort < data" 1>&2
|
||||
./sort < data
|
||||
|
||||
echo 1>&2
|
||||
|
||||
echo "Using stdin/stdout:" 1>&2
|
||||
echo "$ echo 10 7 9 | ./sort" 1>&2
|
||||
echo "10 7 9" | ./sort
|
||||
|
||||
echo "$ ./schnitzi 5 > sort.c" 1>&2
|
||||
./schnitzi 5 > sort.c
|
||||
|
||||
echo "Compiling sort.c:" 1>&2
|
||||
make sort >/dev/null || exit 1
|
||||
|
||||
echo "...built sort." 1>&2
|
||||
|
||||
echo "Creating data:" 1>&2
|
||||
|
||||
echo "$ echo 124 > data" 1>&2
|
||||
echo 124 > data
|
||||
|
||||
echo "$ echo 422 >> data" 1>&2
|
||||
echo 422 >> data
|
||||
|
||||
echo "$ echo 120 >> data" 1>&2
|
||||
echo 120 >> data
|
||||
|
||||
echo "$ echo 100 >> data" 1>&2
|
||||
echo 100 >> data
|
||||
|
||||
echo "$ echo 777 >> data" 1>&2
|
||||
echo 777 >> data
|
||||
|
||||
echo "Sorting data:" 1>&2
|
||||
echo "$ ./sort < data" 1>&2
|
||||
./sort < data
|
||||
|
||||
echo 1>&2
|
||||
|
||||
echo "Using stdin/stdout:" 1>&2
|
||||
echo "$ echo 5 10 7 9 1 | ./sort" 1>&2
|
||||
echo "5 10 7 9 1" | ./sort
|
||||
@@ -469,7 +469,7 @@ Cody added and fixed the [gentab.c](1984/mullender/gentab.c) which is from the
|
||||
author's (or one of them, Mullender) remarks found by Cody. Cody fixed this to
|
||||
compile and work (as best as he can determine: he has no VAX-11 or PDP-11 or
|
||||
emulator to test it) but running the code on the binary itself produces a
|
||||
`short[]` that can compile in modern systems.
|
||||
`short[]` that can compile in modern systems though it'll not work.
|
||||
|
||||
|
||||
# 1985
|
||||
@@ -1138,38 +1138,22 @@ See above entry [1998/dlowe](1998/dlowe/dlowe.c).
|
||||
### Source code: [1998/schnitzi/schnitzi.c](1998/schnitzi/schnitzi.c)
|
||||
### Information: [1998/schnitzi/README.md](1998/schnitzi/README.md)
|
||||
|
||||
[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) fixed this to work for
|
||||
modern systems but he notes a couple compile warnings to ignore.
|
||||
|
||||
First if you get the warning:
|
||||
|
||||
warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
|
||||
11 | void g(){ O=j; printf(_); }
|
||||
| ^~~~~~
|
||||
|
||||
|
||||
please do NOT change it! Doing so will break the generated output.
|
||||
|
||||
Another warning that was introduced but should be ignored (it's required) is:
|
||||
|
||||
|
||||
warning: assignment to 'char *' from incompatible pointer type 'char **' [-Wincompatible-pointer-types]
|
||||
55 | main(int v,char **c){ O=r_; _d=c;
|
||||
| ^
|
||||
|
||||
Please DO NOT change this either.
|
||||
|
||||
If there are any other warnings triggered by your compiler please DO NOT fix
|
||||
those either!
|
||||
|
||||
Another important note is that as the number passed into the program gets bigger
|
||||
the number of lines of output gets substantially larger. For instance:
|
||||
A point worth considering is that as the number passed into the program gets
|
||||
bigger the number of lines of output gets substantially larger. For instance:
|
||||
|
||||
```sh
|
||||
$ ./schnitzi 9|wc -l
|
||||
771999
|
||||
```
|
||||
|
||||
The larger the number the bigger the file can become too, even becoming
|
||||
gigabytes in size. The range is checked for `>0 && <27` as not having this can
|
||||
be a problem including a segfault.
|
||||
|
||||
If you use the generated program and do not give enough numbers in input
|
||||
something funny will happen, very possibly with different results per run. This
|
||||
is in the README.md file as something to try and ponder.
|
||||
|
||||
|
||||
# 1999
|
||||
|
||||
|
||||
+22
-1
@@ -133,13 +133,18 @@ The problem was to do with the way that the `read(2)` function was redefined.
|
||||
With macOS the second arg needs to be a `void *` and this also necessitated some
|
||||
casts to `int` (on the second arg) in the call to `write(2)` (in `read()`).
|
||||
|
||||
Later Cody corrected the mistake where the `"hello, world!"` string was on one
|
||||
line rather than two lines which the author told us (Landon) that they liked.
|
||||
Thus now it is like the original where the first line ends with `"hell\` and
|
||||
the second line starts with `o, world!\n"`.
|
||||
|
||||
By request, the original code is provided as
|
||||
[anonymous.alt.c](1984/anonymous/anonymous.alt.c) so that one can look at it and
|
||||
the famous tattoo:
|
||||
|
||||

|
||||
|
||||
which was done in 2005 by [Thomas
|
||||
...which was done in 2005 by [Thomas
|
||||
Scovell](https://web.archive.org/web/20070120220721/https://thomasscovell.com/tattoo.php).
|
||||
|
||||
|
||||
@@ -1571,6 +1576,22 @@ linux and further changes for macOS. He also fixed a segfault (after printing
|
||||
garbage) when the arg specified evaluated to 0. It was decided that these
|
||||
segfault fixes should be made because the program is so beautiful.
|
||||
|
||||
Later on Cody improved the fixes by checking that the arg is a number `>0 &&
|
||||
<27` as that was noted by the author as a requirement and again since it's such
|
||||
a beautiful program it is worth it, especially as the larger the number the
|
||||
larger the resulting program becomes. It can be gigabytes in length if it
|
||||
doesn't crash. At this point since the author stated it has no `while`,
|
||||
`do...while`, `for`, `if/else`, `switch`, `?:` Cody removed the if statement by
|
||||
doing:
|
||||
|
||||
```c
|
||||
((V[1]&&((atoi(V[1])>0&&atoi(V[1])<27)||(exit(1),1))));
|
||||
```
|
||||
|
||||
Cody also added the [try.sh](1998/schnitzi/try.sh) script to help users try the
|
||||
commands (as well as some added by him) we recommended.
|
||||
|
||||
|
||||
## [1998/schweikh1](1998/schweikh1/schweikh1.c) ([README.md](1998/schweikh1/README.md]))
|
||||
|
||||
Cody fixed this for modern systems (it did not work at all) and added an
|
||||
|
||||
Reference in new issue
Block a user