Fix 1984/decot to not require -traditional-cpp

This was fun to fix. What prompted me to do so is that I noticed that
the patch from Yusuke Endoh actually doesn't work in fedora linux. It never
worked with clang as it required -traditional-cpp and also had
non-standard second and third args type to main (not a char ** but
implicit int). No more. This entry now works with both linux and macOS!

I was able to remove all the macros as they were problematic and not
needed. The code that used them was updated to be what was necessary.

Add to Makefile inclusion of stdio.h and math.h (printf, floor).
Some systems require -lm so that was also added to the Makefile.

Very little else was required to make it work.

The decot.alt.c is the version patched by Yusuke but fixed by me to
compile with fedora's gcc.

Removed this entry from bugs.md.
This commit is contained in:
Cody Boone Ferguson committed 2023-04-04 06:11:38 -07:00
1 parent 7832ef5e46
commit 606e01cb78
5 files changed
+97 -56

No files matched your search

+47 -17
View File
@@ -6,33 +6,63 @@ Dave Decot
make all
[Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a patch so that this
entry would compile with gcc. Thank you Yusuke!
NOTE: this entry requires a compiler that supports `-traditional-cpp`. Note that
clang does not support it and in macOS gcc is actually clang so this will not
compile with the default compiler in macOS.
Originally [Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a patch so that
this entry would compile with gcc - but not clang - or at least some versions.
Thank you Yusuke! [Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson)
noticed this did not work under fedora linux and it definitely didn't work with
macOS as it requires a compiler that supports `-traditional-cpp` which clang
does not. Clang also requires that the second and third arguments to main be a
`char **`. Cody fixed both problems and now it works under both macOS and linux
- clang and gcc. Thank you Cody for your assistance!
## To run:
./decot
```sh
./decot
```
### Alternative code:
The alternative code, [decot.alt.c](decot.alt.c), is the fix that Cody made to
the version that does require `-traditional-cpp` and still runs afoul with
clang's requirement for the second and third arguments to main() being a `char
**` (the fixed version's main() only has one arg, an int). It is a minor fix to
Yusuke's fix. Thank you Yusuke and Cody!
To try this version:
```sh
make alt
./decot.alt
```
## Judges' comments:
Some new (in 1984) compilers disliked line 15 of the source, so we changed it
from:
for(signal=0;*k * x * __FILE__ *i;) do {
to:
for(signal=0;*k *x * __FILE__ *i;) do {
This program prints out a string of garbage.
The judges also offer this one comment: understand comments!
### Historical comments:
Some new (in 1984) compilers disliked line 15 of the original source, so we changed it
from:
```c
for(signal=0;*k * x * __FILE__ *i;) do {
```
to:
```c
for(signal=0;*k *x * __FILE__ *i;) do {
```
To see what we mean look at the source file in the
[archive/archive-1984.tar.bz2](/archive-1984.tar.bz2) tarball or
[decot.alt.c](decot.alt.c).
## Author's comments:
No comments were provided by the author.