Many fixes and additions to 1984/mullender

Swap order of alt and original code in build/try sections so that the
original code is suggested second, after alt code, with the bugs and
(mis)features added to the README.md file, pointing out that it'll only
work on VAX-11 / PDP-11 machines. This is added in the bugs.md (it was
actually missing from the bugs.md file).

The alt code (both versions, see below) now have a lower limit on the
microseconds at 500 (still defaults at 10000). This is because anything
much lower and it's nigh impossible to see and in some cases it won't
work at all (at least in the MacBook Pro with the M1 chip).

Added second alt code which is like the first except that once it times
out it starts over.

Running make alt will compile both alt versions.

The gentab.c file that I added (found from the author) and fixed to
compile could not always create code that would compile due to some
characters needing to be escaped like ' and \. These are now escaped if
they are encountered but there certainly could be more that I did not
think of that would have to be escaped.
This commit is contained in:
Cody Boone Ferguson committed 2023-10-27 03:51:17 -07:00
1 parent 7d28c7eec4
commit 93963607f3
9 files changed
+107 -54

No files matched your search

+2
View File
@@ -1,5 +1,7 @@
mullender
mullender.alt
mullender.alt2
gentab
g.c
mullender.orig
prog.orig
+7 -4
View File
@@ -112,8 +112,8 @@ OBJ= ${PROG}.o
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
#################
@@ -142,8 +142,11 @@ gentab: gentab.c
alt: data ${ALT_TARGET}
@${TRUE}
${ALT_TARGET}: ${PROG}.alt.c
${CC} -include stdio.h -include unistd.h -include stdlib.h ${CFLAGS} $< -o $@ ${LDFLAGS}
${PROG}.alt: ${PROG}.alt.c
${CC} -include stdio.h -include unistd.h -include stdlib.h ${CFLAGS} -Wno-implicit-int $< -o $@ ${LDFLAGS}
${PROG}.alt2: ${PROG}.alt2.c
${CC} -include stdio.h -include unistd.h -include stdlib.h ${CFLAGS} -Wno-implicit-int $< -o $@ ${LDFLAGS}
# data files
#
+60 -38
View File
@@ -9,56 +9,37 @@ Robbert van Renesse
## To build:
```sh
make all
make alt
```
NOTE: the original code will not work on any system other than
[VAX-11](https://en.wikipedia.org/wiki/VAX-11) and
[PDP-11](https://en.wikipedia.org/wiki/PDP-11) and this is why we encourage you
to use the alt version instead. See [original code](#original-code) below for
the original version.
## To use:
```sh
./mullender
```
NOTE: if your machine is not a [VAX-11](https://en.wikipedia.org/wiki/VAX-11)
or [PDP-11](https://en.wikipedia.org/wiki/PDP-11), this program will not execute
correctly. In later years, machine dependent code was discouraged. An alternate
version that will work with other systems is provided as alternate code below.
## Alternate code:
An alternate version exists which allows one to enjoy this entry on systems
other than a [VAX-11](https://en.wikipedia.org/wiki/VAX-11) or
[PDP-11](https://en.wikipedia.org/wiki/PDP-11). This version has a delay feature
as it goes so fast in modern systems. The author suggested that there was a
delay in the original code as well.
### Alternate build:
```sh
make alt
```
### Alternate use:
```sh
./mullender.alt [microseconds]
./mullender.alt2 [microseconds] # starts over after it times out
```
The default microseconds is 10000. This feature is so you can experiment with
The default microseconds is 10000 and it is also the lowest it can be as any
lower doesn't work very well. This feature is so you can experiment with
different speeds in between writes. It can be useful if your CPU is too slow or
too fast.
too fast (:-) ).
Note that it is an `int` (argc) and it uses `atoi()` which does NOT check for
The author stated that the original version also had a delay.
Note that the microseconds is argc and it uses `atoi()` which does NOT check for
overflow!
BTW: is there such a thing as too fast a CPU ? :-) Actually yes for certain code
which is probably not as uncommon as you think :-).
### Alternate try:
### Try:
```sh
@@ -71,6 +52,44 @@ which is probably not as uncommon as you think :-).
./mullender.alt 20000
./mullender.alt 100000
./mullender.alt2 500
# wait for 500 microseconds and see what happens
```
What happens if you hit enter after it reaches the end of the line? Why?
## Original code:
This original code will only execute correctly if your machine is a
[VAX-11](https://en.wikipedia.org/wiki/VAX-11) or
[PDP-11](https://en.wikipedia.org/wiki/PDP-11). In the following years, 1985 on,
machine dependent code was discouraged.
### Original build:
```sh
make all
```
### Bugs and (Mis)features:
This entry a listed in [bugs.md](/bugs.md) as:
```
STATUS: INABIAF - please **DO NOT** fix
```
For more detailed information see [bugs.md](/bugs.md#1984mullender-readmemd).
### Original use:
```sh
./mullender
```
@@ -122,7 +141,7 @@ close to as the original as possible we used a copy of
in the *fabulous* [Unix History
Repo](https://github.com/dspinellis/unix-history-repo/tree/Research-Release).
### Alternate build:
### gentab build:
`gentab.c` can be built like:
@@ -131,18 +150,21 @@ Repo](https://github.com/dspinellis/unix-history-repo/tree/Research-Release).
make gentab
```
### Alternate use:
### gentab use:
```sh
./gentab file
```
### Alternate try:
### gentab try:
```sh
./gentab 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.
## Author's remarks:
### Notes from the judges:
+2 -1
View File
@@ -40,7 +40,8 @@ main(argc, argv) char **argv;
fmt = "0x%x"; break;
}
if (32 <= n && n < 127 && (rand() % 4)) fmt = "'%c'";
if (n == '\\' || n == '\'') fmt = "'\\%c'";
else if (32 <= n && n < 127 && (rand() % 4)) fmt = "'%c'";
printf(n < 8 ? "%d" : fmt, n);
printf(",");
if (pos++ == 8) {
+1 -1
View File
@@ -1 +1 @@
main(i,v)char**v;{i=v[1]?atoi(v[1]):10000;do write(1," :-)\b\b\b\b",9),usleep(i);while(--i);}
main(i,v)char**v;{i=v[1]?atoi(v[1]):10000;i=i<500?500:i;do write(1," :-)\b\b\b\b",9),usleep(i);while(--i);write(1,"\n",1);}
+1
View File
@@ -0,0 +1 @@
main(i,v)char**v;{j:i=v[1]?atoi(v[1]):10000;i=i<500?500:i;do write(1," :-)\b\b\b\b",9),usleep(i);while(--i);write(1,"\n",1);goto j;}