Merge pull request #279 from xexyl/1984-decot
Fix 1984/decot to not require -traditional-cpp
This commit is contained in:
5 files changed
+97
-56
No files matched your search
+4
-9
@@ -63,7 +63,7 @@ CDEFINE=
|
|||||||
|
|
||||||
# Include files that are needed to compile
|
# Include files that are needed to compile
|
||||||
#
|
#
|
||||||
CINCLUDE=
|
CINCLUDE= -include stdio.h -include math.h
|
||||||
|
|
||||||
# Optimization
|
# Optimization
|
||||||
#
|
#
|
||||||
@@ -75,7 +75,7 @@ CFLAGS= ${CSTD} ${CWARN} ${ARCH} ${CDEFINE} ${CINCLUDE} ${OPT}
|
|||||||
|
|
||||||
# Libraries needed to build
|
# Libraries needed to build
|
||||||
#
|
#
|
||||||
LIBS=
|
LIBS= -lm
|
||||||
|
|
||||||
# C compiler to use
|
# C compiler to use
|
||||||
#
|
#
|
||||||
@@ -114,12 +114,8 @@ OBJ= ${PROG}.o
|
|||||||
DATA=
|
DATA=
|
||||||
TARGET= ${PROG}
|
TARGET= ${PROG}
|
||||||
#
|
#
|
||||||
ALT_OBJ=
|
ALT_OBJ= ${PROG}.alt.o
|
||||||
ALT_TARGET=
|
ALT_TARGET= ${PROG}.alt
|
||||||
|
|
||||||
# FORCE use of -traditional-cpp
|
|
||||||
#
|
|
||||||
CFLAGS+= -traditional-cpp
|
|
||||||
|
|
||||||
|
|
||||||
#################
|
#################
|
||||||
@@ -134,7 +130,6 @@ all: data ${TARGET}
|
|||||||
supernova deep_magic magic charon pluto
|
supernova deep_magic magic charon pluto
|
||||||
|
|
||||||
${PROG}: ${PROG}.c
|
${PROG}: ${PROG}.c
|
||||||
@echo "NOTE: this entry requires a compiler that supports -traditional-cpp."
|
|
||||||
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
${CC} ${CFLAGS} $< -o $@ ${LIBS}
|
||||||
|
|
||||||
# alternative executable
|
# alternative executable
|
||||||
|
|||||||
+47
-17
@@ -6,33 +6,63 @@ Dave Decot
|
|||||||
|
|
||||||
make all
|
make all
|
||||||
|
|
||||||
[Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a patch so that this
|
Originally [Yusuke Endoh](/winners.html#Yusuke_Endoh) supplied a patch so that
|
||||||
entry would compile with gcc. Thank you Yusuke!
|
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)
|
||||||
NOTE: this entry requires a compiler that supports `-traditional-cpp`. Note that
|
noticed this did not work under fedora linux and it definitely didn't work with
|
||||||
clang does not support it and in macOS gcc is actually clang so this will not
|
macOS as it requires a compiler that supports `-traditional-cpp` which clang
|
||||||
compile with the default compiler in macOS.
|
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:
|
## 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:
|
## 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.
|
This program prints out a string of garbage.
|
||||||
|
|
||||||
The judges also offer this one comment: understand comments!
|
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:
|
## Author's comments:
|
||||||
|
|
||||||
No comments were provided by the author.
|
No comments were provided by the author.
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
int printf(const char *format, ...);
|
||||||
|
double floor(double x);
|
||||||
|
#define x =
|
||||||
|
#define double(a,b) int
|
||||||
|
#define char k['a']
|
||||||
|
#define union static struct
|
||||||
|
|
||||||
|
double (x1, y1) b,
|
||||||
|
char x {sizeof(
|
||||||
|
double(%s,%D)(*)())
|
||||||
|
,};
|
||||||
|
struct tag{int x0,*xO;}
|
||||||
|
|
||||||
|
*main(i, dup, signal) {
|
||||||
|
{
|
||||||
|
for(signal=0;*k *x * __FILE__ *i;) do {
|
||||||
|
(printf(&*"'\",x); /*\n\\", (*((double(tag,u)(*)())&floor))(i)));
|
||||||
|
goto _0;
|
||||||
|
|
||||||
|
_O: while (!(char <<x - dup)) { /*/*\*/
|
||||||
|
union tag u x{4};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
while(b x 3, i); {
|
||||||
|
char x b,i;
|
||||||
|
_0:if(b&&(int)k+
|
||||||
|
sin(signal) / * ((main) (b)-> xO));/*}
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
*/}}}
|
||||||
+13
-17
@@ -1,30 +1,26 @@
|
|||||||
#define x =
|
int b,
|
||||||
#define double(a,b) int
|
k['a'] = {sizeof(
|
||||||
#define char k['a']
|
int(*)())
|
||||||
#define union static struct
|
|
||||||
|
|
||||||
double (x1, y1) b,
|
|
||||||
char x {sizeof(
|
|
||||||
double(%s,%D)(*)())
|
|
||||||
,};
|
,};
|
||||||
struct tag{int x0,*xO;}
|
struct tag{int x0,*xO;};
|
||||||
|
|
||||||
*main(i, dup, signal) {
|
int dup, signal;
|
||||||
|
*main(int i) {
|
||||||
{
|
{
|
||||||
for(signal=0;*k *x * __FILE__ *i;) do {
|
for(signal=0;*k *= * __FILE__ *i;) do {
|
||||||
(printf(&*"'\",x); /*\n\\", (*((double(tag,u)(*)())&floor))(i)));
|
(printf(&*"'\",x); /*\n\\", (*((int(*)())&floor))(i)));
|
||||||
goto _0;
|
goto _0;
|
||||||
|
|
||||||
_O: while (!(char <<x - dup)) { /*/*\*/
|
_O: while (!(k['a'] <<= - dup)) { /*/*\*/
|
||||||
union tag u x{4};
|
static struct tag u = {4};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
while(b x 3, i); {
|
while(b = 3, i); {
|
||||||
char x b,i;
|
k['a'] = b,i;
|
||||||
_0:if(b&&(int)k+
|
_0:if(b&&(int)k+
|
||||||
sin(signal) / * ((main) (b)-> xO));/*}
|
sin(signal) / * ((main) (((struct tag *)b)-> xO)));/*}
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -245,19 +245,6 @@ this in the [README.md](1984/anonymous/README.md) file. Can you fix this? We
|
|||||||
welcome your help!
|
welcome your help!
|
||||||
|
|
||||||
|
|
||||||
## [1984/decot](1984/decot/decot.c) ([README.md](1984/decot/README.md))
|
|
||||||
## STATUS: requires a compiler supporting `-traditional-cpp` - alternate code requested
|
|
||||||
|
|
||||||
This entry needs a compiler that support `-traditional-cpp`. `gcc`
|
|
||||||
supports this but `clang` does not. Please be advised that `gcc` under macOS is
|
|
||||||
actually gcc if it looks like it's gcc (two different binaries).
|
|
||||||
|
|
||||||
If you do wish to provide an alternate version of the program that does not need
|
|
||||||
compiler supporting `-traditional-cpp` you are welcome to submit such code via a [GitHub pull request](https://github.com/ioccc-src/temp-test-ioccc/pulls) and we will be happy to credit you in the entry's _README.md_ file.
|
|
||||||
|
|
||||||
|
|
||||||
# 1984
|
|
||||||
|
|
||||||
|
|
||||||
# 1985
|
# 1985
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user