From 6e206fc25abe03ad9cc09f3e787dbb4388d3725a Mon Sep 17 00:00:00 2001 From: Cody Boone Ferguson <53008573+xexyl@users.noreply.github.com> Date: Mon, 27 Mar 2023 08:46:46 -0700 Subject: [PATCH] Add 1988/spinellis/spinellis.alt.c for clang This was fun to do even though it's also a very simple one liner plus special handling in the Makefile (the latter part is so you can use it the exact same way as the original). The original code just #included /dev/tty. This does something just as magical! It can be used like: make alt # some C code ^D ./spinellis For instance: make alt #include int main() { puts("hello world"); } ^D ./spinellis Now those with clang can enjoy the entry without any functional difference. I have a very twisted point to make about the original version and this version too: with a very slight change one can actually make a C++ version. Ick! :-) --- 1988/spinellis/.gitignore | 1 + 1988/spinellis/Makefile | 8 +++++-- 1988/spinellis/README.md | 40 ++++++++++++++++++++++++---------- 1988/spinellis/spinellis.alt.c | 1 + 4 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 1988/spinellis/spinellis.alt.c diff --git a/1988/spinellis/.gitignore b/1988/spinellis/.gitignore index 32df5de2c..691594a06 100644 --- a/1988/spinellis/.gitignore +++ b/1988/spinellis/.gitignore @@ -1,2 +1,3 @@ prog.c spinellis +spinellis.alt diff --git a/1988/spinellis/Makefile b/1988/spinellis/Makefile index b02e52b33..52922a501 100644 --- a/1988/spinellis/Makefile +++ b/1988/spinellis/Makefile @@ -111,8 +111,8 @@ OBJ= ${PROG}.o DATA= spinellis.data TARGET= ${PROG} # -ALT_OBJ= -ALT_TARGET= +ALT_OBJ= ${PROG}.alt.o +ALT_TARGET= ${PROG}.alt ################# @@ -135,6 +135,10 @@ ${PROG}: ${PROG}.c alt: data ${ALT_TARGET} @${TRUE} +${PROG}.alt: ${PROG}.alt.c + ${CC} ${CFLAGS} -Wno-implicit-function-declaration $< -o $@ ${LIBS} + @while read -r r; do echo $$r ; done | ./${PROG}.alt + # data files # data: ${DATA} diff --git a/1988/spinellis/README.md b/1988/spinellis/README.md index 0e83d705e..7db821c21 100644 --- a/1988/spinellis/README.md +++ b/1988/spinellis/README.md @@ -10,11 +10,11 @@ make all -and then type a C program into followed by EOF two times (`^D^D`). - -NOTE: this entry will not compile with clang. Also be advised that gcc in macOS -is actually clang so this will not work even with the default compiler in macOS. +and then type a C program into followed by EOF (usually `^D`, ctrl-d). +[Cody Boone Ferguson](/winners.html#Cody_Boone_Ferguson) made a version (also +one-line) for clang. See the alternative code section below for how to use. +Thank you Cody for your assistance! ## Try: @@ -35,23 +35,39 @@ is actually clang so this will not work even with the default compiler in macOS. printf("%d\n", i); } ^D + ./spinellis + +## Alternative code: + +For clang try the alt code like: + + make clobber alt + #include + main() + { + puts("Hello world\n"); + } ^D ./spinellis -## Judges' comments + +## Judges' comments: We enjoyed this entry this year, however in the future programs must be able to be compiled from within a Makefile without the need of human intervention. -The author originally wrote: +Meanwhile Cody was twisted enough to point out (though to be fair he felt sick +doing this) that with a slight modification this entry can be C++ instead. We don't +thank him for this ghastly point! :-) - This program can be configured to do almost everything. - The configuration is done during compile time by typing - in, C code, that one would like the program to perform. - A trivial example is given in the `how to compile' section - but the possibilities are clearly limited only by your - imagination and programming skills. +## Author's comments: + +This program can be configured to do almost everything. The configuration is +done during compile time by typing in, C code, that one would like the program +to perform. A trivial example is given in the `how to compile' section but the +possibilities are clearly limited only by your imagination and programming +skills. ## Copyright and CC BY-SA 4.0 License: diff --git a/1988/spinellis/spinellis.alt.c b/1988/spinellis/spinellis.alt.c new file mode 100644 index 000000000..2795d4a89 --- /dev/null +++ b/1988/spinellis/spinellis.alt.c @@ -0,0 +1 @@ +main(){system("gcc -x c - -o spinellis");}