Improve my fixes to 1984/decot
To make it look more like the original but to still work with compilers without -traditional-cpp (which clang does not support) and other defects with clang (including one that was problematic in linux but not macOS) code that used macros had to be modified and used directly. But I removed the macros because of this. Now they are added back even though they are unused, just to give it a more authentic, original look. The thanks-for-fixes.md file was updated for this, both formatting and otherwise, but an unfortunate thing is that another entry was also modified in there. This is because I was aiming to just do format fixes in 1984 in one pull request to save time but then I came across this and decided to fix it and this should be in a single pull request. Something I noticed is that the fix for linux clang _appears_ to not be needed at least with clang 16.0.6 but what the difference is is just extra warnings. I cannot imagine I changed it just for that so I have left that change in in case there was a problem in earlier versions or something else I do not recall. It should be noted that without the change at least with clang 16.0.6 it appears to work just fine. It is unclear if it should be changed back but again as I can't imagine that I would have changed it just for warnings I think it's wiser not to.
This commit is contained in:
1 parent
c19a19923f
commit
aae8bf1b83
3 files changed
+42
-27
No files matched your search
@@ -1,7 +1,6 @@
|
|||||||
# Second place award
|
# Second place award
|
||||||
|
|
||||||
Dave Decot
|
Dave Decot
|
||||||
|
|
||||||
|
|
||||||
## To build:
|
## To build:
|
||||||
|
|
||||||
@@ -9,14 +8,12 @@ Dave Decot
|
|||||||
make all
|
make all
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## To run:
|
## To run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
./decot
|
./decot
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
### Alternate code:
|
### Alternate code:
|
||||||
|
|
||||||
To try the original code that requires `-traditional-cpp`:
|
To try the original code that requires `-traditional-cpp`:
|
||||||
@@ -26,7 +23,6 @@ make alt
|
|||||||
./decot.alt
|
./decot.alt
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Judges' remarks:
|
## Judges' remarks:
|
||||||
|
|
||||||
This program prints out a string of garbage.
|
This program prints out a string of garbage.
|
||||||
@@ -36,8 +32,8 @@ The judges also offer this one comment: understand remarks!
|
|||||||
|
|
||||||
### Historical remarks:
|
### Historical remarks:
|
||||||
|
|
||||||
Some new (in 1984) compilers disliked line 15 of the original source, so we changed it
|
Some new (in 1984) compilers disliked line 15 of the original source, so we
|
||||||
from:
|
changed it from:
|
||||||
|
|
||||||
```c
|
```c
|
||||||
for(signal=0;*k * x * __FILE__ *i;) do {
|
for(signal=0;*k * x * __FILE__ *i;) do {
|
||||||
@@ -49,7 +45,6 @@ to:
|
|||||||
for(signal=0;*k *x * __FILE__ *i;) do {
|
for(signal=0;*k *x * __FILE__ *i;) do {
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
To see what we mean look at the [original source file](decot.orig.c).
|
To see what we mean look at the [original source file](decot.orig.c).
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,8 @@
|
|||||||
|
#define x =
|
||||||
|
#define double(a,b) int
|
||||||
|
#define char k['a']
|
||||||
|
#define union static struct
|
||||||
|
|
||||||
int b,
|
int b,
|
||||||
k['a'] = {sizeof(
|
k['a'] = {sizeof(
|
||||||
int(*)())
|
int(*)())
|
||||||
|
|||||||
+34
-19
@@ -95,13 +95,25 @@ Scovell](https://web.archive.org/web/20070120220721/https://thomasscovell.com/ta
|
|||||||
|
|
||||||
## [1984/decot](1984/decot/decot.c) ([README.md](1984/decot/README.md]))
|
## [1984/decot](1984/decot/decot.c) ([README.md](1984/decot/README.md]))
|
||||||
|
|
||||||
Cody fixed this to not require `-traditional-cpp` which not all compilers
|
Cody fixed this to not require `-traditional-cpp` which some compilers like
|
||||||
support (clang does not support it for example). Clang is also more strict about
|
clang do not support. Fixing `-traditional-cpp` is, as noted earlier, very
|
||||||
the args' types in `main()` and this was also a problem that Cody fixed, making
|
complicated, but we encourage you to look at the alternate code (which is the
|
||||||
it work with both clang and gcc - in macOS. It was then noticed that with clang
|
original code with a minor modification made by the judges) and the fixed
|
||||||
in linux it did not work so this had to be further fixed which Cody also did.
|
code, to see what had to be done.
|
||||||
For the original code with the gcc fix (noted below), see the alternate code
|
|
||||||
section in the README.md file.
|
Clang is also more strict about the type of args in `main()` and this was also a
|
||||||
|
problem that Cody fixed, making it work with both clang and gcc.
|
||||||
|
|
||||||
|
These fixes worked fine in macOS but it turned out that in some cases with clang
|
||||||
|
in linux it did not work so this had to be further fixed which Cody also did. It
|
||||||
|
is no longer clear what the problem was as in fedora 38 with clang 16.0.6 the
|
||||||
|
only difference is it causes additional warnings but it seems to work just fine.
|
||||||
|
It seems unlikely that a fix was made just for warnings so it is presumed that
|
||||||
|
there was another problem so the change is kept in place.
|
||||||
|
|
||||||
|
A note about the fix is that the `#define`d macros that were used still exist
|
||||||
|
but are not used; they are left in just to make it look more like the original
|
||||||
|
entry. Nevertheless they cannot be used.
|
||||||
|
|
||||||
Originally Yusuke supplied a patch so that this entry would compile with gcc -
|
Originally Yusuke supplied a patch so that this entry would compile with gcc -
|
||||||
but not clang - or at least some versions.
|
but not clang - or at least some versions.
|
||||||
@@ -109,26 +121,29 @@ but not clang - or at least some versions.
|
|||||||
|
|
||||||
## [1984/mullender](1984/mullender/mullender.c) ([README.md](1984/mullender/README.md]))
|
## [1984/mullender](1984/mullender/mullender.c) ([README.md](1984/mullender/README.md]))
|
||||||
|
|
||||||
Cody provided an alternate version which was an improved version from the judges
|
Cody provided an alternate version, an improved version of the judges, so that
|
||||||
so that everyone can enjoy it with systems that are not VAX/PDP. We also refer you
|
everyone can enjoy it with systems that are not VAX/PDP. We also refer you to
|
||||||
to the [FAQ](faq.md) as there are some winning entries that also let one enjoy
|
the [FAQ](faq.md) as there are some winning entries that also let one enjoy it -
|
||||||
it - with more to them of course!
|
with more to them of course!
|
||||||
|
|
||||||
Cody also added the [gentab.c](1984/mullender/gentab.c) file, modified to
|
Cody also added the [gentab.c](1984/mullender/gentab.c) file, modified to
|
||||||
compile with modern systems, which the author noted in their remarks which Cody
|
compile with modern systems, which the author noted in their remarks (which Cody
|
||||||
also found.
|
also found).
|
||||||
|
|
||||||
|
|
||||||
## [1985/applin](1985/applin/applin.c) ([README.md](1985/applin/README.md]))
|
## [1985/applin](1985/applin/applin.c) ([README.md](1985/applin/README.md]))
|
||||||
|
|
||||||
Yusuke provided a patch to get this to not crash and Cody fixed this to
|
Both Cody and Yusuke fixed this; Yusuke got this to not crash and Cody fixed it
|
||||||
work with macOS (it printed the string `H????` in a seemingly infinite loop,
|
to work with macOS.
|
||||||
each time printing another `?`).
|
|
||||||
|
|
||||||
The problem with the crash is that it destructively rewrites string literals but
|
The crash was because it destructively rewrites string literals. However with
|
||||||
with `strdup()` it's safe.
|
`strdup()` it's safe.
|
||||||
|
|
||||||
For macOS it's because there was no prototype for `execlp()` and macOS has
|
The problem with macOS is that although it didn't crash, it printed `H????` in a
|
||||||
|
seemingly infinite loop, each time printing another `?`, probably until it ran
|
||||||
|
out of memory.
|
||||||
|
|
||||||
|
The fix for macOS is that there was no prototype for `execlp()` and macOS has
|
||||||
problems with missing prototypes for some functions (this was also seen when
|
problems with missing prototypes for some functions (this was also seen when
|
||||||
Cody fixed [1984/anonymous](/1984/anonymous/anonymous.c) for macOS as well).
|
Cody fixed [1984/anonymous](/1984/anonymous/anonymous.c) for macOS as well).
|
||||||
Ironically this fix was discovered through linux!
|
Ironically this fix was discovered through linux!
|
||||||
|
|||||||
Reference in new issue
Block a user